CentOS安装nginx openresty
1. 新建openresty.sh文件
cd /usr/local vim openresty.sh
2. 在新建的openresty.sh脚本文件中添加安装命令
最好获取网盘的命令,以下命令直接复制可能由于空格等使得无法使用。
链接:https://pan.baidu.com/s/1H1s3haf4lUGX96Sxc9Fx6A
提取码:h8jd
yum install -y pcre-devel openssl-devel gcc curl cd /usr/local/ wget https://openresty.org/download/openresty-1.17.8.2.tar.gz cd /usr/local/ tar -zxvf openresty-1.17.8.2.tar.gz cd /usr/local/ mv openresty-1.17.8.2 openresty cd /usr/local/openresty/ ./configure --with-luajit \ --without-http_redis2_module \ --with-http_iconv_module cd /usr/local/openresty/ make && make install
3. 授权openresty.sh文件写入权限
chmod +x openresty.sh
4. 执行文件
./openresty.sh
5. 修改环境
vi /etc/profile #将以下红色字体命令添加进配置文件 export PATH=/usr/local/openresty/nginx/sbin:$PATH
#重新加载环境变量
source /etc/profile
6. 启动nginx
cd /usr/local/openresty/ ./nginx/sbin/nginx #启动 ./nginx/sbin/nginx -s stop #强制停止 ./nginx/sbin/nginx -s quit #安全退出,会等待正在执行的线程执行完毕再停止 ./nginx/sbin/nginx -s reload #重启
7. 检测启动是否成功
ps -ef | grep nginx

本地请求输入服务器ip地址。

说明启动成功。

浙公网安备 33010602011771号