Apache configuration in RHEL 7
Apache configuration in RHEL 7
Check “httpd” installed or not.
[root@feenixdv77 ~]# yum install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package httpd-2.4.6-31.el7.centos.x86_64 already installed and latest version
Start apache service and check status of service.
[root@feenixdv77 ~]# systemctl start httpd
[root@feenixdv77 ~]# systemctl status httpd
httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
Active: active (running) since Tue 2016-12-20 09:22:07 EST; 8s ago
Main PID: 9384 (httpd)
Status: "Processing requests…"
CGroup: /system.slice/httpd.service
In RHEL 7 in “httpd.conf” “VirtualHost” section not present so we can copy this format from bellow location and see the example page on browser.
[root@feenixdv77 manual]# cp /usr/share/httpd/manual/vhosts/examples.html /var/www/html/
Then modify “httpd.conf” as per requirement.
Then create director “feenix” and one sample page “index.html” with some content.
Then restart service and open page on web browser.
We can customized log in bellow location.
Some advance configuration of apache web server.
Running several name-based web sites on a single IP address.
Your server has a single IP address, and multiple aliases (CNAMES) point to this machine in DNS. You want to run a web server for www.feenix.com and www.feenix.org on this machine.
# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
DocumentRoot /www/feenix1
ServerName www.feenix.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/feenix2
ServerName www.feenix.org
# Other directives here
</VirtualHost>
Serving the same content on different IP addresses (such as an internal and external address).
The server machine has two IP addresses (192.168.1.1 and 172.20.30.40). The machine is sitting between an internal (intranet) network and an external (internet) network.
<VirtualHost 192.168.1.1 172.20.30.40>
DocumentRoot /www/server1
ServerName server.feenix.com
ServerAlias server
</VirtualHost>
Mixed port-based and ip-based virtual hosts
The server machine has two IP addresses (172.20.30.40 and 172.20.30.50) which resolve to the names www.feenix.com and www.feenix.org respectively. In each case, we want to run hosts on ports 80 and 8080.
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080<VirtualHost 172.20.30.40:80>
DocumentRoot /www/The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.
Listen 80
ServerName www.feenix.com
DocumentRoot /www/feenix1
<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/feenix2
ServerName www.feenix.org
# …
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/feenix3
ServerName www.feenix.net
ServerAlias *.feenix.net
# …
</VirtualHost>
1-80
ServerName www.feenix.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/feenix1-8080
ServerName www.feenix.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/feenix2-80
ServerName www.feenix.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/feenix2-8080
ServerName www.feenix.org
</VirtualHost>
Migrating a name-based vhost to an IP-based vhost
The solution is easy, because we can simply add the new IP address (172.20.30.50) to the VirtualHost directive.
Listen 80
ServerName www.feenix.com
DocumentRoot /www/feenix1
<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/feenix2
ServerName www.feenix.org
# …
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/feenix3
ServerName www.feenix.net
ServerAlias *.feenix.net
# …
</VirtualHost>