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.
1、 GCC
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-essentialapt-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++
2、PCRE
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
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ Download the latest PCRE source package, use the following command to compile and install the PCRE package download:
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34./configure
make
make install
3、ZLIB
** install the zlib Library**
http://zlib.net/Zlib-1.2.8.tar.gz download the latest zlib source package, use the following command to compile and install the zlib package download:
cd /usr/local/src
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gzcd zlib-1.2.8./configure
make
make install
4、SSL
installation SSL (some default VPS no SSL)
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、Nginx
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:
- 1
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
- 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.
--with-openssl=/usr/local/src/openssl-1.0.1c
- 3
make
make install
- 4
--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 bootTo 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 1make[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-essentialmake clean./configuremake
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 libraryinto the system, or build the OpenSSL library statically from the sourcewith nginx by using --with-openssl=<path> option.
According to the installation or fourth step methodUbuntu
apt-get install opensslapt-get install libssl-dev
CentOS
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:
--prefix=path defines a directory, to store the file on the server, the installation of the directory is nginx. Use the default /usr/local/nginx.
The path to the
--sbin-path=path setup nginx executable file, the default is prefix/sbin/nginx.
--conf-path=path settings in the nginx.conf configuration file path. Nginx allows the use of different configuration file to start, through the command line -c options. The default is prefix/conf/nginx.conf.
--pid-path=path set nginx.pid file, the main process of storage process of no.. After the installation is complete, can change the file name, use the PID command in the nginx.conf configuration file. By default, the file name prefix/logs/nginx.pid.
--error-log-path=path set the main errors, warnings, and diagnostic file name. After the installation is complete, can change the file name, use the nginx.conf configuration file in error_log instruction. By default, the file name prefix/logs/error.log.
The name
--http-log-path=path set the main request the HTTP server log file. After the installation is complete, can change the file name, use the nginx.conf configuration file in access_log instruction. By default, the file name prefix/logs/access.log.
--user=name sets the nginx worker process user. After the installation is complete, the name can be changed at any time using in the nginx.conf configuration file in user instruction. The default user name is nobody.
User group
--group=name set the nginx worker process. After the installation is complete, the name can be changed at any time using in the nginx.conf configuration file in user instruction. The default for non privileged users.
--with-select_module --without-select_module enable or disable the construction of a module to allow the server to use Select () method. This module will automatically set up, if the platform does not support kqueue, epoll, or rtsig/dev/poll.
--with-poll_module --without-poll_module enable or disable the construction of a module to allow the server to use poll () method. This module will automatically set up, if the platform does not support kqueue, epoll, or rtsig/dev/poll.
--without-http_gzip_module — Response module does not compile the compression of the HTTP server. Compile and run this module, zlib Library.
--without-http_rewrite_module does not compile the rewrite module. Compile and run the module requires PCRE library support.
--without-http_proxy_module — Does not compile the http_proxy module.
--with-http_ssl_module — Use the HTTPS protocol module. By default, this module is not construction. The establishment and operation of this module of the OpenSSL library is required.
--with-pcre=path — The source path set PCRE Library. PCRE library source code (version 4.4 - 8.30) need to be downloaded from the PCRE web site and decompression. The rest of the work is the Nginx / configure and make to complete the. Regular expressions are used in the location command and ngx_http_rewrite_module module.
--with-pcre-jit —Compile PCRE contains "just-in-time compilation" (1.1. 12, pcre_jit directive).
--with-zlib=path —The source path set zlib library. To download from the zlib (version 1.1.3 - 1.2.5) and decompression. The rest of the work is the Nginx / configure and make. The ngx_http_gzip_module module using zlib .
--with-cc-opt=parameters — Set additional parameters will be added to the CFLAGS variable. For example, need to use when you use the PCRE library on the FreeBSD:
--with-cc-opt=" -I /usr/local/include. Such as the need to increase the select. (the number of) supported file:
--with-cc-opt="-D FD_SETSIZE=2048".
--with-ld-opt=parameters —Set additional parameters, which will be used in the link during the. For example, when using the system in the FreeBSD PCRE library, should be specified:
--with-ld-opt="-L /usr/local/lib".
Typical examples (here in order to show the need to write in a multi line, implementation content needs to be on the same line)
./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=../pcre-4.4
--with-zlib=../zlib-1.1.3