To install an Apache server, execute the following steps: Install the Web Server package group:
# yum groupinstall -y "Web Server"
Edit the /etc/hosts file and the ip address and fully qualified domain name of the server:
Note: This is not mandatory but avoids further warning messages.
Optionally, you can set the ServerName directive in the /etc/httpd/conf/httpd.conf file.
Activate at boot time and start the service:
# systemctl enable httpd # systemctl start httpd
Add the HTTP service to the firewall configuration and reload it:
# firewall-cmd --permanent --add-service=http Success # firewall-cmd --reload Success
Note: If you plan to use the HTTPS protocol, the command should be # firewall-cmd –permanent –add-service=https
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.ddirectory, 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>
Now, every file created in the /var/www/html directory will be displayed by the webserver.