3

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) 
Jenny D
  • 27,780
  • 21
  • 75
  • 114
monxas
  • 81
  • 1
  • 7
  • Please post the messages in your apache log. –  Jun 16 '15 at 09:12
  • 1
    try to replace with – Maxiko Jun 16 '15 at 09:44
  • @Maxiko tried that, with a2dissite, reload apache, a2ensite ande reload apache again, no changes – monxas Jun 16 '15 at 09:56
  • Have you checked that your apache user has read permissions on your `/var/www/internet/movil/` directory and the files inside it? – Gagravarr Jun 17 '15 at 14:23
  • @Gagravarr yeah, www-data is the owner of the folder and files inside, with 755 permissions – monxas Jun 18 '15 at 07:59
  • Only the index.html gives a 403. The index.php and favicon 302. Are there some rewrites happening perhaps? Is there a htaccess file there? – JayMcTee Jun 18 '15 at 14:00
  • @JayMcTee no htaccess file, and no redirections that I'm aware of. neither index.php nor favicon exist yet. – monxas Jun 18 '15 at 15:55
  • 2
    Something is wrong causing apache to not use the correct VirtualHost for this one domain. You can check the VirtualHost configuration by running `httpd -S`. (One thing that can cause this is if you've edited the file on a Windows machine - it has different line breaks which create invisible extra characters at the end of the line. You can see those by running `cat -v /path/to/the/virtualhost.conf`.) – Jenny D Jun 21 '15 at 18:29
  • Check if other configurations are active in `/etc/apache2/sites-enabled` that might have influence or cover your vhost configuration. – Helmut Wollmersdorfer Jun 17 '15 at 13:28
  • yeah there are several subdomains already at work (set up by other). I basically copied one of the working files and edited the paths. I can't find any conflicts, but I'm no expert. – monxas Jun 18 '15 at 08:04
  • Run `httpd -S` it will show if the vhost config you created is loaded fine. As you saying you copied the working file, check the vhost config file permission. It always good to make apache user (or the user under which apache is running) owner of docroot (/var/www/internet/movil). – chetangb Jun 18 '15 at 20:57
  • in that other_vhost logs where you found 403(access.log), check the error log of that vhost it might have some clues or the default error.log – chetangb Jun 18 '15 at 20:59
  • that's the first thing I looked for. Oddly enough, there is no other_vhosts error log... – monxas Jun 19 '15 at 08:42
  • httpd -s is not working for me, I'm looking into it. – monxas Jun 19 '15 at 08:43
  • Also if you are missing `index.html` you will be getting 403. In your document root `/var/www/internet/movi` can you check if you have a `index.html` in place , if not try pasting this - ` This is a test page. ` – chetangb Jun 19 '15 at 10:27
  • yeah, got a index.html already... – monxas Jun 19 '15 at 16:25
  • Is by any chance the hostname (FQDN) of your server m.mores.es? I've run into problems before with Apache not working correctly with vhosts serving the same FQDN as the host it's running on with Debian/Ubuntu. – RSchulze Jun 24 '15 at 03:29

2 Answers2

4

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

Jake
  • 248
  • 2
  • 7
0

If you happen to have SELinux enabled, that could be your culprit.

sudo vim /var/log/audit/audit.log

or sudo tail -f /var/log/audit/audit.log

and

sudo ls -Z /var/www/internet/movil/

With semanage fcontext you can then rectify this.

JayMcTee
  • 3,923
  • 1
  • 13
  • 22