centos6.9编译安装nginx
1、安装nginx所需的依赖包:
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel
2、下载nginx安装包
wget http://nginx.org/download/nginx-1.10.3.tar.gz
3、解压下载的安装包
tar -zxvf nginx-1.10.3.tar.gz
4、cd /opt/nginx-1.10.3
5、编译nginx相关参数
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
--with-http_stub_status_module
6、编译安装
make && make install
7、启动nginx
/usr/sbin/nginx
PS:如果启动报如下错误
nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory)
请执行 mkdir -p /var/tmp/nginx/client
再次启动。
8、查看nginx是否启动成功
ps -ef|grep nginx
9、打开浏览器输入http://nginx安装的服务器IP/
10、 如不能打开此页面请关闭防火墙
/etc/init.d/iptables stop