# #下载nginx源码:
wget http://nginx.org/download/nginx-1.7.8.tar.gztar-xv-f nginx-1.7.8.tar.gz-c/usr/local/src/
# #安装编译环境和必须的组件:
Yum Groupinstall ' development Tools ' yum install pcre pcre-devel zlib zlib-devel OpenSSL openssl-devel gcc gcc-c++ perl per L-devel Perl-extutils-embed.noarch
# #创建nginx用户和组:
Groupadd-r nginxuseradd-s/sbin/nologin-g nginx-c ' nginx Web server '-R nginx
# #创建用于存放临时数据的目录:
Mkdir-p/var/tmp/nginx/tmp
# #编译安装nginx:
./configure --prefix=/usr/local/nginx \ #设置nginx的根目录--conf-path=/etc/nginx/nginx.conf \# Set the path to the Nginx configuration file--error-log-path=/var/log/nginx/error.log \ #设置错误日志的路径--http-log-path=/var/log/nginx/ Access.log \ #设置访问日志的路径--http-client-body-temp-path=/var/tmp/nginx/tmp/client_body \# Sets the location of the temporary file where the client HTTP request is stored--http-proxy-temp-path=/var/tmp/nginx/tmp/proxy \ #nginx作为反向代理时, The location of the HTTP packets generated by the upstream server is temporarily stored--http-fastcgi-temp-path=/var/tmp/nginx/tmp/fastcgi \# FastCGI where temporary files are used--http-uwsgi-temp-path=/var/tmp/nginx/tmp/uwsgi \ #uWSGI Location of temporary files used--http-scgi-temp-path=/var/tmp/nginx/tmp/scgi \ #SCGI所使用临时文件的存放位置--with-http_ssl_module \ #安装http ssl module. Rely on the OpenSSL open source software--with-http_flv_module \ #安装http flv module. So that the client can watch, drag the FLV video--with-http_mp4_module \ #安装http the mp4 module. So that the client can watch, drag MP4 video--with-http_gzip_static_module \ #安装http the gzip static module. If you use the Gzip module to compress some documents and then return them to the client, the Gzip static module can check if there is a. gz file in the same location before gzip compression, and if so, return directly. This way, you canTo pre-do the server on the compression of the document, to the CPU offload--with-http_perl_module \ #安装http perl module. Make Nginx support perl script--with-ld-opt= "-wl,-e" \ #编译最终的可执行文件时加入一些第三方库. --with-mail \ #安装邮件服务器反向代理模块, so that Nginx can reverse proxy IMAP, POP3, SMTP and other Protocols--with-mail_ssl_module \ #安装mail  SSL module. This module enables the use of IMAP, POP3, smtp and other protocols based on the SSL/TLS protocol. Relies on the OpenSSL library--with-http_stub_status_module \ #安装http stub status module. This module allows the running nginx*** to count the pages for the associated concurrent connection, the requested information--user=nginx \ #指定Nginx the user to which the worker process is running. Note: Do not set the user who started the worker process to root, and the master process has the ability to stop/start worker processes when the worker process fails--group=nginx# specifies the group to which the Nginx worker process is running
Make && make install
# #安装完后可再检查一下安装的一些信息, as follows:
#/usr/local/nginx/sbin/nginx-v
Nginx version:nginx/1.7.8
Built by GCC 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)
TLS SNI Support Enabled
Configure arguments:--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--http-client-body-temp-path=/var/tmp/nginx/tmp/client_body- -http-proxy-temp-path=/var/tmp/nginx/tmp/proxy--http-fastcgi-temp-path=/var/tmp/nginx/tmp/fastcgi-- Http-uwsgi-temp-path=/var/tmp/nginx/tmp/uwsgi--http-scgi-temp-path=/var/tmp/nginx/tmp/scgi--with-http_ssl_ Module--with-http_flv_module--with-http_mp4_module--with-http_gzip_static_module--with-http_perl_module-- With-ld-opt=-wl,-e--with-mail--with-mail_ssl_module--with-http_stub_status_module--user=nginx--group=nginx
# #测试一下nginx能否启动 (mainly to see if the configuration file is correct):
#/usr/local/nginx/sbin/nginx-t
Nginx:the configuration file/etc/nginx/nginx.conf syntax is OK
Nginx:configuration file/etc/nginx/nginx.conf Test is successful
# #为了在使用nginx命令的时不用每次都输入绝对路径, you can modify the PATH environment variable by:
# Vim/etc/profile
Add to:
Path=${path}:/usr/local/nginx/sbin
# #如果只想对本用户生效可修改
# Vim ~/.bash_profile
Modify:
Path= $PATH: $HOME/bin:/usr/local/nginx/sbin
This article is from the "Silver Kay Blog" blog, make sure to keep this source http://yinkai.blog.51cto.com/3813923/1591128
Rhel/centos install nginx under the compiler