nginx 编译安装

时间:2022-06-13 12:11:00

一、安装nginx时必须先安装相应的编译工具
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

zlib:nginx提供gzip模块,需要zlib库支持
openssl:nginx提供ssl功能
pcre:支持地址重写rewrite功能

二、tar -zxvf nginx-1.2.8.tar.gz

三、cd nginx-1.2.8

四、./configure \
--prefix=/usr/local \
--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_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

五、make && make install

六,进入默认的安装目录 /usr/local/nginx/conf 把里面的配置文件改成本地源的位置就可以访问到本地源的内容(本地源的配置参见上篇文章)
nginx 编译安装
七,启动nginx( ./sbin/nginx )通过浏览器访问

nginx 编译安装