虽然作为1个后端程序员, 终究避不开这东西
安装Nginx
本人的测试服务器是debian , 安装过程跟ubuntu基本一样
sudo apt-get install nginx
问题是 nginx 安装后 执行文件在/usr/sbin 而不是/usr/bin 所以正常下普通用户是无法使用的。
必须切换到root 用户去配置nginx
gateman@tf-vpc0-subnet0-main-server:~$ nginx -v
-bash: nginx: command not found
gateman@tf-vpc0-subnet0-main-server:~$ sudo su -
root@tf-vpc0-subnet0-main-server:~# nginx -v
nginx version: nginx/1.18.0
root@tf-vpc0-subnet0-main-server:~#
查看服务注册, 可以简单注册nginx.service 已经成功, 而且已启动
root@tf-vpc0-subnet0-main-server:~# systemctl status nginx
● 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 Mon 2024-01-01 12:23:06 UTC; 28min ago
Docs: man:nginx(8)
Process: 32767 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 32768 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 32961 (nginx)
Tasks: 5 (limit: 19184)
Memory: 7.0M
CPU: 26ms
CGroup: /system.slice/nginx.service
├─32961 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─32963 nginx: worker process
├─32964 nginx: worker process
├─32965 nginx: worker process
└─32966 nginx: worker process
Jan 01 12:23:06 tf-vpc0-subnet0-main-server systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 01 12:23:06 tf-vpc0-subnet0-main-server systemd[1]: Started A high performance web server and a reverse proxy server.
root@tf-vpc0-subnet0-main-server:~#
查看Nginx 监听的端口
root@tf-vpc0-subnet0-main-server:~# sudo lsof -i -P -n | grep LISTEN
exim4 830 Debian-exim 4u IPv4 11734 0t0 TCP 127.0.0.1:25 (LISTEN)
exim4 830 Debian-exim 5u IPv6 11735 0t0 TCP [::1]:25 (LISTEN)
sshd 954 root 3u IPv4 10970 0t0 TCP *:22 (LISTEN)
sshd 954 root 4u IPv6 10972 0t0 TCP *:22 (LISTEN)
docker-pr 1304 root 4u IPv4 12180 0t0 TCP *:8201 (LISTEN)
docker-pr 1309 root 4u IPv6 12732 0t0 TCP *:8201 (LISTEN)
docker-pr 1401 root 4u IPv4 12777 0t0 TCP *:2222 (LISTEN)
docker-pr 1408 root 4u IPv6 13466 0t0 TCP *:2222 (LISTEN)
docker-pr 1453 root 4u IPv4 13489 0t0 TCP *:63790 (LISTEN)
docker-pr 1459 root 4u IPv6 14429 0t0 TCP *:63790 (LISTEN)
docker-pr 1474 root 4u IPv4 14437 0t0 TCP *:33062 (LISTEN)
docker-pr 1481 root 4u IPv6 12269 0t0 TCP *:33062 (LISTEN)
docker-pr 1500 root 4u IPv4 12276 0t0 TCP *:33061 (LISTEN)
do

最低0.47元/天 解锁文章
4万+

被折叠的 条评论
为什么被折叠?



