CentOS源码编译安装Nginx
安装编译用到的软件:
- yum install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel
现在到http://nginx.org/en/download.html下载最新版本的Nginx并安装。
- cd /usr/local/src
- wget http://nginx.org/download/nginx-1.0.4.tar.gz
- tar -zxvf nginx-0.7.65.tar.gz
- cd nginx-0.7.65
- ./configure \
- --user=nginx \
- --group=nginx \
- --prefix=/usr/share \
- --sbin-path=/usr/sbin/nginx \
- --conf-path=/etc/nginx/nginx.conf \
- --error-log-path=/var/log/nginx/error.log \
- --http-log-path=/var/log/nginx/access.log \
- --pid-path=/var/log/run/nginx.pid \
- --lock-path=/var/log/lock/subsys/nginx \
- --with-http_ssl_module \
- --with-http_realip_module \
- --with-http_addition_module \
- --with-http_sub_module \
- --with-http_dav_module \
- --with-http_flv_module \
- --with-http_gzip_static_module \
- --with-http_stub_status_module \
- --with-http_perl_module \
- --with-mail \
- --with-mail_ssl_module
- make
- make install
更多的编译选项请参考:http://wiki.nginx.org/NginxInstallOptions
为Nginx建立用户
- /usr/sbin/useradd -c "Nginx user" -s /bin/false -r -d /var/lib/nginx nginx
运行Nginx
- /usr/sbin/nginx
配置文件在:
- /etc/nginx/nginx.conf
- echo "NGINX_CONF_FILE=/etc/nginx/nginx.conf" > /etc/sysconfig/nginx