Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> Linux系統常見問題解答 >> azure 雲上安裝部署nginx

azure 雲上安裝部署nginx

日期:2017/1/20 17:35:14      編輯:Linux系統常見問題解答
在安裝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

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帳號啟動成功了。
Copyright © Windows教程網 All Rights Reserved