yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre pcre-devel安装nginx稳定版本
wget http://nginx.org/download/nginx-1.18.0.tar.gz解压
tar -zxvf nginx-1.18.0.tar.gz构建
通常情况安装在 /usr/local/nginx 这个目录
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-debug make && make installnginx常用命令 启动nginx
进入到nginx安装目录,即/usr/local/nginx/sbin
./nginx验证配置是否成功
./nginx -t重启
./nginx -s reload一健安装并启动nginx的脚本
创建脚本
mkdir -p /home/soft/nginx && cd /home/soft/nginx && vim nginx-install.sh
脚本内容如下
# 安装nginx所需依赖 yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre pcre-devel # 下载nginx安装包 wget http://nginx.org/download/nginx-1.18.0.tar.gz # 解压 tar -zxvf nginx-1.18.0.tar.gz && cd nginx-1.18.0 # 构建 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-debug make && make install # 启动nginx /usr/local/nginx/sbin/nginx
给文件授权
chmod 777 nginxinstall.sh
运行脚本
sh nginx-install.sh
打开浏览器,访问http://ip/ 即可访问nginx



