1、首先确保系统已经安装gcc,如没安装,请先自行安装
2、安装nginx
将openssl-1.1.1j.tar.gz、pcre-8.44.tar.gz、zlib-1.3.tar.gz、nginx-1.20.0.tar.gz解压到当前目录,命令如下:
tar -zxvf openssl-1.1.1j.tar.gz
tar -zxvf pcre-8.44.tar.gz
tar -zxvf zlib-1.3.tar.gz
tar -zxvf nginx-1.20.0.tar.gz
将解压的文件从当前目录拷贝到/usr/local
cp ./openssl-1.1.1j /usr/local
cp ./pcre-8.44 /usr/local
cp ./zlib-1.3 /usr/local
cp ./nginx-1.20.0 /usr/local
安装pcre库
cd /usr/local/pcre-8.44
./configure
make && make install
安装openssl库
cd /usr/local/openssl-1.1.1j
./config
make && make install
安装zlib
cd /usr/local/zlib-1.2.11
./configure
make && make install
安装nginx
cd /usr/lcoal/nginx-1.20.0
./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl-1.1.1j --with-pcre=/usr/local/pcre-8.44 --with-zlib=/usr/local/zlib-1.3 --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
make && make install
3、创建启动和停止脚本
创建start.sh文件,内容如下:
/usr/local/nginx/sbin/nginx
创建stop.sh文件,内容如下
方式1
pid=`ps -ef|grep nginx|grep -v grep|awk ‘{print $2}’`
kill ${pid}
echo “kill process ${pid}”
方式2
/usr/local/nginx/sbin/nginx -s stop
文件下载链接地址:https://download.csdn.net/download/fyzs19891124/89625366