-1

I am using apache virtualhosts for a couple sites I want to run off my ubuntu 14.04 server. My setup works if sites are under /var/www but if i try to run one under /home/myuser/www/sitename/ i get a 403 permissions error. I checked permissions over an over now. My /home directory permissions are

drwxr-xr-x 5 root root 4096 Mar 7 02:05 .

Here is ls -al from home/myuser/www

    myuser@zeppelin:~/www$ ls -al
    total 24
    drwxrwxr-x  3 myuser www-data 4096 Sep  3 19:39 .
    drwxrwxr-x 18 myuser myuser     4096 Sep  3 19:29 ..
    -rwxr-xr-x  1 myuser www-data 4096 Sep  3 19:39 ._.DS_Store
    -rwxr-xr-x  1 myuser www-data 6148 Sep  3 19:39 .DS_Store
    drwxrwxr-x  2 myuser www-data 4096 Sep  3 20:18 sitename

Here is results of ps auxwww | grep -i apache

root     17188  0.0  0.9 178496 17520 ?        Ss   20:25   0:00 /usr/sbin/apache2 -k start
www-data 17190  0.0  0.1  20488  2396 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17193  0.0  1.3 180792 23560 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17194  0.1  1.4 180740 26432 ?        S    20:25   0:01 /usr/sbin/apache2 -k start
www-data 17195  0.1  1.6 181472 29616 ?        S    20:25   0:01 /usr/sbin/apache2 -k start
www-data 17196  0.0  0.3 178544  5652 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17197  0.0  1.1 179960 21176 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17202  0.0  1.2 180804 23296 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17203  0.0  1.1 179960 21176 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17204  0.0  1.4 182564 25304 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
www-data 17205  0.0  1.2 180804 23284 ?        S    20:25   0:00 /usr/sbin/apache2 -k start
myuser   17307  0.0  0.0   4688   812 pts/0    S+   20:47   0:00 grep --color=auto -i apache

And then here is my vhost file

  #
  #  Example.com (/etc/apache2/sites-available/www.example.com)
  #
  <Directory /home/myuser/www/sitename>
    Order allow, deny
    Allow from all
    Options FollowSymLinks Includes ExecCGI
    AllowOverride All
    DirectoryIndex index.php index.htm index.html
  </Directory>

  <VirtualHost *:80>
        ServerName www.sitename.com
        ServerAlias sitename.com

        # Indexes + Directory Root.
        DirectoryIndex  index.php index.html
        DocumentRoot /home/myuser/www/sitename/


        # Logfiles
         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined

  </VirtualHost>
cbalos
  • 123
  • 1
  • 1
  • 6
  • Do you have apparmor or selinux enabled? If so, disable them and see if the problem goes away. If it does, you just need to edit the apparmor or selinux policies to permit apache to read from this location. – EEAA Sep 04 '14 at 03:49
  • @EEAA apparmor was enabled, so i disabled it and still same issue. – cbalos Sep 04 '14 at 03:57

2 Answers2

0

There was a change from apache 2.2 and 2.4 that changed the way you do it. (And you didn't do it right for 2.2 either...).

You are missing "Require all granted" (or for 2.2 it would be "Order allow,deny" and "Allow from all"):

<Directory /home/myuser/www/sitename>
    Require all granted
    Options FollowSymLinks Includes ExecCGI
    AllowOverride All
    DirectoryIndex index.php index.htm index.html
</Directory>
Peter
  • 2,756
  • 1
  • 20
  • 26
-1

Looks like Permissions are wrong. Apache processes are running as www-data and your dir is myuser.

Either change the User that apache runs as to my user or change owner of the site name files to www-data. You can also sym link the site name dir into the /var/www dir. It's a cleaner method of setting up a web server.

Gmck
  • 1
  • 1
  • 1
    The apache user shouldn't need to be the owner of the dir, only the group and with 755 permissions (and I have 775) as it only needs read and execute if i am not mistaken – cbalos Sep 04 '14 at 04:33
  • I did like you symlink suggestion and it did work, but still Id like to figure out my issue – cbalos Sep 04 '14 at 04:48
  • 1
    I second the use of only g+rx or o+rX instead of setting the user as the owner. The server doesn't need to modify the files, so using the principle of least privilege, it should not be allowed to do so. https://en.wikipedia.org/wiki/Principle_of_least_privilege – Peter Sep 04 '14 at 07:32