Ask Your Question
0

Apache does not allow symbolic links in public_html

asked 2015-11-23 04:03:42 -0500

Giordano gravatar image

I enabled the userdir mode in Apache and I am serving a php application from a subdirectory in ~/public_html/myapp. I wish to keep the "myapp" directory in my global "git development" directory and just link it in ~/public_html/. However I'm encountering this problem:

  • If I copy the myapp directory in ~/public_html/, Apache serves it correctly
  • If I symlink it, it shows error 403

Permissions shouldn't be a problem, in fact when I copy the directory apache serves it correctly. What should I change in the configuration to make symlinks to work?

This is my /etc/httpd/conf.d/userdir.conf (gio is my user name)

<IfModule mod_userdir.c>
    #
    # UserDir is disabled by default since it can confirm the presence
    # of a username on the system (depending on home directory
    # permissions).
    #
#    UserDir disabled
    UserDir enabled gio

    #
    # To enable requests to /~user/ to serve the user's public_html
    # directory, remove the "UserDir disabled" line above, and uncomment
    # the following line instead:
    # 
    #UserDir public_html
    UserDir public_html
</IfModule>

#
# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
<Directory "/home/*/public_html">
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>

Thanks in advance

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-11-23 07:17:12 -0500

Giordano gravatar image

Ok I found the problem. I focused so much on the directory's permissions that I forgot to double check the permissions of a parent directory in the path.

edit flag offensive delete link more

Comments

Hello, I have the same configuration and the same problem. Say that ~/public_html/project links to /home/me/code/project/trunk/project ? I have checked that /home/me is 711. Moreover /home/me/code/,/home/me/code/trunk and /home/me/code/trunk/project are 755. Is that supposed to work ? I have changed the selinux bool.

mdubois gravatar imagemdubois ( 2018-01-17 07:50:34 -0500 )edit

I think that selinux blocks the links. If I set it to 'permissive', everything works. Another option is to change the label of the files under /home/me/code/project/trunk/project to httpd_user_content_t (check the chcon & semanage commands).

mdubois gravatar imagemdubois ( 2018-01-17 15:20:43 -0500 )edit
0

answered 2015-11-23 04:41:31 -0500

geforce gravatar image

The default selinux settings will block

http://www.if-not-true-then-false.com...

edit flag offensive delete link more

Comments

Uhmm... I tried setsebool -P httpd_enable_homedirs true but this didn't fix the problem unfortunately.

Giordano gravatar imageGiordano ( 2015-11-23 07:01:40 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-23 04:03:42 -0500

Seen: 932 times

Last updated: Nov 23 '15