linux中安装nginx方法

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

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值