Nginx installation in centos is summarized. The source code package wget is first sent to the server from the official website, through some nginx configuration, compilation, and finally service registration./etc/init.d, You can use System V,serviceCommand to control nginx.
Download source code package
Go to the nginx official website to download it. You can pull it directly on the server by wget, http://nginx.org/en/download.html, and selectStable versionVersion
Prerequisites
Nginx compilation requires several prerequisites,GCC,PCRE,zlib,OpenSSL
GCCThis command is used to compile nginx. It is executed at http://zh.wikipedia.org/wiki/gcc.gccTo test whether GCC has been installed. Installation instructions:
yum install gcc
PCREIs nginx rewrite core modules need regular expression support, http://www.pcre.org/
yum install pcre pcre-devel
zlibProvide compression algorithm, http://zh.wikipedia.org/wiki/Zlib
yum install zlib zlib-devel
OpenSSLOpen-source SSL/TLS Module
yum install openssl openssl-devel
Module configuration
Nginx many modules, core modules are enabled by default, such as gzip, rewrite, etc., need to select the configuration to enable and disable, the official module description http://wiki.nginx.org/Modules
Currently, I only need to enable HTTPS access and register an independent user for nginx in advance, such as a userwww, ThroughconfigureTo configure
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module
Compile
make
After compilation, install and automatically copy some files to some specific directories of the configuration.
make install
You can send some parameters to the nginx binary execution file to return some information, such as nginx version information and manually enabled module information.
<prefix>/sbin/nginx -V## nginx version: nginx/1.4.6## built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ## TLS SNI support enabled## configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module
Register System Service, System V script
Script http://www.rackspace.com/knowledge_center/article/centos-adding-an-nginx-init-script
Create a file nginx in/etc/init. d/and configure its executable permissions.chmod +x ./nginx, Modify some prefix-related paths in the script according to your own situation.
chkconfig nginx on
In this way, nginx can be automatically started as the system starts.serviceTo manage nginx, suchservice nginx stop
Install nginx on centos