azure 雲上安裝部署nginx


在安裝nginx之前可以先安裝libevent,安裝libevent步驟如下:
1.下載libevent:
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz


2.解壓libevent:
tar -zxvpf libevent-2.0.21-stable.tar.gz


3.進入解壓目錄:
cd libevent-2.0.21-stable


4.指定安裝目錄:
./configure --prefix=/usr/local/libevent-2.0.21


5.安裝libevent:
make
make install


本blog來源地址:http://blog.csdn.net/mchdba/article/details/50967970,不經過原作者mchdba(黃杉)允許,謝絕轉載。


6,安裝nginx
yum install -y openssl*
tar -xvf pcre-8.31.tar.gz -C /usr/local/
tar -xvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure   --with-http_ssl_module --prefix=/usr/local/nginx   --with-pcre=/usr/local/pcre-8.31 --with-http_stub_status_module 


pS:首席編譯腳本 1.121/122
yum -y install gcc automake autoconf libtool make
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_realip_module --with-http_gzip_static_module  --with-http_ssl_module --with-pcre=/usr/local/pcre-8.31


make
make install


7,查看編譯參數:

/usr/local/nginx/sbin/nginx -V 



8,使用nginx帳號啟動
setcap CAP_NET_BIND_SERVICE=+ep /usr/local/nginx/sbin/nginx
要先用root帳號運行 /usr/local/nginx/sbin/nginx 啟動,然后kill掉nginx進程
再切換到nginx帳號執行service nginx restart或者/usr/local/nginx/sbin/nginx 啟動,就會看到進程是用nginx帳號在啟動了



9,報錯調試
[nginx@lb_net_1 ~]$ service nginx start
start nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx is running[nginx@lb_net_1 ~]$
[nginx@lb_net_1 ~]$ exit
logout
[root@lb_net_1 conf]# 
[root@lb_net_1 conf]# sudo chown root:wheel /usr/local/nginx/sbin/nginx 
[root@lb_net_1 conf]# sudo chmod u+s /usr/local/nginx/sbin/nginx
[root@lb_net_1 conf]# 
[root@lb_net_1 conf]# su - nginx 
[[root@lb_net_1 conf]# sudo chmod u+x /usr/local/nginx/sbin/nginx
之后進入nginx帳號啟動成功了。

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com