Cloud Service >> Knowledgebase >> Cloud Server >> How to Install Apache Web Server on Linux Cloud Server?
submit query

Cut Hosting Costs! Submit Query Today!

How to Install Apache Web Server on Linux Cloud Server?

When discussing web server software in today’s cloud industry, Apache HTTP Server is among the most acknowledged solutions. Following is the knowledge base article: This tutorial describes how to install Apache on a Linux cloud server and mostly focuses on Ubuntu and CentOS brands.

 

This will allow you to install the complete running Apache web server in the shortest time possible.

 

Prerequisites:

- A Linux cloud server (Ubuntu or CentOS)

- Root or sudo access to the server

- Basic knowledge of Linux command-line interface

 

Step 1: Update System Packages

 

For Ubuntu:

```

sudo apt update

sudo apt upgrade

```

 

For CentOS:

```

sudo yum update

```

 

Step 2: Install Apache Web Server

 

For Ubuntu:

```

sudo apt install apache2

```

 

For CentOS:

```

sudo yum install httpd

```

 

Step 3: Start and Enable Apache Service

 

After installation, you need to start the Apache service and enable it to run on system boot.

 

For Ubuntu:

```

sudo systemctl start apache2

sudo systemctl enable apache2

```

 

For CentOS:

```

sudo systemctl start httpd

sudo systemctl enable httpd

```

 

Step 4: Verify Apache Installation

 

To ensure Apache is running correctly, you can check its status using the following command:

 

For Ubuntu:

```

sudo systemctl status apache2

```

 

For CentOS:

```

sudo systemctl status httpd

```

 

You should see "active (running)" in the output, indicating that Apache is functioning properly.

 

Step 5: Firewall Configuration

 

If your server has a firewall enabled, you will need to allow HTTP & HTTPS traffic.

 

For Ubuntu (using UFW):

```

sudo ufw allow 'Apache Full'

```

 

For CentOS (using firewalld):

```

sudo firewall-cmd --permanent --add-service=http

sudo firewall-cmd --permanent --add-service=https

sudo firewall-cmd --reload

```

 

Step 6: Test Apache Web Server

 

We have to use our browser to prove that webpages are being served by Apache, simply by typing the server IP address or Domain name. You should observe the default Apache welcome page here if you are successful with the above steps.

 

Step 7: Configure Apache (Optional)

 

Ubuntu users may find the primary Apache configuration file at 

 

-/etc/apache2/apache2.conf.

-CentOS: httpd.conf in /etc/httpd/conf

 

Step 8: Set Up Virtual Hosts

 

Several websites may be hosted on a single server thanks to virtual hosting. How to configure a virtual host

 

1. Create a directory for your website:

```

sudo mkdir -p /var/www/your_domain

```

 

2. Assign ownership of the directory:

```

sudo chown -R $USER:$USER /var/www/your_domain

```

 

3. Create a sample index.html file:

```

echo "Welcome to Your Website" > /var/www/your_domain/index.html

```

 

4. Create a virtual host configuration file:

   - Ubuntu: /etc/apache2/sites-available/your_domain.conf

   - CentOS: /etc/httpd/conf.d/your_domain.conf

 

5. Add the following configuration (adjust as needed):

```

    ServerName your_domain

    ServerAlias www.your_domain

    DocumentRoot /var/www/your_domain

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

```

 

6. Enable the virtual host (Ubuntu only):

```

sudo a2ensite your_domain.conf

```

 

7. Restart Apache to apply changes:

   - Ubuntu: sudo systemctl restart apache2

   - CentOS: sudo systemctl restart httpd

 

Troubleshooting:

 

1. Apache not starting:

   - Check error logs: /var/log/apache2/error.log (Ubuntu) or /var/log/httpd/error_log (CentOS)

   - Verify configuration syntax: apache2ctl configtest (Ubuntu) or httpd -t (CentOS)

 

2. Permission issues:

   - Ensure proper ownership and permissions on the web root directory

   - Check SELinux settings (CentOS)

 

3. Unable to access the website:

   - Verify firewall settings

   - Check Apache status and ensure it's running

   - Confirm DNS settings if using a domain name

 

Setting up Apache on the Linux cloud server is perhaps one of the easiest tasks that would give you a rock-solid web-serving platform. Thus, you have mastered the process of extending Apache to host multiple websites by using the directions from this guide. This has to be done carefully and according of the security updates and the general rules of web server management.

 

Bonus Advice

 

To gain a perfect experience when installing Apache and managing it, seek the managed cloud hosting solutions from Cyfuture Cloud. Let our highly qualified specialist set up, adjust, and provide further support of the Apache web server for you, while you concentrate on your work. Cyfuture Cloud will provide you with transparent, fast infrastructure with around-the-clock support services and customizable solutions. Capture the efficiencies of cloud hosting services with Cyfuture Cloud as your company’s web applications accelerator.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!