我需要对已经在服务器中运行的 django 应用程序进行故障排除。我要访问APP URL IP:PORT
但我不知道前开发人员用什么端口来运行它。例如:manage.py runserver 0.0.0.0:<port>
是否有可能通过类似的方式检查这个已使用的端口
netstat -ano | grep ...
netstat -ano | grep runserver
不提供任何东西。
如果不使用runserver
,我应该如何检查(apache/nginx)?
最佳答案
您确定服务器是使用“runserver”启动的吗?如果使用像 apache 或 nginx 这样的网络服务器,那么您需要查找这些进程名称。
如果使用“runserver”:
选项 1: netstat
和 grep
用于“python”而不是“runserver”(请参阅 this askubuntu answer):
$ sudo netstat -peanut | grep python
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 1000 3645959 28500/python
tcp 0 0 127.0.0.1:37004 127.0.0.1:39989 ESTABLISHED 1000 3041068 22188/python
$
选项 2: ps
和 grep
用于“runserver”:
$ ps -aux | grep runserver
ralf 28500 2.2 0.4 309672 74184 tty2 Sl+ 14:11 0:14 /home/ralf/.venv/bin/python /home/ralf/manage.py runserver
ralf 29199 0.0 0.0 21532 1000 pts/0 S+ 14:22 0:00 grep --color=auto runserver
$
关于django - 如何检查 django 在正在运行的服务器上使用的端口? `manage.py runserver 0.0.0.0:<port>` ,或通过 apache/nginx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59326949/