老师你好,我线上服务器重新部署了代码

来源:16-2 nginx + uwsgi 实现多进程访问

慕妹4270370

2019-08-01

怎么启动的?
我启动不成功了。
麻烦告诉我一下,执行的代码流程,谢谢

[root@izbp1i0t9v2ixxhu5e9tewz ~]# clear
[root@izbp1i0t9v2ixxhu5e9tewz ~]# pwd
/root
[root@izbp1i0t9v2ixxhu5e9tewz ~]# cd data/www/
[root@izbp1i0t9v2ixxhu5e9tewz www]# ll
total 25812
drwxrwxrwx 2 root root     4096 Jul 14 23:52 challenges
drwxrwxrwx 2 root root     4096 Jul 15 00:00 https
drwxrwxrwx 2 root root     4096 Aug  1 18:46 logs
drwxr-xr-x 9 root root     4096 Jul 31 17:18 Order
-rw-r--r-- 1 root root 26409908 Aug  1 17:19 order.zip
drwxrwxrwx 5 root root     4096 Jul 10 19:01 python3_vir
[root@izbp1i0t9v2ixxhu5e9tewz www]# source python3_vir/bin/activate
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz www]# cd Order/
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# ll
total 52
-rw-r--r-- 1 root root  979 Jun 26 19:43 application.py
drwxr-xr-x 5 root root 4096 Jun 10 16:28 common
drwxr-xr-x 2 root root 4096 Jul 31 16:48 config
drwxr-xr-x 2 root root 4096 Jun 10 16:18 docs
drwxr-xr-x 4 root root 4096 Jul  5 10:07 jobs
-rw-r--r-- 1 root root  525 Jul  5 09:54 manager.py
drwxr-xr-x 7 root root 4096 Jul 29 13:10 mina
drwxr-xr-x 2 root root 4096 Aug  1 17:45 __pycache__
-rw-r--r-- 1 root root  419 Jul 31 17:18 readme.md
-rw-r--r-- 1 root root   67 Jul  9 11:31 requirements.txt
-rw-r--r-- 1 root root  409 Jul 11 23:33 uwsgi.ini
drwxr-xr-x 7 root root 4096 Jun 11 17:38 web
-rw-r--r-- 1 root root 1427 Jul  7 18:33 www.py
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# export ops_config=production
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini
[uwsgi-static] added mapping for /static => /root/data/www/Order/web/static
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# sudo service nginx restart
Redirecting to /bin/systemctl restart  nginx.service
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2019-08-02 11:11:36 CST; 15s ago
  Process: 2383 ExecReload=/bin/kill -s HUP $MAINPID (code=exited, status=0/SUCCESS)
  Process: 3374 ExecStart=/usr/sbin/nginx (code=exited, status=1/FAILURE)
  Process: 3372 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 3371 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 2349 (code=killed, signal=KILL)
   CGroup: /system.slice/nginx.service
           └─2384 nginx: worker process

