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.
Step 1 – Updating the system
sudo apt update
Step 2 – Install Apache
sudo apt install apache2
Step 3 – Check Apache status
sudo systemctl status apache2
Open your IP address on the browser to check if the Apache server is loading
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
<VirtualHost *:80>
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
2 Comments
How To Install Webmin On Ubuntu 20.04 - Virtono Community · July 26, 2022 at 12:16 PM
[…] Apache installed (Click here for the installation tutorial) […]
Install The Apache On CentOS - Virtono Community · April 19, 2023 at 3:21 PM
[…] the installation is complete, you can start the Apache on CentOS service by running the following […]