Debian – Getting 403 – Forbidden when creating a subdomain

apache-2.2debiandomainsubdomain

I've gone through a number of posts but none has fixed my problem, so I'm asking.

I've never setup domains or subdomains so any simple mistake could be the problem.

System:

  • Debian 6.0.6
  • apache2.2.16

What i've done so far:

  • Created an A record. (looks like it's resolving fine)
  • added a sites available config file that looks like this:

    <VirtualHost *:80>
        ServerAdmin webmaster@mores.es
        ServerName m.mores.es
    
        DocumentRoot /var/www/internet/movil/
    
       <Directory />
            Options Indexes FollowSymLinks Includes ExecCGI
            DirectoryIndex index.php index.html
    
            AllowOverride None
            Order allow,deny
            allow from all
       </Directory>
    
       ErrorLog /var/log/apache2/m.mores.es-error.log
       CustomLog /var/log/apache2/m.mores.es-access.log combined
    
    </VirtualHost>
    
  • i've run the command a2ensite m.mores.es (name of the file created in sites available)

  • restarted apache

Here, I get the forbidden error.

  • Changed folder permissions recursively to 775
  • restarted apache

I get the forbidden error.

Any clue?

EDIT apache log:
This might be the key. this log appears on "other_vhosts_access.log" when on the file I set up another log file. Both access and error files for m.mores.es EXIST but are empty. this is the only log that has something with m.mores.es

m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:02:54 +0200] "GET /index.html HTTP/1.1" 403 237 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:02:54 +0200] "GET /index.html HTTP/1.1" 403 237 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:02:55 +0200] "GET /favicon.ico HTTP/1.1" 302 241 "http://m.mores.es/index.html" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:02:55 +0200] "GET /favicon.ico HTTP/1.1" 302 241 "http://m.mores.es/index.html" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:03:01 +0200] "GET /index.php HTTP/1.1" 302 241 "-" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36"
m.mores.es:80 212.89.22.73 - - [15/Jun/2015:17:03:01 +0200] "GET /index.php HTTP/1.1" 302 241 "-" "Mozilla/5.0 (Windows NT 5.1) 

Best Answer

You have set your DocumentRoot to /var/www/internet/movil/ but you point the directory to /. Change it to say

   <Directory /var/www/internet/movil>

Also mind to remove the trailing slashes in the paths.

The entire vhost would look like this:

<VirtualHost *:80>
    ServerAdmin webmaster@mores.es
    ServerName m.mores.es

    DocumentRoot /var/www/internet/movil

   <Directory /var/www/internet/movil>
        Options Indexes FollowSymLinks Includes ExecCGI
        DirectoryIndex index.php index.html

        AllowOverride None
        Order allow,deny
        allow from all
   </Directory>

   ErrorLog /var/log/apache2/m.mores.es-error.log
   CustomLog /var/log/apache2/m.mores.es-access.log combined

</VirtualHost>

Reload apache and it should work