1. Run the following command:
sudo yum install httpd
2. Keep a backup copy after httpd.conf
cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup.timestamp
3. Check installed version with:
httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Oct 19 2017 20:39:16
4. Right now httpd is installed and not running:
service httpd status
Redirecting to /bin/systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
5. Create document root folder:
cd /var/www/html && mkdir test.com
6. Add document root to httpd.conf
vi /etc/httpd/conf/httpd.conf
...
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/html/test.com"
...
7. Configure virtual host:
cd /etc/httpd/conf.d
touch vhost.conf
vi vhost.conf
....
<VirtualHost *:80>
ServerName localhost
ServerAlias www.test.com
DocumentRoot /var/www/html/test.com/
ErrorLog logs/error.log
CustomLog logs/access.log combined
</VirtualHost>
...
8. Test httpd configuration by running:
service httpd configtest
Syntax OK
9. Start apache httpd:
service httpd start
10. Check service is running:
service httpd status
Redirecting to /bin/systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2017-11-29 07:44:34 PST; 7s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 21159 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─21159 /usr/sbin/httpd -DFOREGROUND
├─21160 /usr/sbin/httpd -DFOREGROUND
├─21161 /usr/sbin/httpd -DFOREGROUND
├─21162 /usr/sbin/httpd -DFOREGROUND
├─21163 /usr/sbin/httpd -DFOREGROUND
└─21164 /usr/sbin/httpd -DFOREGROUND
11. Make sure Inbound port 80 is enabled on CentOS 7 Firewall:
firewall-cmd --zone=public --add-port=80/tcp
success
12. Test from within browser apache is accessible:
No comments:
Post a Comment