CentOS系统下安装Nginx

系统平台: CentOS 7.7.1908 (Core)

nginx1.9.1

pcre8.42

01. 安装编译环境及库文件

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

02. 安装PCRE, 让nginx支持rewrite功能

  2.1 下载PCRE安装包,下载地址: http://downloads.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz

         注意: 必须安装到/usr/local/src/路径下

cd /usr/local/src/
wget http://downloads.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz

2.2 解压安装包

tar zxvf pcre-8.42.tar.gz

2.3 进入安装包

cd pcre-8.42

2.4 编译安装

./configure
make && make install

2.5 查看pcre版本

pcre-config --version

3. 安装nginx

3.1 下载nginx安装包, 下载地址:http://nginx.org/download/nginx-1.9.1.tar.gz

cd /opt/
wget http://nginx.org/download/nginx-1.9.1.tar.gz

3.2 解压安装包

tar zxvf nginx-1.9.1.tar.gz

3.3 进入安装包

./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.42

3.4 编译安装

make
make install

3.5 查看nginx版本

cd /usr/local/webserver/nginx/sbin/    // 注意nginx的安装路径
nginx -v

3.6 修改nginx端口号, 配置文件的路劲为/usr/local/webserver/nginx/conf/nginx.conf, 和有些文档不符.

4. nginx操作

cd /usr/local/webserver/nginx/sbin/
./nginx   // 启动
./nginx -s stop    // 停止
./nginx -s reload  // 重新加载配置文件
./nginx -s reopen  // 重新启动

5. 查看nginx进程

ps -ef | grep nginx

6. 关闭防火墙

systemctl stop firewalld // 临时关闭
systemctl stop firewalld // 启动防火墙
systemctl disable firewalld //然后reboot 永久关闭
systemctl enable firewalld //然后reboot 永久关闭

systemctl status  firewalld 查看防火墙状态。

7. 测试, 输入http://ip地址:端口, 出现如下界面说明nginx安装完成

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值