Apache Not Accepting a Path in My Home Folder
I have trying to set up an Apache site to use a folder in my home folder without any success. I exactly followed the steps in this page:
https://help.ubuntu.com/community/ApacheMySQLPHP
yet I did not succeed; I keep getting error 403, which says that the server doesn't have permission to access the requested page. I searched forums and many suggested changing the permission of the folder. I went straight away and set the permission to 777, but that didn't solve the problem.
I made another search and somebody gave me a clue, which is that it could be because my home folder is encrypted. I believe this could be the problem, but:
What is the relation between encryption and Apache? I suppose Apache server is requesting the file from the system, rather than trying to access the file bytes!
Is there anyway to solve this problem? I don't want to move the folder to /var/www because I am using this Apache for testing, so I want whatever change I make to be immediately reflected, rather than having to copy files whi开发者_C百科ch is error prone.
What is the relation between encryption and Apache? I suppose Apache server is requesting the file from the system, rather than trying to access the file bytes!
Yes, but it is likely to do so as a different user than you (I think Apache has its own user on most distros). That user probably can't access your home folder.
The best thing would be to place the htdocs folder outside your encrypted folder, or somehow make the Apache service run as you. That is more of a serverfault.com or askubuntu.com issue then, though.
It sounds as if your server is set up with Security-Enhanced Linux (SELinux) enabled. If so, your Apache is probably configured so it can only access specially marked directories.
To check whether SELinux is active, try on of the following commands:
cat /etc/sysconfig/selinux
Or:
sestatus
Update:
If you don't have SELinux enabled, then it might be a simple permission problem. It is not sufficient to set your directory's permission to 777, the Apache user must also have (execute) permission on each directory leading from root to your home directory. Futhermore, the files you want to access must also have (read) permissions for Apache.
To commands you have to execute are:
chmod o+x /home
chmod o+rx /home/someuser
chmod o+r /home/someuser/*
(assuming that your home directory is /home/someuser).
If you have subdirectories, then you have to repeat it for these as well.
I don't think it's an encryption problem. Then you would rather get garbled data instead of a permission error. If you're using encryption, then you probably have a directory called Private in your home directory. Anyway, Apache can't access the encrypted data. You would need to turn encryption off.
精彩评论