我需要在一个域的根目录build立一个Django站点,然后在一个子目录下(例如/ blog /)安装一个Wordpress。 如何configurationNGinX来做到这一点? “漂亮”的url也必须适用于WordPress。
对于Django,我正在使用已configuration好的Gunicorn。 从NGinX我会打电话给“proxy_pass”来指导。 PHP通过FPM运行。
考虑到上面的限制,我将如何configurationNGinX? 任何帮助,将不胜感激!
谢谢。
更新:我已经尝试了几件事情,目前我有一部分工作。 我已经删除了任何Djangoconfiguration。 然后我在/ blog /子目录中find了WordPress。 在那里,我有test.php,它只是调用phpinfo(),然后test.html,它显示纯净的HTML。 当调用test.php时,页面加载。 但是,当我打电话test.html,或index.php(Wordpress索引页),它给了我一个404。
我的nGinxconfiguration:
server { listen 80; root /path/to/www/root; server_name domain.com; access_log /path/to/logs/access.log; error_log /path/to/logs/error.log; location / { index index.php; } location /blog { alias /path/to/www/blog; try_files $uri =404; index index.php index.html; } location ~ /blog/.+\.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path/to/www/blog$fastcgi_script_name; } location ~ /\.ht { deny all; } }
你build立一个location /blog/并使用所有通常的nginx指令传递给PHP。