我在流浪汉VM上有一个nginx配置,该网站运行的是Joomla。这没关系,运行正常。问题在于实时站点上的nginx,运行与VM上相同的版本 - 1.8.0
。
当您访问VM上的站点时,所有URL重写都有效,但是当您在实际站点上访问时,重写都不起作用。我可以访问主页,因此我们知道nginx有效,我可以使用example.com/index.php?page=page1
访问网站页面,但如果我尝试example.com/page1
,我会404 Not Found
example.com/page1
可以正常使用server {
listen 80;
listen [::]:80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
server {
client_max_body_size 100M;
autoindex off;
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com;
server_name_in_redirect off;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
access_log /var/log/nginx/example.com.access_log;
error_log /var/log/nginx/example.com.error_log info;
root /vagrant/site;
index index.html index.htm index.php default.html default.htm;
# Support Clean (aka Search Engine Friendly) URLs
location / {
try_files $uri $uri/ /index.php?$args;
}
# deny running scripts inside writable directories
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}
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;
include /etc/nginx/fastcgi.conf;
fastcgi_read_timeout 300;
}
# caching of files
location ~* \.(ico|pdf|flv)$ {
expires 1y;
}
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
expires 14d;
}
}
VM。
这是配置:
PHP
实时服务器上的配置与location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
include /etc/nginx/fastcgi.conf;
}
部分相同:
QuerySet.annotate
错误日志只是说明
015/08/25 18:58:21 [错误] 35356#35356:* 6432 open() " /家/网站/第1页"失败了(2:没有这样的文件或 目录),客户端:000.000.000.000,服务器:myflashstore.net,请求: " GET / page1 HTTP / 1.1",主持人:" www.example.com",推荐人: " https://www.example.com/"