I am new to configuring servers and i'm having issues getting php to work with my django app using UWSGI on nginx. Django works great using uwsgi and php works great when I remove the django site conf, but when i use django and php together php files don't work (browser just downloads them), any ideas (please be specific i'm new to this stuff)? I open to suggestions, getting kinda desperate here. Thanks
Here is my django-site conf file for nginx:
# mysite_nginx.conf
####################
# the upstream component nginx needs to connect to
upstream django {
# server unix:///home/appdeploy/uwsgi-tutorial/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name 173.10.235.37; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/appdeploy/v1/website/media;
# your Django project's media files - amend as required
}
location /static {
alias /home/appdeploy/v1/website/static;
# your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/appdeploy/v1/website/uwsgi_params; # the uwsgi_params file you installed
}
error_page 404 /404.html;
location = /404.html {
root /home/appdeploy/v1; ## or whereever You put it - will not be needed if 404.html is where index.html is placed
}
}
Here is my default conf file running as well (with the php fast cgi):
# default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /home/appdeploy/v1/website;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/appdeploy/v1/website$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}