The default root directory is at /var/www/html. In my case, I want to change it to /home/user1/web.
Step 1: Edit apache configuration file (as root)
# gedit /etc/httpd/conf/httpd.conf
Find these two lines
DocumentRoot "/var/www/html"
...
...
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/var/www/html">
Then, change to
DocumentRoot "/home/user1/web"
...
...
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/home/user1/web">
Save and close this file.
Step 2: Changing permission
# chmod 711 /home/user1
# chmod -R 755 /home/user1/web
This step is necessary since in fedora, httpd process will be executed by user 'apache', thus permission need to be change.
By default, the permission for each user directory is drwx------, so that other users can't access to files in this directory and its subdirectories.
# setsebool -P httpd_enable_homedirs 1
# chcon -R -t httpd_sys_content_t /home/user1/web
Note: httpd by default is not allowed to access users home directories, see this page
Step 3: Restart apache
# service httpd restart
Hope this will help a little bit :)
References:
wow..terernyer
ReplyDeleteThanks... just what I was looking for...
ReplyDeleteYes! thank you.. exactly what I needed. Just made the switch from Debian and almost went back over this issue.
ReplyDeleteexcept.. it still won't let the webserver write to the folder, and any new files/folders I create have the default se permissions. still unusable. *sigh*
ReplyDeleteThank you very much!
ReplyDeleteThanx ! you rock
ReplyDeleteChange is successful. Apache restarts OK, but the following message is printed in the browser:
ReplyDeleteYou don't have permission to access / on this server.
thanks man, it helped me a lot, although it definitively put out a fight
ReplyDeleteI have problem with setsebool -P httpd_enable_homedirs 1 - it start working on something, but never end. Can someone help me?
ReplyDeleteIt takes long but it works
DeleteWorks for me! :D
ReplyDeleteWorked for me too, in new Fedora 20!
ReplyDeleteI did everything but in httpd.conf
The solution came from setsebool & chcon
I am very gratefull!
Very nice! functionou perfectly! would you allow me to publish on my blog here in Brazil?
ReplyDelete