Section reference: http://www.cnblogs.com/simpman/p/4151662.html
1, using the Linux system comes with the Yum command to install, upgrade the required library (this step is best to execute, anyway, there is nothing serious, execution side of the line)
sudo -s LANG=C yuminstallgcc gcc bzip2 bzip2-devel ncurses ncurses-devel Curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn Libidn-devel OpenSSL openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
2, Installation nginx1.7.8
1) First install the Nginx-dependent module :
Gzip module requires zlib library
Rewrite module requires Pcre library (required)
The SSL feature requires the OpenSSL library
(1) Installing the Pcre Library
Method One:
Get Pcre Compile the installation package and get the appropriate version on http://www.pcre.org/. Then copy to the/usr/local/src/directory under $ cd/usr/local/ $ tar-zxvf pcre2-10.00.tar.gz $ cd pcre2-10.00 $. Configure $ make $ make install
Method Two:
$ cd/usr/local/ $ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz $ tar-zxvf pcre2-10.00.tar.gz $ cd pcre2-10.00 $./configure $ make $ make install
(2) Installing the OpenSSL library
http://www.openssl.org/source/, the method is the same as above.
(3) Installing the Zlib Library
http://www.zlib.net/, the method is the same as above.
2) Install Nginx
Nginx generally has two versions, respectively stable and development version, according to the needs of the choice.
The installation of Nginx is very simple. By default, the compiled and installed Nginx contains most of the available modules. You can use the "./configure--help" option to set the usage of each module, such as an unwanted Http_ssi module, which can be closed by "--without-http_ssi_module", and, if necessary, "Http_perl module, you can install the module by using the "--with-http_perl_module" mode. The "Http_perl" module can be used to enable Nginx's nginxstatus function to monitor the current state of Nginx. Here is the installation process:
$ wget http://nginx.org/download/nginx-1.7.8.tar.gz $ tar zxvf nginx-1.7.8.tar.gz $ cd nginx-1.7.8 $./ Configure--with-http_stub_status_module--prefix=/usr/local/nginx $ make $ make install
Note: If the above dependent modules cannot be found at the time of installation, use--with-openssl=<openssl_dir> 、--with-pcre=<pcre_dir> 、--with-zlib=<zlib_dir > Specifies a dependent module directory.
"" "" "" in this, Nginx completed installation.
View Help for managing Nginx.
$/usr/local/nginx/sbin/nginx-h
We can enter http://192.168.1.204:80 in the browser to see if Nginx is working, default to 80 port
Or
Execute command: $ ps-a|grep nginx # If there is a return result stating that Nginx is running, the service has started
$/usr/local/nginx/sbin/nginx # start nginx(method one)
Or
Execute command : $ netstat-ano|grep # View Port occupancy status to determine if nginx is started, if
The port is only used by nginx
3) configuration file
(1) nginx.conf file (master configuration file)
The configuration file is under the /nginx/conf/ directory, where nginx.conf is the primary configuration file.
VI nginx.conf
in nginx.conf,
Top, userwww www # set nginx running users and Groups
# Global error log and PID file # # #
PID Logs/nginx.pid
Error_log Logs/error.log
##########################
Worker_process Indicates the number of worker processes, typically set to the CPU 's number of cores
Worker_connections represents the maximum number of connections per worker process
server{} block defines the virtual host
Listener Listening Port
server_name monitoring domain name
location{} is used to configure a matching URI ,location/{} matches any query, so the request begins with /
Root Specifies The resource lookup path for the corresponding URI, where the HTML is the relative path, and the complete /usr/local/nginx/html/
index specifies the name of the index file on the first page and can be configured with multiple spaces separated by a space. Search by order
* * The root path is /nginx/html/, under this directory:
50x.html for server error redirection
(2) Mime.types file
File extension with File Type mapping table,nginx sets the HTTP Request response Header based on the mapping relationship
The Content-type value. When it is not found in the mapping table, use The default value specified in the nginx.conf . default-type file .
eg , in nginx.conf file,
Include Mime.types;
Default_type Application/octet-stream
(3) Fastcgi_params file
Nginx configuration Fastcgi resolves when the fastcgi_params configuration file is called to pass the server variable, so
The values of these variables can be obtained in CGI
(4) fastcgi.conf file
Relative to the fastcgi_param file, only one more line:
Fastcgi_param script_filename $document _root$fastcgi_script_name;
This is done to prevent many people from using hard-coded methods when defining script_filename
(5) Uwsgi_params file
As with fastcgi_params , only the prefix is used Uwsgi_param
(6) Scgi_params file
As with fastcgi_params , only the prefix is used Scgi_param
(7) Koi-utf documents, Koi-win documents, Win-utf file
These three files are encoded with a translation mapping file that is used when outputting content to the client,
Change to another encoding
Koi-win:charset_map Koi8-r <-->windows-1251
Koi-utf:charset_map Koi8-r <-->utf-8
Win-utf:charset_map windows-1251 <-->utf-8
3. Install PHP
1) Installation
Because PHP-FPM has been added to the PHP kernel after php5.3.3. Older versions of PHP-FPM are installed in patch mode. We install the php-5.6.3 version.
$ wget http://cn2.php.net/get/php-5.6.3.tar.gz/from/this/mirror $ tar zxvf php-5.6.3.tar.gz $ cd php-5.6.3 $./configure--enable-fpm --with-mysql=/usr/local/mysql--prefix=/usr/local/php-5.6.3--without-pear
It is best to add --without-pear , to prevent the following operation error.
$ make
Execute make zend_extra_libs= '-liconv ' command If you are the last to make : ***[sapi|cli|php] Error 1 when performing the make operation.
$ make Install
Execute the above command if the make : ***[ext|phar|phar.php] Error 127 errors, then perform the operation:
$ vi/etc/ld.so.conf # #在该文件中加入一行:/usr/local/lib then run: $/sbin/ldconfig
At last
$ cp php.ini-development /usr/local/php-5.6.3/php.ini $ cp/usr/local/php-5.6.3/etc/php-fpm.conf.default /usr/local/php-5.6.3/etc/php-fpm.conf
"" "" at this point, PHP5.6.3 installation completed!
2) configuration
If the file does not exist, it prevents Nginx from sending the request to the back-end PHP-FPM module to avoid a malicious script injection attack. Set the configuration item cgi.fix_pathinfo in the php.ini file to 0 $ vim/usr/local/php/php.ini $ cgi.fix_pathinfo=0
Start PHP-FPM:
$/usr/local/bin/php-fpm View PHP-FPM supported startup options $/usr/local/bin/php-fpm-h
Let Nginx support PHP:
Modify Nginx.conf, vim/usr/local/nginx/conf/nginx.conf
Location/{ root html; Index index.php index.html index.htm;} Location ~* \.php$ { fastcgi_index index.php; Fastcgi_pass 127.0.0.1:9000; Include Fastcgi_params; Fastcgi_param Script_filename $document _root$fastcgi_script_name; Fastcgi_param script_name $fastcgi _script_name;}
Where Red is the modified part.
If the modification is not correct, 404 error will be reported.
Restart Nginx, you can use it.
One, Linux under the nginx1.7.8+php5.6.3 environment configuration