What is Apache HTTP?
The Apache HTTP Server is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.
Table of Contents
Step 1 – Updating the system
Step 2 – Install Apache
Step 3 – Check Apache status
Step 4 – Set up Virtual Hosts
## Step 1 – Updating the system##
sudo apt update
Updating Ubuntu system
## Step 2 – Install Apache##
sudo apt install apache2
Install Apache Ubuntu
## Step 3 – Check Apache status##
sudo systemctl status apache2
Check Apache status
Open your IP address on the browser to check if the Apache server is loading
Apache2 Ubuntu
## Step 4 – Set up Virtual Hosts##
Create your domain directory on the server
sudo mkdir /var/www/domain-name
Give permissions to your domain directory
sudo chmod -R 755 /var/www/domain-name
Create a sample index.html
touch /var/www/domain-name/index.html
echo "Your domain is now online" > /var/www/domain-name/index.html
Create a virtual host file
sudo nano /etc/apache2/sites-available/domain-name.conf
Add the following content to your domain-name.conf file
>
- ServerAdmin webmaster@localhost
- ServerName domain-name
- ServerAlias www.domain-name
- DocumentRoot /var/www/domain-name
- ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
<\/VirtualHost>
Use a2ensite to enable the file
sudo a2ensite domain-name.conf
or
sudo a2ensite /etc/apache2/sites-available/domain-name.conf
Next, we have to disable the default file
sudo a2dissite 000-default.conf
Check for errors
sudo apache2ctl configtest
The output should be Syntax OK
Restart Apache and navigate to your domain on the browser
sudo systemctl restart apache2/
End