我有一个使用laravel 4.2的现有网站。我试图在/ blog子目录中安装October CMS(仅用作博客和帮助部分),但是nginx安装不正确。我做了10月份的CMS安装向导,并且能够让/blog/index.php页面正确显示。问题是当我尝试登录到后端(/ blog/backend)时,我得到一个404页面。下面是我对这个网站的虚拟主机的nginx的配置:10月CMS安装为子目录 - /后端未找到,Nginx配置问题?
server {
listen 80;
server_name my_site;
root /home/vagrant/my_site/public;
index index.html index.htm index.php;
charset utf-8;
location/{
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/my_site.app-error.log error;
rewrite_log on;
error_page 404 /index.php;
sendfile off;
# October CMS rewrites
location blog {
root /home/vagrant/my_site/public/blog;
try_files $uri $uri/ /index.php$is_args$args;
}
rewrite ^/blog/themes/.*/(layouts|pages|partials)/.*.htm /blog/index.php break;
rewrite ^/blog/bootstrap/.* /blog/index.php break;
rewrite ^/blog/config/.* /blog/index.php break;
rewrite ^/blog/vendor/.* /blog/index.php break;
rewrite ^/blog/storage/cms/.* /blog/index.php break;
rewrite ^/blog/storage/logs/.* /blog/index.php break;
rewrite ^/blog/storage/framework/.* /blog/index.php break;
rewrite ^/blog/storage/temp/protected/.* /blog/index.php break;
rewrite ^/blog/storage/app/uploads/protected/.* /blog/index.php break;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.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_intercept_errors on;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 120;
fastcgi_read_timeout 120;
}
location ~ /\.ht {
deny all;
}
}
我能出现在/博客/后端页面(虽然无样式的CSS/JS),如果我添加以下指令:
rewrite ^/blog /blog/index.php break;
请注意,通过上面的rewrite指令,/blog/index.php页面的资源返回的结果是404,因此/blog/index.php页面也是非风格的。但是,如果我删除上述指令,链接将再次运行。
我是nginx的新手,并且设置了10月份的CMS,但无法弄清楚这一点。谢谢!
根文件夹是正确的,因为最初注意到'/家庭/流浪者/ my_site/public'我试图加十月CMS到一个现有的laravel应用程序,其中10月CMS只处理应用程序的博客和帮助部分。重写如OctoberCMS站点上的配置文档中所述:https://octobercms.com/docs/help/installation#nginx-configuration – Jon
建议的配置似乎有点可疑,因为它没有任何关于PHP的位置和重写似乎只是发送一切index.php通常复制try_files将做什么。不太确定谁写的真正理解Nginx。尝试我的建议配置,看看。我发布了你拥有的任何根配置选项。如果需要,您还可以添加重写。即使事实证明他们实际上并不需要,他们也没有真正的伤害。 – Dayo
好吧 - 它看起来像你的位置博客{....}'修复了这个技巧(同时从'rewrite'指令中删除'/ blog'(这是我在那里工作的nginx无能为力,现在修复 - 谢谢! (只要他们允许,我会尽快给予赏金)。 – Jon