Ask Your Question
0

Non-default directory as DocumentRoot for Apache in Fedora

asked 2019-02-03 16:24:00 -0600

powergame gravatar image

updated 2019-02-03 16:25:44 -0600

I am planning to set up a development site on my local computer. I am trying to use /home/johndoe/src/mysite as DocumentRoot. I think I have done all the required steps to allow httpd load the site from the non-default location. But, when I browse 'http://mysite.local', I get a 403 error saying "You don't have permission to access / on this server". Here's the things I have already done with no success to fix the said problem.

  • Set /etc/hostname to mysite.local
  • Set ServerName in httpd.conf to mysite.local
  • Set DocumentRoot in httpd.conf to /home/jondoe/src/mysite
  • change <directory> in httpd.conf to /home/johndoe/src/mysite
  • Restarted httpd
  • Added firewall rules for port 80 udp/tcp
  • Setting required selinux flags and then restarting the system:
    > semanage fcontext -a -e /var/www /home/johndoe/src/mysite
    > restorecon -R /home/johndoe/src/mysite

And then according to this:

chcon -R --reference=/var/www/html/ /home/johndoe/src/mysite
chcon -R -t httpd_sys_content_t /home/johndoe/src/mysite
semanage fcontext -a -t httpd_sys_content_t "/home/johndoe/src/mysite(/.*)?" 
setsebool -P httpd_enable_homedirs true 
chmod 755 /home/johndoe/src/mysite # important !!
service httpd restart 

And then restarted the system, but I still got the error.

edit retag flag offensive close merge delete

Comments

Panther gravatar imagePanther ( 2019-02-03 17:14:07 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-02-03 17:10:33 -0600

aeperezt gravatar image

You did all the SELinux part but you did not change apache configuration, you need to change the file /etc/httpd/conf.d/userdir.conf comment out the UserDir disable and remove the "#" con the line UserDir public_html and change it to src/mysite

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-03 16:24:00 -0600

Seen: 22 times

Last updated: Feb 03