10月CMS作为子目录安装-/未找到后端,Nginx配置问题?
我有一个使用Laravel4.2的现有网站。我正试图在/blog子目录中安装十月CMS(仅用作博客和帮助部分),但nginx安装程序中的某些内容不正确。我完成了10月份的CMS安装向导,并且能够正确显示/blog/index.php页面。问题是当我尝试登录到后端(/blog/backend)时,我得到一个404页面。以下是我的虚拟主机nginx对此站点的配置:10月CMS作为子目录安装-/未找到后端,Nginx配置问题?,nginx,octobercms,Nginx,Octobercms,我有一个使用Laravel4.2的现有网站。我正试图在/blog子目录中安装十月CMS(仅用作博客和帮助部分),但nginx安装程序中的某些内容不正确。我完成了10月份的CMS安装向导,并且能够正确显示/blog/index.php页面。问题是当我尝试登录到后端(/blog/backend)时,我得到一个404页面。以下是我的虚拟主机nginx对此站点的配置: server { listen 80; server_name my_site; root /home/vagr
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;
}
}
如果添加以下指令,我可以显示/blog/backend页面(尽管未使用css/js设置样式):
rewrite ^/blog /blog/index.php break;
请注意,使用上面的rewrite指令,/blog/index.php页面的资产返回结果为404,因此/blog/index.php页面也将取消样式设置。但是,如果我删除上述指令,链接将再次工作
我是nginx的新手,在10月份建立了CMS,但我无法理解这一点。谢谢大家! 我不使用10月份的CMS,但查看您的配置,我认为不需要所有这些重写,您只需要正确设置try_文件部分 看起来您还需要考虑根文件夹到底是什么。我在这里假设它是
/home/vagrant/my_site/public/blog
考虑到这一点,这应该适用于您:
Server {
....
# Generally better to define root at server level
root /home/vagrant/my_site/public/blog;
location / {
try_files $uri $uri/ /index.php;
}
# Use this instead if root folder is /home/vagrant/my_site/public
#location /blog {
# try_files $uri $uri/ /blog/index.php;
#}
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;
}
}
根文件夹是正确的,如最初所述
/home/vagrant/my_site/public
我正在尝试将十月CMS添加到现有的laravel应用程序中,十月CMS将只处理应用程序的博客和帮助部分。重写如OctoberCMS站点上的conguration文档所述:建议的配置似乎有点可疑,因为它没有任何关于php位置的说明,重写似乎只是将所有内容发送到index.php,而index.php通常会复制try_文件的功能。不太确定是谁写的真的理解Nginx。试试我的建议配置,看看。我发布了所有根配置的选项。如果需要,还可以添加重写。即使事实证明它们是不需要的,它们也不会造成真正的伤害。好吧-看起来你的位置博客{…}
修复完成了(同时将/blog
从重写
指令中删除)(这是我的nginx在那里工作时的无能。现在修复-谢谢!(他们允许我的话,我们会尽快颁发赏金)。