在Linux上面编译和安装Nginx服务器需要的条件:
磁盘空间: 10M以上的剩余空间,nginx安装完毕后会占据大概4MB左右的空间,实际的磁盘空间需求会因为便宜设置和是否安装第三方模块而有所不同。
依赖包安装:
gcc # Linux许上软件安装编译工具:支持c、c++、Objective-c、Fortran、Java语言的编译。
gcc-c++
automake #自动创建功能完善的 Makefile(编译)
autoconf #自动创建功能完善的 Makefile(配置)
zlib #第三方扩展(gzip)支持
zlib-devel
openssl #第三方扩展SSL
openssl-devel
pcre #rewrite模块需要的pcre库支持
pcre-devel
以下是安装这些库文件的Linux shell 指令:
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel
安装前配置(注意配置文件和pid文件位置的位置)
./configure
--prefix=/usr/local/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/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--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-pcre
#如果出现如下信息,表明安装成功!
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/tmp/nginx/client/"
nginx http proxy temporary files: "/var/tmp/nginx/proxy/"
nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi/"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
然后执行编译和安装:
make && make install