将nginx-1.8.0.tar.gz拷贝至linux服务器。linux
解压:nginx
tar -zxvf nginx-1.8.0.tar.gzc++
cd nginx-1.8.0服务器
一、 configureui
./configure --help查询详细参数(参考本教程附录部分:nginx编译参数)spa
参数设置以下:.net
./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. 编译安装code
makeblog
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 ?
若是是redhat系统,运行:
[plain] view plain copy print ?