Linux服务器部署nginx,centos中编译安装nginx

安装编译环境和必要的库

[root@localhost ~]# yum -y install gcc gcc-c++ autoconf automake libtool make cmake
[root@localhost ~]# yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

说明:

zlib: 为nginx提供gzip模块,需要zlib库支持
openssl: 为nginx提供ssl功能
pcre: 为支持地址重写rewrite功能,有一些操作系统使用yum install pcre-devel安装,由于缺乏包,而安装失败,因此需要手动安装

手动安装pcre

[root@localhost ~]#wget https://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz
[root@localhost ~]#tar -zxvf pcre-8.39.tar.gz
[root@localhost ~]#cd pcre-8.39
[root@localhost ~]#./configure
[root@localhost ~]#make
[root@localhost ~]#make install

创建用来运行nginx的用户及组

[root@localhost ~]#groupadd nginx
[root@localhost ~]#useradd -M -s /sbin/nologin -g nginx nginx

说明

-g参数为nginx用户指定了一个组。
-M参数保证其不自动生成home目录。

编译安装Nginx

[root@localhost ~]#wget http://nginx.org/download/nginx-1.10.1.tar.gz
[root@localhost ~]#ls
[root@localhost ~]#tar -zxvf nginx-1.10.1.tar.gz 
[root@localhost ~]#cd nginx-1.10.1
[root@localhost ~]#ls
[root@localhost ~]#./configure --prefix=/usr/local/nginx --with-http_ssl_module --user=nginx --group=nginx --with-pcre 
[root@localhost ~]#make
[root@localhost ~]#make install

启动

[root@localhost ~]# /usr/local/nginx/sbin/nginx   启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop  停止
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload  重新载入
[root@localhost ~]# /usr/local/nginx/sbin/nginx -v  查看版本
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t  测试配置文件是否正常
[root@localhost ~]# pkill nginx  强制关闭

查看安装状态

[root@localhost ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.10.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --user=nginx --group=nginx --with-pcre

原文链接:https://blog.csdn.net/bjnihao/article/details/52370089

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值