2

I've read up on this subject at so many resources but I'm still struggling to get this right. Background: I'm using an Amazon EC2 instance with a LAMP setup

I have this repo on bitbucket that has several directories: _fixtures, oldfiles, psds, webfiles. I only want to place the webfiles directory above the webroot at /var/www/html/. I've cloned the repo to my home folder and I've tried symlinking with

ln -s /home/myuser/myrepo/webfiles /var/www/html/webfiles

This is resulting in a 403 Forbidden access error. I've tried chmod the webfiles folder to be owned by the apache group (so it would have read permission), but this doesn't help.

I also have

<VirtualHost *:80>
     <Directory "/var/www/html">
         allow from all
         Options -Indexes FollowSymlinks
         AllowOverride All
     </Directory>

in my httpd.conf to enable the symlinks, but still nothing. Any help on how I could accomplish this linking would be appreciated.

EDIT

Based on this SO thread+answer I will be taking the strategy of just checking out the webfiles directory.

EDIT 2

It's been a while, but just thought I'd drop a note here saying that another solution I could have tried for this would be to clone the repo to somewhere like /var/www/repos/myrepo and then symlink the webfiles directory from there. It would be simpler since the permissions are more likely already in place for /var/www.

  • 1
    check that your /home/myuser/myrepo/webfiles can be accessed by apache/httpd user. Usually, /home/myuser directory has a permission 700. – kofemann Jan 31 '14 at 9:27
  • @tigran I have read permission for all users and write for the group also. – juuga Jan 31 '14 at 9:31
3

If you Amazon Linux has SElinux enabled you may be having trouble with that and need to allow httpd to read user's home directories

 setsebool httpd_enable_homedirs 1
2

You also need a directory statement for /home/myuser/myrepo/webfiles:

<Directory "/home/myuser/myrepo/webfiles">
     allow from all
     Options -Indexes
     AllowOverride None
</Directory>
  • I added the Directory statement for the symlinked folder but I still get this in my error_log: Symbolic link not allowed or link target not accessible: /var/www/html/webfiles – juuga Jan 31 '14 at 9:07
2

I'm doing something similar - with a laravel install in the home directory of the ec2-user so that when I want to update the site, I can do so without root permissions.

The crucial bit, or the part that got me stuck was that you need to allow directory execute access to the home directory of the ec2-user.

Not doing this caused me quite some time wondering why it wasn't working.

To avoid having to open the permissions up completely, I added the 'apache' user to the 'ec2-user' group.

As root:

usermod -aG ec2-user apache

Here is the crucial bit ...

chmod g+x /home/ec2-user

You don't need 'read' access on the directroy, just execute so you can open the directory to get to the one(s) you want under it. The directories under the home directory should already have 'r' and 'x' for group access. You might need to add write access to any cache or log directories.

After that you can setup things as you wish - in my case it is something like:

cd /var/www
ln -s /home/ec2-user/my_laravel_repo/public my_laravel

Then I adjust my DocumentRoot to /var/www/my_laravel along with allowing symlinks and overrides etc

1

Please try below syntax

<Directory "/var/www/html">
 Options -Indexes FollowSymLinks MultiViews
 AllowOverride All
 Allow from all
</Directory>

<Directory "/home/myuser/myrepo/webfiles">
 Options -Indexes FollowSymLinks MultiViews
 AllowOverride All
 Allow from all
</Directory>

Please check in default httpd.conf or apache.conf if "AllowOverride" is set to "None" for directory/var/www/html/

Also if symlinks not working you can mount one folder to another folder as below

mkdir /var/www/html/webfiles
mount -o bind /home/myuser/myrepo/webfiles /var/www/html/webfiles
0

As tigran commented before you must make sure that apache can actually read the destination directory.

In this case, /home/myuser/myrepo/webfiles, besides webfiles being acessible apache needs execute rights on the all path (/home ; /home/myuser ; /home/myuser/myrepo).

It would probably be better if you used a directory outside your home, but if you want you can open up permissions.

  • Ah, well I guess the problem is then the directories leading up to the repo, since they don't have the correct permissions. – juuga Jan 31 '14 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.