在Nginx中使用Django和PHP
我在Vhost中使用Django,在另一个中使用PHP,现在我想用两个东西制作一个文件,一部分用于Django,另一部分用于PHP 我读过这个问题,但它对我没有帮助。 这个也没用 这是我在PHP配置中的一部分:在Nginx中使用Django和PHP,php,django,nginx,Php,Django,Nginx,我在Vhost中使用Django,在另一个中使用PHP,现在我想用两个东西制作一个文件,一部分用于Django,另一部分用于PHP 我读过这个问题,但它对我没有帮助。 这个也没用 这是我在PHP配置中的一部分: root /var/www/agendav/web/public; # Add index.php to the list if you are using PHP index index.php; location ~ ^(.+\.php)(.*)$ { try_file
root /var/www/agendav/web/public;
# Add index.php to the list if you are using PHP
index index.php;
location ~ ^(.+\.php)(.*)$ {
try_files $fastcgi_script_name =404;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
这是完整的Django部分:
upstream django {
server unix:///tmp/mysite.sock;
}
root /path/to/project/folder;
charset utf-8;
index index.html index.htm index.php;
if ($allowed_country = no) {
return 444;
}
# max upload size
client_max_body_size 75M;
# Django media
location /media {
alias /path/to/mysite/media/;
}
location /static {
alias /path/to/mysite/static/;
}
location ~ /cal/.*\.php$ {
root /var/www/agendav/web/public;
index index.php;
try_files $uri $uri/ /index.php/login =404;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass pass;
include /path/to/uwsgi_params;
}
location /.well-known/acme-challenge/ {
allow all;
}
我正试图将其添加到另一个conf文件中(该文件已经在运行)
就我所阅读的内容而言,这应该可以做到,但我得到的只是一个404错误,或者一个空白页面,nginx日志甚至agendav(PHP中的应用程序)日志中都没有读数
我做错了什么?django配置部分在哪里?好了@sideffect我添加了(几乎)完整的配置文件,只遗漏了端口、ssl之类的部分。你得到的是django uwsgi日志吗?你检查了??好吧,这是我的错,我没有正确检查所有东西。。。有了这个配置,我在uwsgi日志中获得了日志,这让我觉得位置不好,我对它进行了更改,在做了一些更改后,我得到了一个位置块,当我的URL中有something.PHP时,它会进入我的PHP应用程序,接下来是尝试只关注URL中有/cal/的内容和一个.PHP文件。谢谢你的回复!我也有同样的问题。你能发布你的最终配置吗?
location ~ /cal/.*\.php$ {
root /var/www/agendav/web/public;
index index.php;
try_files $uri $uri/ /index.php/login =404;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}