You are not logged in.

#1 2009-08-11 05:24:13

ztrange
Member
From: Mexico
Registered: 2009-06-16
Posts: 28

[SOLVED] Using symlink in a virtual host apache

I want to configure an apache virtual host for one project I'm working on.
My project is in ~/httpd/www/sglp2
In my hosts.conf i have set up 127.0.0.1 www.sglp2.tst
In my /srv/http I have a folder called sglp2 that is a copy of the one in my home folder.
Everything works.

Now, I want to change the sglp2 folder in /srv/http for a symlink:
cd /srv/http
rm -rf sglp2
ln -s sglp2 ~/httpd/www/sglp2
sudo /etc/rc.d/httpd restart
Now apache says: Access forbidden.
I have set the symlink permissions to 777 and also 777 for ~/httpd/www/sglp2  and all its contents.

I have tested the alias parameter in httpd.conf and also added ~/httpd/www/sglp2 as <Directory> but is not working. Can anyone give me some advice as to what directive I have to use to do this configuration?

Thanks

Last edited by ztrange (2009-08-17 03:45:59)


Using Arch Linux + KDE 4.3 rc3 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 2048 RAM.
Sorry for my bad english...

Offline

#2 2009-08-11 05:43:03

alterecco
Member
Registered: 2009-07-13
Posts: 152

Re: [SOLVED] Using symlink in a virtual host apache

You need to have the Option FollowSymlinks defined and you need a Directory set up for your destination.

Have a look here for further details.

.]

Offline

#3 2009-08-11 14:30:09

ztrange
Member
From: Mexico
Registered: 2009-06-16
Posts: 28

Re: [SOLVED] Using symlink in a virtual host apache

Thank you very much, alterecco. I'll try that


Using Arch Linux + KDE 4.3 rc3 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 2048 RAM.
Sorry for my bad english...

Offline

#4 2009-08-13 02:06:16

ztrange
Member
From: Mexico
Registered: 2009-06-16
Posts: 28

Re: [SOLVED] Using symlink in a virtual host apache

Well, I haven't had time to check this issue (since I got a job and I'm still at school...) but today I tried the following:

#These are the same, never changed them during tests
DocumentRoot "/srv/http"

<Directory "/srv/http">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

#Added this one changing several times from /home/mario/httpd/www/sglp2 to /home/mario/httpd/www
<Directory "/home/mario/httpd/www/sglp2">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

As you can see, I have FollowSymLinks in both my "Directories".

In the httpd-vhostos.conf I got the following:
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/srv/http/sglp2"
    ServerName www.sglp2.tst
    ServerAlias www.sglp.tst
    ErrorLog "/var/log/httpd/sglp2"
    CustomLog "/var/log/httpd/sglp2" common
</VirtualHost>

For that one, I also tested {DocumentRoot "/home/mario/httpd/www/sglp2"} to see if the problem was for me to be using symliks but it failed too.

I read about userdir directive in apache conf but I think that is not what I want. I only need my document root to be inside my home directory.

I also commented out the Directory / :
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

To see the difference in whatever the log were reporting:
Before commenting, log report was:
[Wed Aug 12 20:47:33 2009] [error] [client 127.0.0.1] (13)Permission denied: access to /favicon.ico denied
127.0.0.1 - - [12/Aug/2009:20:47:33 -0500] "GET /favicon.ico HTTP/1.1" 403 1078

After commenting, log report was:
Wed Aug 12 20:52:23 2009] [crit] [client 127.0.0.1] (13)Permission denied: /home/mario/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
127.0.0.1 - - [12/Aug/2009:20:52:23 -0500] "GET /favicon.ico HTTP/1.1" 403 1078

Is back to be uncommented, but I did it to see if that provided me with a little more info in whatever is happening.

As for the browser it always said:

Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
www.sglp2.tst
Wed Aug 12 20:52:23 2009
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2

Well, any help will be appreciated.

Thanks in advance


Using Arch Linux + KDE 4.3 rc3 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 2048 RAM.
Sorry for my bad english...

Offline

#5 2009-08-13 03:45:02

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] Using symlink in a virtual host apache

You also need to set your home directory +x for apache to be able to descend into the directory.

eg:

chmod o+x /home/username

Last edited by fukawi2 (2009-08-13 03:45:34)

Offline

#6 2009-08-13 16:50:54

timgws
Member
Registered: 2009-02-02
Posts: 11

Re: [SOLVED] Using symlink in a virtual host apache

fukawi2, you are a winner. I was having the exact same problem, and the o+x worked. I must admit, I tried (almost) everything else. ztrange, this should help you out :]

Offline

#7 2009-08-13 22:49:13

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,217
Website

Re: [SOLVED] Using symlink in a virtual host apache

timgws wrote:

fukawi2, you are a winner.

Taco's for me? big_smile

Glad it helped -- I've spent ages before figuring this one out, lots of guides seem to miss it.

Offline

#8 2009-08-14 16:30:21

ztrange
Member
From: Mexico
Registered: 2009-06-16
Posts: 28

Re: [SOLVED] Using symlink in a virtual host apache

fukawi2 wrote:

Glad it helped -- I've spent ages before figuring this one out, lots of guides seem to miss it.

Thank you for your help, I'll try it ASAP but yes, I think that may be the problem. You're right, many guides miss that point.

As for the tacos, I'll invite you some great ones the day you come to México.


Using Arch Linux + KDE 4.3 rc3 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 2048 RAM.
Sorry for my bad english...

Offline

#9 2009-08-17 03:45:21

ztrange
Member
From: Mexico
Registered: 2009-06-16
Posts: 28

Re: [SOLVED] Using symlink in a virtual host apache

I can confirm now that using chmod o+x home/username was the thing needed. Everything is alright now. Thank you all for your help.


Using Arch Linux + KDE 4.3 rc3 Fully updated, Toshiba U305 S5107 Intel Core 2 duo 2048 RAM.
Sorry for my bad english...

Offline

Board footer

Powered by FluxBB