CentOS, Apache2, Change DocumentRoot HTTPD

Hi, long time not write something technical.

This week, after install httpd packet for webserver in CentOS, then open port 80 in firewall. I want to move DocumentRoot to my home folder (/home/user/repo). The default DocumentRoot is /var/www/html folder. But I get 403 error. There how to solve this problem:

  1. Set DocumentRoot to path you want, by editing httpd.conf.
    $ sudo vim /etc/httpd/conf/httpd.conf
  2. Set permission for /home/user folder.
    $ chmod 0+x /home/user
  3. Set SELinux for new DocumentRoot
    $ sudo getenforce
    $ sudo setenforce 0
    $ sudo chcon -Rv –type=httpd_t /home/user/repo
    $ sudo setenforce 1
  4. Make simple index.html file in the new DocumentRoot, restart httpd and test access from browser.
    $ sudo service httpd restart
  5. Finish

Yay. That all, please remind me if you find anythink wrong. Thanks