Flask和WordPress在Nginx中位于同一域 [英] Flask and WordPress on the same domain in nginx

查看:208
本文介绍了Flask和WordPress在Nginx中位于同一域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将Wordpress博客添加到我的Flask网站. 我试图通过这种方式将博客部署到可工作的nginx配置:

I need to add Wordpress blog to my Flask site. I tried to deploy blog to working nginx config in this way:

server {
listen 80;
server_name localhost;

location / {
    uwsgi_pass unix:/tmp/site.sock;
    include uwsgi_params;
}

location = /blog/ {
   alias /var/www/blog/;
   index index.php;
   try_files $uri $uri/ /blog/index.php?q=$uri?$args;
}


location ~ /blog/.+\.php$ {
   root /var/www/;
   include /etc/nginx/fastcgi_params;
   fastcgi_pass 127.0.0.1:9000;
}

# path for static files
location  /static/ {
    alias /var/www/site/static/;
    autoindex on;
    expires max;
}
}

但是wordpress只显示404页(不是标准字体,此页面专为Blog设计,并包含在wordpress页面中) 否则,我检查了与数据库的连接已创建,并且wp_config有效. 可能会错过WP或nginx配置中的某些设置吗?

But wordpress shows me only 404 page(not standart, this page was made expessially for blog and included to wordpress page) Otherwise, I checked, that connection to database created and wp_config works. May be I missed some setting in WP or nginx config?

推荐答案

您确实没有解释确切的位置服务器是什么,但是如果问题出在与aliastry_files有关,例如@Seberius,请尝试 尝试更改

You really didn't explain what locations server what exactly, but if the problem is about alias with try_files like @Seberius mentioned, then try try changing

alias /var/www/blog/;

root /var/www/;

然后重新加载nginx

Then reload nginx

这篇关于Flask和WordPress在Nginx中位于同一域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