Installation instructions yum groupinstall -y "Web Server"
Edit the /etc/hosts file and the ip address and fully qualified domain name of the server :
Activate at boot time and start the service:
# systemctl enable httpd
# systemctl start httpd
sed -i ‘s/Enforcing/Disabled/g’ /etc/selinux/config
If you send a request to your new webserver, you will get the welcome page whatever you put into the /var/www/html directory. This is due to the IncludeOptional conf.d/*.conf statement at the end of the /etc/httpd/conf/httpd.conf file that instructs Apache to load the files finishing by *.conf located in the /etc/httpd/conf.d directory.
If you really want to display the content of the /var/www/html directory, you need to go to the /etc/httpd/conf.d directory and remove all the files there (you can also rename them but with an extension different from .conf).
Then, still in the /etc/httpd/conf.d directory, you can create a file (here mywebserver.conf) like below (the name doesn’t matter, only the extension in .conf):
<Directory /var/www/html> AllowOverride None Require all granted </Directory>
<VirtualHost *:80> DocumentRoot /var/www/html/serverx.example.com ServerName serverx.example.com ErrorLog logs/serverx.example.com-error_log CustomLog logs/serverx.example.com-access_log common </VirtualHost>
Check the validity of the configuration:
check apache config apache configtest Syntax OK systemctl restart httpd
Check the virtual host(s) configuration:
# httpd -D DUMP_VHOSTS VirtualHost configuration: *:80 is a NameVirtualHost default server dummy-host.example.com (/etc/httpd/conf.d/vhosts.conf:1) port 80 namevhost dummy-host.example.com (/etc/httpd/conf.d/vhosts.conf:1) port 80 namevhost dummy-host.example.com (/etc/httpd/conf.d/vhosts.conf:1)
Source:RHEL 7 HTTP Vhost