Sunday, April 24, 2016

Configuring a Simple Web Server


  • Creating a Web Server using default configuration.
    • yum install -y httpd httpd-manual
    • systemctl enable httpd
    • systemctl start httpd
    • firewall-cmd --permanent --add-service=http --add-service=https
    • firewall-cmd --reload
    • cd /var/www/html
    • vim index.html
      • Welcome to simple web server
    • to test install elinks
      • yum -y install elinks
      • elinks http://localhost
  • Creating a Web Server using  different DocumentRoot.
    • yum install -y httpd httpd-manual
    • systemctl enable httpd
    • systemctl start httpd
    • firewall-cmd --permanent --add-service=http --add-service=https
    • firewall-cmd --reload
    • mkdir /web
    • vim /web/index.html
      • Welcome to simple web server
    • vim /etc/httpd/conf/httpd.conf
      • Change value of DocumentRoot.
        • DocumentRoot "/web"
      • Change value of Directory.
        • <Directory "/web">
    • Change the selinux security label of DocumentRoot /web.
      • semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?"
      • restorecon -R -v /web

[root@server1 ~]# ls -Zd /web
drwxrwxr-x+ root root unconfined_u:object_r:httpd_sys_content_t:s0 /web

    • restart httpd
      • systemctl restart httpd
    • test
      • elinks http://localhost

No comments:

Post a Comment