Aug 02 11:11:34 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: nginx.service: control process exited, code=exited status=1
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] still could not bind()
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Unit nginx.service entered failed state.
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: nginx.service failed.
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# journalctl -xe
-- Subject: Unit session-126.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-126.scope has finished starting up.
-- 
-- The start-up result is done.
Aug 02 11:10:01 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Starting Session 126 of user root.
-- Subject: Unit session-126.scope has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit session-126.scope has begun starting up.
Aug 02 11:10:01 izbp1i0t9v2ixxhu5e9tewz CROND[3346]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz sudo[3353]:     root : TTY=pts/0 ; PWD=/root/data/www/Order ; USER=root ; COMMAND=/sbin/service nginx restart
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz polkitd[445]: Registered Authentication Agent for unix-process:3354:6265263 (system bus name :1.279 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Starting The nginx HTTP and reverse proxy server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has begun starting up.
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz nginx[3372]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz nginx[3372]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:33 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:34 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:34 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:34 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:34 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Aug 02 11:11:35 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz polkitd[445]: Unregistered Authentication Agent for unix-process:3354:6265263 (system bus name :1.279, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: nginx.service: control process exited, code=exited status=1
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz nginx[3374]: nginx: [emerg] still could not bind()
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit nginx.service has failed.
-- 
-- The result is failed.
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: Unit nginx.service entered failed state.
Aug 02 11:11:36 izbp1i0t9v2ixxhu5e9tewz systemd[1]: nginx.service failed.
lines 3779-3825/3825 (END)

===========================
老师请看

[root@izbp1i0t9v2ixxhu5e9tewz ~]# sudo netstat -anpl |grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      2384/nginx: worker  
[root@izbp1i0t9v2ixxhu5e9tewz ~]# 

该怎么解决?
我想问一下 我上传新的后台代码 正确的操作步骤是什么

我执行了如下代码 还是不能正常访问

[root@izbp1i0t9v2ixxhu5e9tewz ~]# sudo netstat -anpl |grep 443
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      2384/nginx: worker  
[root@izbp1i0t9v2ixxhu5e9tewz ~]# kill -9 2384
[root@izbp1i0t9v2ixxhu5e9tewz ~]# sudo netstat -anpl |grep 443
[root@izbp1i0t9v2ixxhu5e9tewz ~]# pwd
/root
[root@izbp1i0t9v2ixxhu5e9tewz ~]# cd data/www/
[root@izbp1i0t9v2ixxhu5e9tewz www]# ll
total 25812
drwxrwxrwx 2 root root     4096 Jul 14 23:52 challenges
drwxrwxrwx 2 root root     4096 Jul 15 00:00 https
drwxrwxrwx 2 root root     4096 Aug  1 18:46 logs
drwxr-xr-x 9 root root     4096 Jul 31 17:18 Order
-rw-r--r-- 1 root root 26409908 Aug  1 17:19 order.zip
drwxrwxrwx 5 root root     4096 Jul 10 19:01 python3_vir
[root@izbp1i0t9v2ixxhu5e9tewz www]# source python3_vir/bin/activate
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz www]# cd Order/
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# ll
total 52
-rw-r--r-- 1 root root  979 Jun 26 19:43 application.py
drwxr-xr-x 5 root root 4096 Jun 10 16:28 common
drwxr-xr-x 2 root root 4096 Jul 31 16:48 config
drwxr-xr-x 2 root root 4096 Jun 10 16:18 docs
drwxr-xr-x 4 root root 4096 Jul  5 10:07 jobs
-rw-r--r-- 1 root root  525 Jul  5 09:54 manager.py
drwxr-xr-x 7 root root 4096 Jul 29 13:10 mina
drwxr-xr-x 2 root root 4096 Aug  1 17:45 __pycache__
-rw-r--r-- 1 root root  419 Jul 31 17:18 readme.md
-rw-r--r-- 1 root root   67 Jul  9 11:31 requirements.txt
-rw-r--r-- 1 root root  409 Jul 11 23:33 uwsgi.ini
drwxr-xr-x 7 root root 4096 Jun 11 17:38 web
-rw-r--r-- 1 root root 1427 Jul  7 18:33 www.py
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# export ops_config=production
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# uwsgi --ini uwsgi.ini
[uWSGI] getting INI configuration from uwsgi.ini
[uwsgi-static] added mapping for /static => /root/data/www/Order/web/static
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# sudo service nginx restart
Redirecting to /bin/systemctl restart  nginx.service
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz Order]# 
(python3_vir) [root@izbp1i0t9v2ixxhu5e9tewz logs]# tail -f order.log 
  File "/root/data/www/python3_vir/lib/python3.5/site-packages/sqlalchemy/engine/__init__.py", line 435, in create_engine
    return strategy.create(*args, **kwargs)
  File "/root/data/www/python3_vir/lib/python3.5/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/root/data/www/python3_vir/lib/python3.5/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
    return __import__("MySQLdb")
  File "/root/data/www/python3_vir/lib/python3.5/site-packages/MySQLdb/__init__.py", line 18, in <module>
    from . import _mysql
ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory
[pid: 2480|app: 0|req: 70/78] 183.192.138.227 () {58 vars in 1106 bytes} [Sat Aug  3 11:49:04 2019] POST /api/member/check-reg => generated 0 bytes in 104 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

写回答

3回答

编程浪子

2019-08-03

你好 

你每个问题单独问吧,完全看不懂到底什么问题了,一会nginx好,一会不好。

可以通过课程群里找到我的qq,qq交流快

0
0

编程浪子

2019-08-02

你好

nginx: [emerg] bind() to 0.0.0.0:443

这个报错说明已经有个服务把端口占用了 

可以执行 

sudo netstat -anpl |grep 443 看看

0
2
慕妹4270370
老师,我杀掉443 之后 执行成功不报错了,现在访问,小程序开发者工具报502错误
2019-08-03
共2条回复

编程浪子

2019-08-02

你好

你执行什么命令,启动不成功报错是什么?

0
1
慕妹4270370
老师 请看我又添加了代码描述 ,接下来该怎么操作
2019-08-02
共1条回复

Python Flask构建微信小程序订餐系统(可用于毕设)

微信小程序 + Python Flask 打造订餐系统全栈应用,可用于毕设。

1709 学习 · 1889 问题

查看课程