简体   繁体   中英

Apache Server error 500 when DocumentRoot is a symlink

I have setup my fedora system, the default was that / size is 50gb while remaining drives where put on /home .

since I don't want to waste my precious 50gb for my web project I setup my apache web server as follow

since the default of apache is /var/www/html

i remove html dir and replace it with a symbolic link that points to my /home/user/www/html

note /home , /home/user , /home/user/www , /home/user/www/html have x permission for apache

my conf is like this

DocumentRoot "/var/www/html"

<Directory "/var/www">
    Options Indexes FollowSymLinks
    AllowOverride None 
    Require all granted
</Directory>

<Directory "/var/www/html"> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Require all granted
</Directory>

I already restart my httpd service and it was fine. The problem is when I try to access my index.php I get a server error. when it's index.html I get a 403.

my selinux is currently enabled and no plans on disabling it. I would Like to learn how to use it rather. so it this an selinux problem?

As I run ls -Zla on /home/user/www/html , this is the result

-rw-r--r--. 1 root root unconfined_u:object_r:user_home_t:s0   27 Dec 21 22:37 index.php

It seems that SELinux is preventing this

when accessing an html

[Mon Dec 21 23:35:33.749916 2015] [core:error] [pid 20579] (13)Permission denied: [client 127.0.0.1:45632] AH00132: file permissions deny server access: /var/www/html/index.html

when a php

    [Mon Dec 21 23:39:36.801672 2015] [:error] [pid 20585] [client 127.0.0.1:45816] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Mon Dec 21 23:39:36.801730 2015] [:error] [pid 20585] [client 127.0.0.1:45816] PHP Fatal error:  Unknown: Failed opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0

~

to someone that may get this problem. change the selinux type of the folder using this command.

sudo chcon -R -t httpd_sys_content_t /home/user/www

more info

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM