1、安装
下载RPM: wget http://nginx.org/download/nginx-1.16.0.tar.gz
解压:tar -zxf nginx-1.16.0.tar.gz
安装:
cd nginx-1.16.0
./configure
make && make install2、安装成功后nginx的几个默认目录
执行目录:/usr/sbin/nginx
模块所在目录:/usr/lib64/nginx/modules
配置所在目录:/etc/nginx/
默认站点目录:/usr/share/nginx/html
主要配置文件:/etc/nginx/nginx.conf 指向:/etc/nginx/conf.d/default.conf
PID目录:/var/run/nginx.pid 错误日志:/var/log/nginx/error.log 访问日志:/var/log/nginx/access.log3、查看nginx状态
输入命令:systemctl status nginx.service
1 [root@N37012 ~]# systemctl status nginx.service 2 ● nginx.service - nginx 3 Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) 4 Active: failed (Result: exit-code) since 日 2019-05-19 16:31:16 CST; 15min ago 5 Process: 23482 ExecStop=/usr/local/nginx/sbin/nginx quit (code=exited, status=1/FAILURE) 6 Main PID: 7158 (code=exited, status=0/SUCCESS) 7 8 5月 19 16:00:29 N37012 systemd[1]: Starting nginx... 9 5月 19 16:00:30 N37012 systemd[1]: Started nginx.10 5月 19 16:31:15 N37012 systemd[1]: Stopping nginx...11 5月 19 16:31:15 N37012 nginx[23482]: nginx: invalid option: "quit"12 5月 19 16:31:16 N37012 systemd[1]: nginx.service: control process exited, code=exited status=113 5月 19 16:31:16 N37012 systemd[1]: Stopped nginx.14 5月 19 16:31:16 N37012 systemd[1]: Unit nginx.service entered failed state.15 5月 19 16:31:16 N37012 systemd[1]: nginx.service failed.16 [root@N37012 ~]#
4、启动、停止、重启命令
systemctl start nginx.service
systemctl stop nginx.service
systemctl reload nginx.service
systemctl status nginx.service
5、查看nginx的状态
1 [root@N37012 ~]# systemctl status nginx.service 2 ● nginx.service - nginx 3 Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) 4 Active: active (running) since 日 2019-05-19 16:00:30 CST; 30min ago 5 Main PID: 7158 (nginx) 6 Tasks: 2 7 CGroup: /system.slice/nginx.service 8 ├─7158 nginx: master process /usr/local/nginx/sbin/nginx 9 └─7159 nginx: worker process10 11 5月 19 16:00:29 N37012 systemd[1]: Starting nginx...12 5月 19 16:00:30 N37012 systemd[1]: Started nginx.13 [root@N37012 ~]#
6、杀掉进程命令
a.相关nginx进程全部杀掉:killall -9 nginx
b.把PID两个经常杀掉:kill -9 pid1 and kill -9 pid 2
6、查看版本
输入命令:nginx -V