CentOS6.5编译安装Nginx和Openssl


 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的小文件并发能力在同类型的网页服务器中表现较好。

Nginx的编译安装:

1.下载Openssl

 
[root@Node1 ~] # wget http://www.openssl.org/source/openssl-1.0.2.tar.gz


2.下载nginx

 
[root@Node1 ~] # wget http://nginx.org/download/nginx-1.6.2.tar.gz

 

3.解压软件

[root@Node1 ~] # tar zxf openssl-1.0.2.tar.gz
[root@Node1 ~] # tar zxf nginx-1.6.2.tar.gz

4.编译Nginx

[root@Node1 ~] # cd nginx-1.6.2
[root@Node1 nginx-1.6.2] # ./configure  --user=www --group=www --prefix=/data/nginx1.6.2
--with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
--with-openssl=/root/openssl-1.0.2

注意:编译nginx添加ssl支持,如果需要编译的openssl,是不需要编译opensll,--with-openssl=DIR DIR是openssl的源码路径,不是openssl的安装路径,否则make时将出错:

make [1]: Entering directory ` /root/nginx-1 .6.2'
cd  /server/openssl  \
         &&  make  clean \
         && . /config  --prefix= /server/openssl/openssl  no-shared  no-threads \
         &&  make  \
         &&  make  install
make [2]: Entering directory ` /server/openssl '
make [2]: *** No rule to  make  target `clean'.  Stop.
make [2]: Leaving directory ` /server/openssl '
make [1]: *** [ /server/openssl/openssl/include/openssl/ssl .h] Error 2
make [1]: Leaving directory ` /root/nginx-0 .7.61'
make : *** [build] Error 2

 

如果出现

. /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.

这说明没有安装pcre &  pcre-devel包,这里yum安装

 
[root@Node1 nginx-1.6.2] # yum -y install pcre pcre-devel

 

5.安装Nginx

[root@Node1 nginx-1.6.2] # make
 
[root@Node1 nginx-1.6.2] # make install

 

6.启动之前检查nginx

 
[root@Node1 nginx-1.6.2] # /data/nginx1.6.2/sbin/nginx -t
nginx: the configuration  file  /data/nginx1 .6.2 /conf/nginx .conf syntax is ok
nginx: [emerg] getpwnam( "www" ) failed
nginx: configuration  file  /data/nginx1 .6.2 /conf/nginx .conf  test  failed

检查发现是没有运行用户,新增www账户

[root@Node1 nginx-1.6.2] # groupadd www
[root@Node1 nginx-1.6.2] # useradd -g www -s /sbin/nologin -d /dev/null www

7.再次检查

[root@Node1 nginx-1.6.2]# /data/nginx1.6.2/sbin/nginx -t
nginx: the configuration file /data/nginx1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /data/nginx1.6.2/conf/nginx.conf test is successful
 

8.启动Nginx

 
[root@Node1 nginx-1.6.2] # /data/nginx1.6.2/sbin/nginx

9.检查端口

 
[root@Node1 nginx-1.6.2] # netstat -ntlup |grep :80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN     
19849
/nginx

10.检查进程

[root@Node1 nginx-1.6.2] # ps aux |grep nginx
root     19849  0.0  0.0  22664   852 ?        Ss   11:19   0:00 nginx: master process
 
/data/nginx1 .6.2 /sbin/nginx
www      19850  0.0  0.1  23100  1448 ?        S    11:19   0:00 nginx: worker process
root     19858  0.0  0.0 103244   856 pts /0     S+   11:21   0:00  grep  nginx

11.网站访问

wKioL1T2fL_zYxrrAAGEdK_4bkY849.jpg


转自: http://www.centoscn.com/nginx/2015/0304/4782.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值