Alias does not work with php

Hello,

I’ve set up nginx 1.0.10 with php5-fpm. I’ve tested the setup and I can
confirm that php works.
The problem is when I set up an alias under “location /” nginx can’t
load the php pages. Only static html files work.

Any ideas?

Thank you.

Posted at Nginx Forum:

Hello!

On Sat, Dec 17, 2011 at 04:43:05AM -0500, tapir wrote:

Hello,

I’ve set up nginx 1.0.10 with php5-fpm. I’ve tested the setup and I can
confirm that php works.
The problem is when I set up an alias under “location /” nginx can’t
load the php pages. Only static html files work.

Any ideas?

Most likely, you’ve forgot to add corresponding alias in your .php
location.

Maxim D.

yes I didn’t change anything there. why and how should I change it?

thank you

Posted at Nginx Forum:

On Sat, Dec 17, 2011 at 9:58 PM, tapir [email protected] wrote:

I’ve added “fastcgi_param SCRIPT_FILENAME
$document_root/wordpress$fastcgi_script_name;”
and now it works.

As you might predict “$document_root/wordpress” is the alias for
“location /”.
So what’s the correct way of doing this? I mean I have other aliases as
well and I would like php to work with those also.

combining alias and fastcgi (php) is the fastest way to get headache.
Go with symlink instead.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

I’ve added “fastcgi_param SCRIPT_FILENAME
$document_root/wordpress$fastcgi_script_name;”
and now it works.

As you might predict “$document_root/wordpress” is the alias for
“location /”.
So what’s the correct way of doing this? I mean I have other aliases as
well and I would like php to work with those also.

Thanks

Posted at Nginx Forum:

On Sat, Dec 17, 2011 at 11:05 PM, tapir [email protected] wrote:

ok, what exactly do you mean by symlink? is that a nginx feature or you
just mean plain old linux symbolic links?

plain old symlink.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

ok, what exactly do you mean by symlink? is that a nginx feature or you
just mean plain old linux symbolic links?

thank you

Posted at Nginx Forum:

On Sat, Dec 17, 2011 at 11:36 PM, Edho A. [email protected] wrote:

On Sat, Dec 17, 2011 at 11:05 PM, tapir [email protected] wrote:

ok, what exactly do you mean by symlink? is that a nginx feature or you
just mean plain old linux symbolic links?

plain old symlink.

also, alias in “location /” doesn’t make sense.


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Saturday 17 December 2011 18:58:59 tapir wrote:

I’ve added “fastcgi_param SCRIPT_FILENAME
$document_root/wordpress$fastcgi_script_name;”
and now it works.

As you might predict “$document_root/wordpress” is the alias for
“location /”.
So what’s the correct way of doing this? I mean I have other aliases as
well and I would like php to work with those also.

Why don’t you just use the “root” directive?

root /patch/to/wordpress;

location / {

}

and respectively:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

wbr, Valentin V. Bartenev

ok I thought it didn’t. what I’m trying to do is to install the
wordpress on it’s own directory under the document root but I want it to
be accessible directly from mydomain.com. Wordpress allows you to do it
actually but I need a web server level solution because if I change it
in wordpress, it messes up some links (thousands) generated by poorly
designed plugins.

Posted at Nginx Forum:

can I then use other scripts from /path/to/otherscript

my document root looks like this:

phpbb/
wordpress/
phpmyadmin/
piwik/

but I only want wordpress to be accessible from the mydomain.com. Others
should be accessible from mydomain.com/phpbb and so on…

maybe I should have asked this from the start :slight_smile: how can I achieve this?

Posted at Nginx Forum:

thanks. that works.

but somehow I have to define all the fastcgi params everytime. for
example can’t I just define fatscgi_pass and fastcgi_index once instead
of everytime for a new location.

Posted at Nginx Forum:

On Sun, Dec 18, 2011 at 12:21 AM, tapir [email protected] wrote:

should be accessible from mydomain.com/phpbb and so on…

maybe I should have asked this from the start :slight_smile: how can I achieve this?

location /phpbb {
root /some/where; #actual phpbb installation in /some/where/phpbb
location ~ .php$ {
fastcgi_pass …;

}
}
location /wordpress {
root /some/where_else; #actual wordpress installation in
/some/where_else/wordpress
location ~ .php$ {

}
}

location / {
root /some/where_else/wordpress;
location ~ .php$ {

}
}


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Sun, Dec 18, 2011 at 10:17 PM, tapir [email protected] wrote:

I’m sorry it does not work. I didn’t test it properly before.

here is my settings: server { root /usr/share/nginx/www; index index.php index.html index.htm; - Pastebin.com

when I go to mydomain.com it redirects to wordpress so it works but if I
go to mydomain.com/pma it says “404 not found”

this line

location /pma {
root /usr/share/nginx/www/phpmyadmin;

will cause nginx to search for relevant files in
/usr/share/nginx/www/phpmyadmin/pma. For example

http://host.com/pma/index.php
root: /usr/share/nginx/www/phpmyadmin
$uri: /pma/index.php
therefore it checks: /usr/share/nginx/www/phpmyadmin/pma/index.php


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

I’m sorry it does not work. I didn’t test it properly before.

here is my settings: server { root /usr/share/nginx/www; index index.php index.html index.htm; - Pastebin.com

when I go to mydomain.com it redirects to wordpress so it works but if I
go to mydomain.com/pma it says “404 not found”

Posted at Nginx Forum:

okay now I get it → server { root /usr/share/nginx/www; index index.php index.html index.htm; - Pastebin.com

one last question: how can I get rid off the same fastcgi lines. can’t I
just define those globally? do I have to type the same thing for every
location?

Posted at Nginx Forum:

On 18 Dez 2011 16h35 WET, [email protected] wrote:

okay now I get it → server { root /usr/share/nginx/www; index index.php index.html index.htm; - Pastebin.com

one last question: how can I get rid off the same fastcgi
lines. can’t I just define those globally? do I have to type the
same thing for every location?

http://wiki.nginx.org/CoreModule#include

— appa