1
我想在ubuntu上的nginx服务器上运行一个php应用程序。我确实把我所有的文件放在var/www/mydomain.com.html中,它完美地呈现了我的index.php。但是,即使这些文件存在于同一目录中,也会显示404 Not Found for every page。Nginx显示404没有找到每个页面,但主页
这是我的服务器块配置。
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80; ## listen for ipv6
root /var/www/app.limoposter.com/html;
index index.php index.html index.htm;
server_name app.limoposter.com www.app.limoposter.com;
location/{
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我应该把这个rewrited htaccess放在服务器块,nginx.conf还是其他地方? – Mohan
这应该工作,但要更有组织,你可以创建一个额外的文件 – Sebastian
感谢您的建议:) – Mohan