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

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帐号启动成功了。

相关内容

    暂无相关文章