Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用。其特点是占有内存少,并发能力强,事实上nginx的小文件并发能力在同类型的网页服务器中表现较好。
Nginx的编译安装:
1.下载Openssl
2.下载nginx
3.解压软件
[root@Node1 ~]
[root@Node1 ~]
4.编译Nginx
[root@Node1 ~]
[root@Node1 nginx-1.6.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安装
5.安装Nginx
[root@Node1 nginx-1.6.2]
[root@Node1 nginx-1.6.2]
6.启动之前检查nginx
[root@Node1 nginx-1.6.2]
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]
[root@Node1 nginx-1.6.2]
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
9.检查端口
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 19849
/nginx
10.检查进程
[root@Node1 nginx-1.6.2]
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.网站访问
转自: http://www.centoscn.com/nginx/2015/0304/4782.html