您的位置:首页 > 运维架构 > Nginx

CentOS 7下编译安装 nginx1.9.14

2016-04-17 22:01 591 查看
开始安装 nginx1.9.14
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.9.14.tar.gz tar -zxvf nginx-1.7.8.tar.gz
cd nginx-1.7.8
#编译基本能运行的nginx
./configure \
--user=www \
--group=www \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--wit
4000
h-http_ssl_module \
--with-http_gzip_static_module

make
make install


若有错误,则考虑是否依赖相关问题。

如果有错误提示:

./configure: error: C compiler cc is not found

解决方法:
yum install gcc gcc-c++


如果有错误提示:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using –without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using –with-pcre=<path> option.

解决方法:
yum install pcre-devel


如果有错误提示:

./configure: error: SSL modules require the OpenSSL library.

You can either do not enable the modules, or install the OpenSSL library

into the system, or build the OpenSSL library statically from the source

with nginx by using –with-openssl=<path> option.

解决方法:
 yum install openssl-devel


以上错误提示依次解决后:再一次的运行

nginx直接启动的方法:
/usr/local/nginx/sbin/nginx


编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_module
#开启ssl支持
--with-http_ssl_module
#开启GZIP功能
--with-http_gzip_static_module


安装完成之后,若本机通过curl或者wget方式访问localhost可以访问到nginx相关信息但是其他机子不行,则考虑是否是防火墙firewalld引起的。

禁用防火墙:systemctl stop firewalld

参考网址:

安装nginx:http://www.centoscn.com/nginx/2015/0423/5253.html

防火墙firewalld:http://www.centoscn.com/CentOS/help/2015/0208/4667.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  CentOS nginx php