lnmp环境之Nginx安装,lnmp环境nginx


一. nginx是什么?
1)Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件代理服务器,并在一个BSD-like 协议下发行。
2)特点: 占有内存少, 并发能力强 , 事实上nginx的并发能力确实在同类型的网页服务器中表现较好。

1.安装前准备:

#首先确认是不是有安装编译包和一些依赖包
# yum install gcc gcc-c++ openssl openssl-devel zib-devel zib

2.安装pcre
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
#tar zxvf pcre-8.39.tar.gz
编译安装
# cd pcre-8.39
# ./configure --prefix=/usr/local/pcre
# make && make install

3.安装nginx
# wget http://nginx.org/download/nginx-1.6.2.tar.gz
# tar -zxvf nginx-1.6.2.tar.gz
# cd nginx-1.6.2
# ./configure --prefix=/usr/local/nginx --with-pcre=usr/local/pcre --with-http_stub_status_module
# make && make install

5.启动nginx
检查nginx配置文件语法有没问题
#/usr/local/nginx/sbin/nginx -t
如果没有会出现,下面提示
nginx: the configuration file /usr/local/nginx-1.4.6/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.4.6/conf/nginx.conf test is successful

启动nginx
#/usr/local/nginx/sbin/nginx
重新加载nginx
#/usr/local/nginx/sbin/nginx –s reload

到这一步没有什么错误,就可以ip访问了.

 

二.安装中报错解决:

1.解决nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed错误 

解决方法:
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

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

#yum -y install pcre-devel

以上仅为个人安装,仅供参考!

 

相关内容