CentOS7下Nginx安装

安装nginx的基本环境部署

1、gcc、 gcc-c++ 是用来编译下载下来的nginx源码
2、pcre和pcre-devel
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。
nginx 的 http 模块使用 pcre 来解析正则表达式,pcre-devel 是使用 pcre 开发的一个二次开发库。
3、安装zlib zlib提供了很多压缩和解方式,nginx需要zlib对http进行gzip
4、安装openssl openssl是一个安全套接字层密码库,nginx要支持https,需要使用openssl

yum install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel -y

官网下载

https://nginx.org/en/download.html

解压

tar -zxvf nginx-1.14.0.tar.gz -C  /usr/local

编译

 ./configure –prefix=/usr –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –pid-path=/var/run/nginx/nginx.pid –lock-path=/var/lock/nginx.lock –user=nginx –group=nginx –with-http_ssl_module –with-http_flv_module –with-http_gzip_static_module –http-log-path=/var/log/nginx/access.log –http-client-body-temp-path=/var/tem/nginx/client –http-proxy-temp-path=/var/tem/nginx/proxy –http-fastcgi-temp-path=/var/tem/nginx/fcgi –with-http_stub_status_module

安装

  make && make install

启动

nginx -c /etc/nginx/nginx.conf

其他问题处理

1、如果出现[emerg] getpwnam(“nginx”) failed 错误 执行

useradd -s /sbin/nologin -M nginx
 id nginx

2.如果出现 [emerg] mkdir() “/var/temp/nginx/client” failed (2: No such file or directory) 错误 执行

sudo mkdir -p /var/tem/nginx/client

3.如果您正在运行防火墙,请运行以下命令以允许HTTP和HTTPS通信:

sudo firewall-cmd –permanent –zone=public –add-service=http 
sudo firewall-cmd –permanent –zone=public –add-service=https

sudo firewall-cmd –reload

4.nginx 重启

进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可

./nginx -s reload 

5.nginx 配置文件检测

nginx -t -c /etc/nginx/nginx.conf
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值