What is Apache ?
The Apache webserver is an opensource and popular HTTP web server that continues to enjoy a massive market share in the hosting industry. It ships with loads of features including module enhancements, multi-protocol support, simplified configuration, and multi-language support to mention just a few.
How To Install Apache on Centos 8 ?
You just need to update your current system and use dnf package manager for installing using the following commands
$ sudo dnf update
$ sudo dnf install httpd
Validation
You can use rpm -qa <package name > for validation
![](http://unixcop.com/wp-content/uploads/2021/05/image-1.png)
Starting the Apache Server
sudo systemctl start httpd
sudo systemctl status httpd
![](http://unixcop.com/wp-content/uploads/2021/05/image-2-1024x388.png)
From the output, the ‘active‘ status indicates that the Apache webserver is up and running.
Validation
From any browser , you can issue http://<Listening_IP_Address> or http://hostname
![](http://unixcop.com/wp-content/uploads/2021/05/image-3-1024x529.jpg)
Setting Up Apache Virtual Hosts
A virtual host is a separate file that contains configurations that allow you to set up a separate domain from the default one. For this guide, we will set up a virtual host for the domain alfa.unixcop.com/
The default virtual host is located at the /var/www/html
directory. This works only for a single site. To create a separate virtual host for our domain, we will create another directory structure within the /var/www
directory as shown.
sudo mkdir -p /var/www/alfa.unixcop.com
Next, edit the file permissions use the $USER
environment variable as shown.
sudo chown -R $USER:$USER /var/www/alfa.unixcop.com/html
Also, adjust the permissions of the webroot directory as shown.
sudo chmod -R 755 /var/www
Next, create a sample index.html
file using the following command.
sudo vi /var/www/alfa.unixcop.com/html/index.html
<html>
<head>
<title>Welcome to Alfa.unixcop.com!</title>
</head>
<body>
<h1>virtual host is up and perfectly working!</h1>
</body>
</html>
Save and exit the configuration file.
Next, we need to create alfa.unixcop.com.conf as the configuration file for the virtual host using the following
cd /etc/httpd/conf.d/
sudo vi alfa.unixcop.com.conf
and add below :
<VirtualHost *:80>
ServerName www.alfa.unixcop.com
ServerAlias alfa.unixcop.com
DocumentRoot /var/www/alfa.unixcop.com/html
</VirtualHost>
Restart Apache for the changes to be applied.
$ sudo systemctl restart httpd
Last thing , you need to open any browser and issue http://alfa.unixcop.com
![](http://unixcop.com/wp-content/uploads/2021/05/image-3-1024x270.png)
I am trying to create virtual host and I following your post but I’m don’t succeeding to load my .war in browser, can you help me?