CentOS源码编译安装Nginx

安装编译用到的软件:

  1. yum install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel

现在到http://nginx.org/en/download.html下载最新版本的Nginx并安装。

  1. cd /usr/local/src
  2. wget http://nginx.org/download/nginx-1.0.4.tar.gz
  3. tar -zxvf nginx-0.7.65.tar.gz
  4. cd nginx-0.7.65
  5. ./configure \
  6.     --user=nginx \
  7.     --group=nginx \
  8.     --prefix=/usr/share \
  9.     --sbin-path=/usr/sbin/nginx \
  10.     --conf-path=/etc/nginx/nginx.conf \
  11.     --error-log-path=/var/log/nginx/error.log \
  12.     --http-log-path=/var/log/nginx/access.log \
  13.     --pid-path=/var/log/run/nginx.pid \
  14.     --lock-path=/var/log/lock/subsys/nginx \
  15.     --with-http_ssl_module \
  16.     --with-http_realip_module \
  17.     --with-http_addition_module \
  18.     --with-http_sub_module \
  19.     --with-http_dav_module \
  20.     --with-http_flv_module \
  21.     --with-http_gzip_static_module \
  22.     --with-http_stub_status_module \
  23.     --with-http_perl_module \
  24.     --with-mail \
  25.     --with-mail_ssl_module
  26. make
  27. make install

更多的编译选项请参考:http://wiki.nginx.org/NginxInstallOptions
为Nginx建立用户

  1. /usr/sbin/useradd -c "Nginx user" -s /bin/false -r -d /var/lib/nginx nginx

运行Nginx

  1. /usr/sbin/nginx

配置文件在:

  1. /etc/nginx/nginx.conf
  1. echo "NGINX_CONF_FILE=/etc/nginx/nginx.conf" > /etc/sysconfig/nginx
标签:CentosNginx 发布于:2019-10-05 20:20:14