location - nginx configuratio : alias and 404 error -


my actual problem wanted make "site.com/blog/index.php" direct "/srvx/www/blog/caller/index.php". althought straightforward direct "/srv/www/blog/index.php" using "root /srv/www/", that's not wanted. discovered "alias", , seem want.

1)first try :

server {     listen 80;     server_name _;      root /srv/www/blog/pages;     index index.php;      location /blog {             alias /srv/www/blog/caller;     } } 

there trying site.com/blog me 404 not found, , nothing pop /var/log/nginx/error.log

1)second try know happens :

if change "alias /srv/www/blog/caller;" bad path, let "alias /srvx/www/blog/caller;" got same behaviour in browser, can see in /var/log/nginx/error.log :

[error] 7229#0: *1 "/srvx/www/blog/caller/index.php" not found (2: no such file or directory), client: 192.168.1.200, server: 192.168.1.221, request: "get /blog/ http/1.1", host: "192.168.1.221"

conclusion : don't know what's hapenning there : seem clear nginx file in first try, sends 404 error browser no reason think of, while when specyfiyng wrong path, tells me right away. :/*


edit

well, found solution. totally works nginx, problem php-fpm lose mind when using alias nginx. need doing sublocation of aliased locations adding :

             location ~ \.php$ {                     fastcgi_pass unix:/var/run/php5-fpm.sock;                     include fastcgi_params;                     fastcgi_param script_filename $request_filename;             } 

now works. fact nginx giving 404 error without in nginx's logs, php-fpm 1 failing serve.

the problem have no instructions on how deal php script. solve issue following:

add following code nginx.conf file within server tags or if have created in conf.d folder add file.

location / {     try_files $uri $uri/ /index.php?q=$request_uri;     } location ~ \.php$ {         fastcgi_pass   127.0.0.1:9000;         fastcgi_index  index.php;         include        fastcgi_params;         fastcgi_param  script_filename $document_root$fastcgi_script_name;     } 

that solve problem in file:

/etc/php-fpm.d/www.conf

ensure listen.owner set listen.owner = nginx

ensure listen.group set listen.group = nginx

restart both services , should work.

if not ensure document root , files directory owned user nginx , group nginx.

if not can using following:

chown -r nginx:nginx documentroot

and keep doing adding /* each time until reach error.

hope works out you!!


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -