centos7手动安装Nginx

环境:vbox +centos7 

基本可以yum安装 gcc 、pcre、zlib、openssl等,此处部分文件手动下载安装

1.下载依耐包:

gcc :yum install gcc

2.下载openssl:

wget https://www.openssl.org/source/openssl-3.0.10.tar.gz --no-check-certificate

安装过程会报错:Can‘t locate IPC/Cmd.pm in @INC  运行yum -y install perl-IPC-Cmd 解决

如果没有先安装gcc,也可能会出错。

成功如下:

3.下载zlib:wget http://zlib.net/current/zlib.tar.gz

解压后进入目录文件下输入:./configure  然后make && make install

4.下载pcre2:

Download pcre2-10.37.tar.gz (PCRE)

解压就可以了,用于后面的nginx 配置,写上此处解压的目录

 5.下载nginx:

wget nginx: download

解压后

 ./configure  --sbin-path=/usr/local/nginx/nginx  --conf-path=/usr/local/nginx/nginx.conf   --pid-path=/usr/local/nginx/nginx.pid   --with-http_ssl_module  --with-pcre=../pcre2-10.37  --with-zlib=../zlib-1.3

--with-http_ssl_module:开启https 443

--with-pcre :用于路由重写  sets the path to the sources of the PCRE library. The library distribution needs to be downloaded from the PCRE site and extracted. The rest is done by nginx’s ./configure and make. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module.

--with-zlib:ngx_http_gzip_module 需要用到, 主要用于压缩文件

完成后  make && make install

最后

cd /usr/local/nginx

./nginx 

开启nginx后,查看进程 ps ef|grep nginx

访问IP地址能看到welcome to nginx代表安装成功

如果不能成功,需要开启防火墙的端口

nginx服务指令 nginx -s stop /quit /reload /reopen

如果运行重启指令时提示:nginx: command not found

需要添加nginx到环境变量中

vi /etc/profile

文末添加(后面的路径根据当时配的sbin-path路径来):

export PATH=/usr/local/nginx/:$PATH

重启资源

source /etc/profile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值