I'm getting really stressed out because i'm trying to get this site running on my ubuntu server. I'm just a front-ender trying to host things by myself. I think i almost got it down. But still getting 502 bad gateway error when visiting the domain.
This is my project tree:
-- var
-- www
-- stacaravanverhuurgroesbeek
|-- env/
|-- logs/
|-- access.log
|-- error.log
`-- uwsgi.log
|-- conf/
| |-- stacaravanverhuurgroesbeek.sock
| `-- uwsgi.ini
`-- public/
|-- manage.py
|-- media/
|-- project.db
|-- requirements.txt
|-- static/
`-- website/
|-- dev/
|-- gulp/
|-- gulpfile.js
|-- package.json
|-- settings.py
|-- static/
|-- templates/
|-- urls.py
`-- wsgi.py
My uwsgi ini file: /var/www/stacaravanverhuurgroesbeek/conf/uwsgi.ini
:
[uwsgi]
# variables
projectname = stacaravanverhuurgroesbeek
projectdomain = stacaravanverhuurgroesbeek.nl
base = /var/www/stacaravanverhuurgroesbeek
# config
chdir = %(base)/public
home = %(base)/env
wsgi-file = %(base)/public/website/wsgi.py
master = True
processes = 5
socket = %(base)/conf/%(projectname).sock
vacuum = true
die-on-term = true
logto = %(base)/logs/uwsgi.log
My nginx config: /etc/nginx/sites-available/stacaravanverhuurgroesbeek
:
server {
listen 80;
server_name stacaravanverhuurgroesbeek.nl www.stacaravanverhuurgroesbeek.nl;
root /var/www/stacaravanverhuurgroesbeek/;
access_log /var/www/stacaravanverhuurgroesbeek/logs/access.log;
error_log /var/www/stacaravanverhuurgroesbeek/logs/error.log;
location /static/ {
root /var/www/stacaravanverhuurgroesbeek/public/static/;
}
location /media/ {
root /var/www/stacaravanverhuurgroesbeek/public/media/;
}
location / {
include uwsgi_params;
uwsgi_pass unix:///var/www/stacaravanverhuurgroesbeek/conf/stacaravanverhuurgroesbeek.sock;
}
}
I also symlinked this file to sites-enabled
.
And my startup script: /etc/init/uwsgi.conf
# Emperor uWSGI script
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [!2345]
setuid bastard
setgid bastard
exec uwsgi --master --emperor /etc/uwsgi/vassals
Also everytime I changed something I restarted both nginx and uwsgi, with no effect.
I really hope someone can see what the problem is in my setup.
Perhaps you should set upstream in Nginx config since you're going to proxy all requests to uWSGI. Eg:
upstream uwsgi_app {
server unix:///path/to/your/mysite/mysite.sock; # взаимодействие
}
server {
...
location / {
uwsgi_pass uwsgi_app;
include uwsgi_params;
}
...
}
If it won't work please provide uWSGI log also to make sure that reqquest actually reach uWSGI and no error occured.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.