blog.mydomain.com/phpinfo.php (which simply shows phpinfo()
) works fine.
What am I missing?
Directory root of my blog is /usr/share/nginx/html/blog/
I'm using Centos.
/etc/nginx/nginx.conf is as default.
/etc/nginx/conf.d/virtual.conf:
server {
server_name blog.fuzzybee7.com www.blog.fuzzybee7.com;
include /etc/nginx/conf.d/global/php.conf;
root /usr/share/nginx/html/blog;
}
/etc/nginx/conf.d/global/php.conf:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
in /etc/nginx/conf.d/global/php.conf try this
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
@Faishal's answer should have been fine, but he did a small mistake, he used $args
instead of $uri
or $request_uri
, so try doing this;
location / {
try_files $uri $uri/ /index.php?$request_uri;
}
This should pass the uri correctly to the index.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.