The Nginx installation

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Nginx can use the platform default package to install, this paper is to introduce the use of source code compiler installation, including compiling parameters of concrete information.

Before the official start, the compiler environment GCC g+ + to develop library, advance installed, here you have it installed by default.

The ububtu platform compiler can use the following command

apt-get install build-essential
apt-get install libtool

CentOS platform compiler environment using the following command

Install make:

yum -y install gcc automake autoconf libtool make

Install g++:

yum install gcc gcc-c++

Following a formal start
We all need to install PCRE, zlib, the former to override the rewrite, the latter for gzip compression.
1 selected source directory
Can be any directory, this paper selected is/usr/local/src

cd /usr/local/src

2 install the PCRE Library Download the latest PCRE source package, use the following command to compile and install the PCRE package download:

cd /usr/local/src
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34
make install

3 install the zlib Library download the latest zlib source package, use the following command to compile and install the zlib package download:

cd /usr/local/src

tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
make install

4 installation SSL (some default VPS no SSL)

cd /usr/local/src
tar -zxvf openssl-1.0.1c.tar.gz

Installing nginx 5

Nginx generally has two versions, which are stable and development, you can according to your purpose to select the two version of the one, the following is to install Nginx on the detailed steps under the /usr/local/nginx directory:

cd /usr/local/src
tar -zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2

./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/ \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.34 \
--with-zlib=/usr/local/src/zlib-1.2.8 \

make install

--with-pcre=/usr/src/Pcre-8.34 refers to the source path pcre-8.34.
--with-zlib=/usr/src/Zlib-1.2.7 refers to the source path zlib-1.2.7.

After the success of the installation directory /usr/local/nginx

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 boot
To ensure that the 80 port system is not being used by another program, run the /usr/local/nginx/nginx command to start the Nginx,

netstat -ano|grep 80

If the implementation does not check the results, this step is ignored (Ubuntu must use sudo to start, otherwise can only run in the foreground)

sudo /usr/local/nginx/nginx

Open a browser to access this IP machine, if the browser Welcome to nginx! That Nginx is installed and running successful.

Here nginx is installed, if only handle static HTML will not continue the installation

If you need to deal with PHP script, you also need to install the php-fpm.

The following installation debugging

Attached: possible error and some help information

1.1 compiler PCRE error

libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/usr/local/src/pcre-8.34'
make: *** [all] Error 2

Solution: install the g+ +, don't forget to configure

apt-get install g++
apt-get install build-essential
make clean

1.2 make error

make: *** No rule to make target `build', needed by `default'. Stop.
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

According to the installation or fourth step method

apt-get install openssl
apt-get install libssl-dev


yum -y install openssl openssl-devel

The 2.nginx compile option

Make is used to compile the instruction, which are read from the Makefile, then compile.

Make install is used to install, also it reads the instructions from the Makefile to the specified location, the installation.

The configure command is used to detect the target characteristics of your installation platform. It defines the various aspects of the system, including the nginx allowed connecting method of processing using, for example, it will detect your Is it right? With CC or GCC, not CC or GCC, which is a shell script, at the end of the execution, it will create a Makefile file. The nginx configure command to support the following parameters:

Typical examples (here in order to show the need to write in a multi line, implementation content needs to be on the same line)


NewestThe earliestThe heat
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Stephen at March 04, 2014 - 2:15 PM