注意事项:
- 安装用户为root
- 服务器需要连网并能够执行yum下载环境
- 下载包:
http://nginx.org/en/download.html
-
安装基础环境:yum -y install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel
-
解压
-
执行 ./configure
-
编译并安装:执行make 再执行make install
-
查看安装位置 whereis nginx
-
进入启动目录:/usr/local/nginx/sbin
-
启动nginx ./nginx
-
查看nginx ps -ef|grep nginx
-
访问界面:ip:80端口
-
复制配置文件,准备修改配置文件 cp nginx.conf nginx.conf_bak
-
修改端口80为81
-
启动与停止命令:
./nginx -s stop //停止
./nginx 开启
./nginx -s quit //停止
./nginx -s reload 重启
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
-
停止命令:
-
查看日志路径:
/usr/local/nginx/logs
验证nginx
-
执行: ./nginx -t
-
或者指定配置文件方式: ./nginx -t -c /root/nginx-1.18.0/conf/nginx.conf
-
参考博客:https://blog.youkuaiyun.com/w410589502/article/details/70787468