Nginx是一款輕量級的Web 服務(wù)器/反向代理服務(wù)器及電子郵件(IMAP/POP3)代理服務(wù)器,并在一個BSD-like 協(xié)議下發(fā)行。由俄羅斯的程序設(shè)計師Igor Sysoev所開發(fā),供俄國大型的入口網(wǎng)站及搜索引擎Rambler(俄文:Рамблер)使用。其特點是占有內(nèi)存少,并發(fā)能力強(qiáng),事實上nginx的小文件并發(fā)能力在同類型的網(wǎng)頁服務(wù)器中表現(xiàn)較好。
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 |
如果出現(xiàn)
. /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 |
檢查發(fā)現(xiàn)是沒有運行用戶,新增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.檢查進(jìn)程
[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.網(wǎng)站訪問
本文出自 “楓林晚” 博客,請務(wù)必保留此出處http://fengwan.blog.51cto.com/508652/1617167
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。