前言
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器 [13],同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,公开版本1.19.6发布于2020年12月15日。 [11]
其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名。2022年01月25日,nginx 1.21.6发布。 [12]
Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好。
百度百科


配置 Nginx 为系统服务
这个是我的启动地址和配置文件地址
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
将 Nginx 制作成系统服务让你无需手动到 Nginx 安装目录下执行命令来启动它,而是系统会在开机时自动启动 Nginx,让启动过程更加方便和自动化。
1、编写 Nginx 系统启动文件
在 /lib/systemd/system 目录下创建 nginx.service 文件
vi /lib/systemd/system/nginx.service
编写内容如下:
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[Install]
WantedBy=multi-user.target
说明:ExecStart= 后配置实际的 Nginx 启动命令。
2、重载所有服务
systemctl daemon-reload
3、设置开机自启动
systemctl enable nginx
4、查看开机启动状态
systemctl is-enabled nginx
5、查看 Nginx 服务状态
systemctl status nginx
卸载 Nginx
如果需要卸载Nginx,您可以执行以下步骤:
停止 Nginx 服务:
执行以下命令停止 Nginx 服务:
systemctl stop nginx
如果你使用的是非系统服务方式启动Nginx,可以使用以下命令停止Nginx:
/usr/local/nginx/sbin/nginx -s stop
确定Nginx的安装位置:
执行以下命令查找Nginx的安装位置:
whereis nginx
该命令将返回Nginx可执行文件的路径,例如 /usr/local/nginx。
删除Nginx安装目录:
执行以下命令删除Nginx的安装目录:
rm -rf /usr/local/nginx
查找并删除相关文件:
执行以下命令查找可能与Nginx相关的文件:
find / -name nginx
这将搜索文件系统中所有包含 “nginx” 的文件名,并且你可以根据需要删除这些文件。
完成以上步骤后,Nginx将被完全卸载。



















