将nginx-1.8.0.tar.gz拷贝至linux服务器。
解压:
tar -zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0
1、 configure
./configure --help查询详细参数(参考本教程附录部分:nginx编译参数)
参数设置如下:
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
2. 编译安装
make
make install
3.安装成功后检查
注意:上边将临时文件目录指定为/var/temp/nginx,需要在/var下创建temp及nginx目录
遇到错误:
./configure: error: the HTTP rewrite module requires the PCRE library
解决:
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
其间可能碰到错误:
错误①:依赖软件prce,ssl,zlib未安装错误
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
需要安装pcre包
Pcre
tar zxvf pcre-8.12.tar.gz
cd pcre-8.12
./configure
make
make install
nginx 启动
./nginx -c /usr/local/nginx/conf/nginx.conf
在网址上输入:192.168.152.131:80 //192.168.152.131是我虚拟机linux的ip
错误②:pcre3编译报错:libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
解决方法:
该错误是由于缺少 gcc-c++ 包。
如果是debian系统,运行:
[plain] view plain copy print ?
- apt-get install gcc g++ autoconf
如果是redhat系统,运行:
[plain] view plain copy print ?
- yum -y install gcc-c++
来源:oschina
链接:https://my.oschina.net/u/2450896/blog/672250