: This article describes how to install the Nginx compiling and deployment environment. if you are interested in the PHP Tutorial, refer to it. Nginx can be installed using the default packages on various platforms. This article describes how to use the source code for compilation and installation, including the specific compilation parameter information.
Before the official start, you need to install the gcc g ++ development library in the compiling environment in advance. you have installed it by default.
You can use the following commands to compile the ububtu platform environment:
Apt-get install build-essential
Apt-get install libtool
Use the following commands in the centos compiling environment:
Install make:
Yum-y install gcc automake autoconf libtool make
Install g ++:
Yum install gcc-c ++
Start Now
---------------------------------------------------------------------------
Generally, we need to install pcre and zlib first. The former is used to rewrite, and the latter is used to compress gzip.
1. select the source code directory
This document selects/usr/local/src.
Cd/usr/local/src
2. install the PCRE library
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ download the latest PCRE source package, use the following command to download the compilation and installation of PCRE package:
Cd/usr/local/src
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
Tar-zxvf pcre-8.35.tar.gz
Cd pcre-8.35
./Configure
Make // used for automatic compilation
Make install
3. install the zlib library
Http://zlib.net/zlib-1.2.8.tar.gz to download the latest zlib source package, use the following command to download the compilation and installation of zlib package:
Cd/usr/local/src
Wget http://zlib.net/zlib-1.2.8.tar.gz
Tar-zxvf zlib-1.2.8.tar.gz
Cd zlib-1.2.8
./Configure
Make
Make install
4. install ssl (ssl is not installed in some vps by default)
Cd/usr/local/src
Wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
Tar-zxvf openssl-1.0.1c.tar.gz
5. install nginx
Nginx generally has two versions: stable version and development version. you can select one of these two versions based on your purpose, the following describes how to install Nginx in the/usr/local/nginx Directory:
Cd/usr/local/src
Wget http://nginx.org/download/nginx-1.4.2.tar.gz
Tar-zxvf nginx-1.4.2.tar.gz
Cd nginx-1.4.2
./Configure -- sbin-path =/usr/local/nginx \
-- Conf-path =/usr/local/nginx. conf \
-- Pid-path =/usr/local/nginx. pid \
With-http_ssl_module \
-- With-pcre =/usr/local/src/pcre-8.35 \
-- With-zlib =/usr/local/src/zlib-1.2.8 \
-- With-openssl =/usr/local/src/openssl-1.0.1c
Or:
./Configure -- prefix =/usr/local/nginx -- with-http_stub_status_module -- with-http_ssl_module -- with-pcre =/root/soft/pcre-8.36
. /Configure -- prefix =/usr/local -- sbin-path =/usr/local/sbin/nginx -- conf-path =/etc/nginx. conf -- error-log-path =/var/log/nginx/error. log -- http-log-path =/var/log/nginx/access. log -- pid-path =/var/run/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/-- http-uwsgi-temp- path =/var/tmp/nginx/uwsgi -- http-scgi-temp-path =/var/tmp/nginx/scgi -- with-pcre -- with-file-aio -- with-http_image_filter_module;
Make
Make install
-- With-pcre =/usr/src/pcre-8.35 refers to the source code path of the pcre-8.35.
-- With-zlib =/usr/src/zlib-1.2.7 refers to the source code path of the zlib-1.2.7.
After the installation is successful, the/usr/local/nginx directory is as follows:
Fastcgi. conf koi-win nginx. conf. default
Fastcgi. conf. default logs scgi_params
Fastcgi_params mime. types scgi_params.default
Fastcgi_params.default mime. types. default uwsgi_params
Html nginx uwsgi_params.default
Koi-utf nginx. conf win-utf
6. start
Ensure that Port 80 of the system is not occupied by other programs. run the/usr/local/nginx command to start Nginx,
Netstat-ano | grep 80
If no result is found, run the command. If no result is found, ignore this step. (sudo must be enabled in ubuntu; otherwise, it can only run on the foreground)
Sudo/usr/local/nginx
Open the browser to access the IP address of this machine. if the browser displays Welcome to nginx! Nginx has been installed and runs successfully.
The above describes how to install the Nginx compilation and deployment environment, including some content, and hope to be helpful to anyone interested in the PHP Tutorial.