$ yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel
$ cd /opt/
$ wget http://nginx.org/download/nginx-1.9.9.tar.gz
$ tar zxvf nginx-1.9.9.tar.gz
You can specify compilation parameters when compiling, refer to the end of the article: Common Compilation Options
$ cd nginx-1.9.9
$ ./configure
$ make
$ make && make install
Installed by default in /usr/local/nginx
There are four directories:
Check every time you modify the nginx configuration file
$ /usr/local/nginx/sbin/nginx -t
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
$ /usr/local/nginx/sbin/nginx
If you cannot access, check the firewall and turn off the firewall
Centos 6.x close iptables
$ service iptables status #Query firewall status command
$ service iptables stop #Close command
Centos 7.x close firewall
$ ssystemctl status firewalld.service #Check status
$ systemctl stop firewalld.service #Stop firewall
Enter the local IP in the browser and see the following content to prove that the installation is successful
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
$ /usr/local/nginx/sbin/nginx -s stop
$ /usr/local/nginx/sbin/nginx -s reload
. /configure \
- - prefix=/home/nginx \
- - sbin-path=/usr/sbin/nginx \
- - user=nginx \
- - group=nginx \
- - conf-path=/etc/nginx/nginx.conf \
- - error-log-path=/home/log/nginx/error.log \
- - http-log-path=/home/log/nginx/access.log \
- - with-http_ssl_module \
- - with-http_gzip_static_module \
- - with-http_stub_status_module \
- - with-http_realip_module \
- - pid-path=/home/run/nginx.pid \
- - with-pcre=/home/software/pcre-8.35 \
- - with-zlib=/home/software/zlib-1.2.8 \
- - with-openssl=/home/software/openssl-1.0.1i
- - prefix=/home/nginx \The root path of Nginx installation,All other paths depend on this option
- - sbin-path=/usr/sbin/nginx \The path of the nginx executable file (nginx)
- - user=nginx \The user the worker process is running on
- - group=nginx \The group in which the worker process runs
- - conf-path=/etc/nginx/nginx.conf \Point to the configuration file (nginx.conf)
- - error-log-path=/var/log/nginx/error.log \Point to the error log directory
- - http-log-path=/var/log/nginx/access.log \Set the name of the log file of the HTTP server of the main request
- - with-http_ssl_module \Use https protocol module. By default, this module is not built. The premise is openssl and openssl-devel is installed
- - with-http_gzip_static_module \Enable ngx_http_gzip_static_Module support (online real-time compression output data stream)
- - with-http_stub_status_module \Enable ngx_http_stub_status_Module support (get the working status of nginx since the last start)
- - with-http_realip_module \Enable ngx_http_realip_Module support (this module allows to change the client's IP address value from the request header, the default is off)
- - pid-path=/var/run/nginx.pid \Point to the pid file (nginx.pid)
Set the source path of the PCRE library, if it has been installed via yum, use –with-pcre finds the library file automatically. Use --with-pcre=PATH, you need to download the source code of the pcre library from the PCRE website (version 4.4 – 8.30) Decompress and leave the rest to Nginx./Configure and make to complete. Perl regular expressions are used in the location directive and ngx_http_rewrite_module module.
- - with-pcre=/home/software/pcre-8.35 \
Specify zlib (version 1.1.3 – 1.2.5) The source code decompression directory. The network transmission compression module ngx enabled by default_http_gzip_Need to use zlib when module.
- - with-zlib=/home/software/zlib-1.2.8 \
Point to the openssl installation directory
- - with-openssl=/home/software/openssl-1.0.1i
Recommended Posts