nginx安装及相关操作
工作中经常用到nginx,今天写个自动部署nginx的脚本。nginx版本选用:1.20.2
1.创建nginx安装脚本(nginx.sh)
[root@iZ2ze7uphtapcv51egcm7rZ opt]# vim nginx.sh
#!/bin/bash
yum -y install openssl openssl-devel make zlib zlib-devel gcc gcc-c++ libtool pcre pcre-devel wget http://nginx.org/download/nginx-1.20.2.tar.gz tar -zxvf nginx-1.20.2.tar.gz -C /usr/src cd /usr/src/nginx-1.20.2 mkdir /opt/nginx ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module make && make install
echo "nginx安装路径:/opt/nginx"
2. 执行nginx安装脚本
[root@iZ2ze7uphtapcv51egcm7rZ opt]# sh nginx.sh
3. 启动nginx
[root@iZ2ze7uphtapcv51egcm7rZ opt]# cd /opt/nginx [root@iZ2ze7uphtapcv51egcm7rZ nginx]# ls conf html logs sbin [root@iZ2ze7uphtapcv51egcm7rZ nginx]# cd sbin/ [root@iZ2ze7uphtapcv51egcm7rZ sbin]# ./nginx
4. 查看nginx是否启动成功
[root@iZ2ze7uphtapcv51egcm7rZ sbin]# ps -ef|grep nginx root 28059 1 0 19:55 ? 00:00:00 nginx: master process ./nginx nobody 28060 28059 0 19:55 ? 00:00:00 nginx: worker process root 28116 25068 0 19:56 pts/0 00:00:00 grep --color=auto nginx
5. 其它操作
检查配置文件nginx.conf的正确性命令:./nginx -t
修改配置文件后重启nginx:./nginx -s reload
停止nginx:./nginx -s stop
查看nginx版本:./nginx -v
6. nginx优化
参考链接:https://www.cnblogs.com/silgen/p/16636782.html
nginx下载地址:https://nginx.org/en/download.html
本文来自博客园,作者:查拉图斯特拉面条,转载请注明原文链接:https://www.cnblogs.com/n00dle/p/16690013.html