Generally we need to first install Pcre, Zlib, the former in order to rewrite rewrite, the latter in order to gzip compression.
1. Select the source directory
Can be any directory, this article is selected/USR/LOCAL/SRC
Cd/usr/local/src
2. Installing the Pcre Library
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Download the latest pcre source package, download the compile and install the Pcre package using the command below:
Cd/usr/local/srcwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz TAR-ZXVF PCRE-8.34.TAR.GZCD Pcre-8.34./configuremakemake Install
3. Installing the Zlib Library
http://zlib.net/zlib-1.2.8.tar.gz Download the latest zlib source package, download the compile and install the zlib package using the command below:
Cd/usr/local/srcwget HTTP://ZLIB.NET/ZLIB-1.2.8.TAR.GZTAR-ZXVF ZLIB-1.2.8.TAR.GZCD Zlib-1.2.8./configuremakemake Install
4. Install SSL (some VPS does not install SSL by default)
Cd/usr/local/srcwget HTTP://WWW.OPENSSL.ORG/SOURCE/OPENSSL-1.0.1C.TAR.GZTAR-ZXVF openssl-1.0.1c.tar.gz
5. Installing Nginx
Nginx generally has two versions, the stable version and the development version, you can choose one of these two versions according to your purpose, below is the detailed steps of installing nginx into the/usr/local/nginx directory:
Cd/usr/local/srcwget HTTP://NGINX.ORG/DOWNLOAD/NGINX-1.4.2.TAR.GZTAR-ZXVF NGINX-1.4.2.TAR.GZCD nginx-1.4.2./ Configure--sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf--pid-path=/usr/local/nginx/ Nginx.pid--with-http_ssl_module--with-pcre=/usr/local/src/pcre-8.34--with-zlib=/usr/local/src/zlib-1.2.8-- With-openssl=/usr/local/src/openssl-1.0.1cmakemake Install
--with-pcre=/usr/src/pcre-8.34 refers to the pcre-8.34 source path.
--with-zlib=/usr/src/zlib-1.2.7 refers to the zlib-1.2.7 source path.
After the installation is successful, the/usr/local/nginx directory is as follows
fastcgi.conf koi-win nginx.conf.defaultfastcgi.conf.default logs Scgi_paramsfastcgi_params mime.types scgi_params.defaultfastcgi_params.default mime.types.default uwsgi_paramshtml Nginx uwsgi_params.defaultkoi-utf nginx.conf Win-utf
6. Start
Ensure that the 80 port of the system is not occupied by other programs, run the/usr/local/nginx/nginx command to start Nginx,
Netstat-ano|grep 80
If the results are not found after the execution, the result is ignored this step (Ubuntu must be started with sudo, or can only be run in the foreground)
Sudo/usr/local/nginx/nginx
Open the browser to access the IP of this machine if the browser appears Welcome to nginx! Indicates that Nginx is installed and running successfully.
Nginx source code compilation and installation