Я, пытаюсь настроить тестовый веб-сервер.
/ дом / WebApp / uwsgi / сайты / testproject.ini
[uwsgi]
plugins=python
home = /home/webapp/testproject/env
chdir = /home/webapp/testproject/testproject
pythonpath=/home/webapp/testproject
wsgi-file = /home/webapp/testproject/testproject/wsgi.py
http = 0.0.0.0:8000
socket = /var/run/testproject.sock
vacuum = true
chown-socket = nginx:nginx
chmod-socket = 666
uid = nginx
gid = nginx
listen.owner = nginx
listen.group = nginx
/ и т.д. / Systemd / система / uwsgi.service
[Unit]
Description=uWSGI Emperor service
After=syslog.target
[Service]
ExecStart=/usr/local/bin/uwsgi --emperor /home/webapp/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
/ и т.д. / Nginx / сайты-доступные / TestProject
server {
listen 0.0.0.0:8000 default_server;
location / {
include uwsgi_params;
uwsgi_pass unix:/var/run/testproject.sock;
}
}
и копирование на включенные сайты
sudo ln -s /etc/nginx/sites-available/testproject /etc/nginx/sites-enabled
проверка конфигурации nginx
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
А затем запустите uwsgi и nginx
sudo systemctl daemon-reload
sudo systemctl start uwsgi
sudo systemctl start nginx
Когда я открываю http://0.0.0.0:8000/, я получаю сообщение об ошибке 502 Bad Gateway
uwsgi выглядит нормально
stemctl status uwsgi.service
● uwsgi.service - uWSGI Emperor service
Loaded: loaded (/etc/systemd/system/uwsgi.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-05-23 22:40:20 CEST; 4min 47s ago
Main PID: 27454 (uwsgi)
Status: "The Emperor is governing 1 vassals"
Tasks: 2 (limit: 4915)
Memory: 2.6M
CGroup: /system.slice/uwsgi.service
└─27454 /usr/local/bin/uwsgi --emperor /home/webapp/uwsgi/sites
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: !!! no internal routing support, rebuild with pcre support !!!
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: chdir() to /home/webapp/testproject/testproject
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: your processes number limit is 31045
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: your memory page size is 4096 bytes
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: detected max file descriptor number: 1024
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: lock engine: pthread robust mutexes
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: thunder lock: disabled (you can enable it with --thunder-lock)
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: probably another instance of uWSGI is running on the same address (0.0.0.0:8000).
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: bind(): Address already in use [core/socket.c line 769]
Mai 23 22:45:06 Lenovo-B51-80 uwsgi[27454]: Thu May 23 22:45:06 2019 - [emperor] curse the uwsgi instance testproject.ini (pid: 2786
Mai 23 22:51:12 Lenovo-B51-80 uwsgi[27454]: Thu May 23 22:51:12 2019 - [emperor] removed uwsgi instance testproject.ini
То же самое с сервисом nginx
systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-05-23 22:42:25 CEST; 4min 48s ago
Docs: man:nginx(8)
Process: 27626 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 27638 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 27639 (nginx)
Tasks: 5 (limit: 4915)
Memory: 5.3M
CGroup: /system.slice/nginx.service
├─27639 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─27640 nginx: worker process
├─27641 nginx: worker process
├─27642 nginx: worker process
└─27643 nginx: worker process
Mai 23 22:42:25 Lenovo-B51-80 systemd[1]: Starting A high performance web server and a reverse proxy server...
Mai 23 22:42:25 Lenovo-B51-80 systemd[1]: Started A high performance web server and a reverse proxy server.
Проверить файл журнала
/var/log/nginx/error.log
2019/05/23 22:42:47 [error] 28382#28382: *1 connect() to unix:/var/run/testproject.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/var/run/testproject.sock:", host: "0.0.0.0:8000"
что мне нужно сделать, чтобы отобразить тестовую страницу?
ls -l /var/run/testproject.sock
srw-rw-rw- 1 root root 0 Mai 23 22:42 /var/run/testproject.sock