Description: This tutorial mainly consists of the following three sections:
1. Source code Compiler installation Nginx
2. Source code Compilation install PHP and MySQL, Redis extension module
3. Configure the Virtual host
Download links are available in the installation package program, Welcome to use
Operating environment and preconditions: Ubuntu 12.04 LTS installed g++ compilation environment
All source program paths are located in: [Email Protected]:/home/shihai/desktop/nginx folder, as shown:
The program installation path is located under:/usr/local folder
Part I: Installing Nginx
Install the dependent Library Pcre Library, zlib library, SSL library before installing Nginx
Install the Pcre Library --for rewrite
Pcre Library
TAR–ZXVF pcre-8.21.tar.gz
CD pcre-8.21
./configure--prefix=/usr/local/pcre-8.21
Make
Make install
Install the Zlib library --for gzip compression
Zlib
TAR–ZXVF zlib-1.2.8.tar.gz
CD zlib-1.2.8
./configure--prefix=/usr/local/zlib-1.2.8
Make
Make install
Install SSL Library --Support SSL encryption
Openssl
TAR-ZXVF openssl-1.0.1c.tar.gz
CD openssl-1.0.1c
./config--prefix=/usr/local/openssl-1.0.1
Make
Make install
Installing the nginx-- Server Software
Nginx
TAR-ZXVF nginx-1.2.8.tar.gz
CD nginx-1.2.8
./configure--prefix=/usr/local/nginx-1.2.8 \
--with-pcre=. /pcre-8.21/\
--with-zlib=. /zlib-1.2.8/
Make
Make install
Setting Nginx-Initiated configuration files
/usr/local/nginx-1.2.8/sbin#./nginx-c/usr/local/nginx-1.2.8/conf/nginx.conf
/usr/local/nginx-1.2.8/sbin#./nginx-s Reload
View Nginx Process
Ps–ef|grep Nginx
Open localhost
When you see the content shown, the Nginx server has been successfully installed
Part II: Installing PHP and MySQL, Redis extension modules
Install ncurses-install MySQL pre-condition:
Ncurses
TAR-ZXVF ncurses-5.4.tar.gz
CD ncurses-5.4
./configure
Make
Make install
install MySQL--Used here is the source package compiled and installed
Mysql
TAR-ZXVF mysql-5.1.73.tar.gz
CD mysql-5.1.73
./configure--prefix=/usr/local/mysql-5.1.73
Make
Make install
Installing the Curl Library --for Curl requests
Curl Library
TAR-ZXVF curl-7.39.0.tar.gz
./configure--prefix=/usr/local/curl-7.39.0
Make
Make install
Install PHP
Php
TAR-ZXVF php-5.2.14.tar.gz
Gunzip php-5.2.14-fpm-0.5.14.diff.gz
Patch-d Php-5.2.14-p1 < Php-5.2.14-fpm-0.5.14.diff
CD php-5.2.14
./configure--prefix=/usr/local/php-5.2.14\
--ENABLE-FASTCGI \
--ENABLE-FPM \
--enable-sockets \
--enable-mbstring \
--with-mysql=/usr/local/mysql-5.1.73 \
--with-mysqli=/usr/local/mysql-5.1.73/bin/mysql_config\
--with-pdo-mysql=/usr/local/mysql-5.1.73 \
--with-curl=/usr/local/curl-7.39.0 \
--with-openssl=/usr/local/openssl-1.0.1 \
--with-mcrypt
Make
Make install
Start PHP-FPM using the following command:
/usr/local/php-5.2.14/sbin#./php-fpm Start
When you start PHP-FPM, it appears.
STARTINGPHP_FPM Dec 15:27:32.502790 [ERROR] fpm_unix_conf_wp (), line 124:pleasespecify user and group other than Root, Pool ' default '
Workaround: Go to directory:/usr/local/php-5.2.14/etc only need to modify php-fpm.conf
Unix User of processes
<!--<value name= "user" >nobody</value>-
Unix Group of processes
<!--<value name= "group" >nobody</value>-
Remove <!––>. As for User/group according to the actual situation changes (WWW).
Restart/usr/local/php-5.2.14/sbin#./php-fpm restart was successful.
To Install the Redis expansion module :
Redis
Unzip Phpredis-master.zip
exportpath=/usr/local/php-5.2.14/bin/: $PATH
Cp-r Phpredis-master php-5.2.14/ext/
CD Php-5.2.14/ext/phpredis-master
Phpize
./configure--with-php-config=/usr/local/php-5.2.14/bin/php-config
Make
Make install
Extension Library Path:/usr/local/php-5.2.14/lib/php/extensions/no-debug-non-zts-20060613/
Under the PHP extension library path, you can find the compiled Redis extension library file redis.so
Open the php.ini file under Path/usr/local/php-5.2.14/lib/php.ini, using the following command:
Vim php.ini
File content Quick Find (press "N" to find the next matching location), use the following command:
:? extension
After locating the specified location, insert the following:
Extension = redis.so
PHP will automatically load the redis.so file into the extension library path
If you do not find the php.ini file, you can search the file in full, using the following command:
Find/-name php.ini
The search results show that the/etc/php5/cli/php.ini file exists under this path and is then copied to/usr/local/php-5.2.14/lib using the following command:
/usr/local/php-5.2.14/lib# Cp/etc/php5/cli/php.ini php.ini
You need to restart PHP-FPM here to take effect, using the following command:
/usr/local/php-5.2.14/sbin#./PHP-FPM restart
Part III: Configuring NGINX Virtual Host
Create a new virtual host configuration file directory
/usr/local/nginx-1.2.8# mkdir vhosts
CD vhosts
Touch scott.qq.com.conf
Vim scottshi.qq.com.conf
Enter the following to configure a custom virtual host:
server {
Listen 8001;/* Listening port number */
server_name scott.qq.com;/* domain Name */
access_log/usr/local/nginxweb/htdocs/access.log;/* Site Access Log */
Location/{
root/usr/local/nginxweb/htdocs/;/* Page File directory */
Index index.php index.html index.htm;
}
Error_page 502 503 504/50x.html;/* Server error page */
Location =/50x.html {
root HTML;
}
# Pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000
Location ~ \.php$ {
Fastcgi_pass 127.0.0.1:9000; /*nginx Forwarding Request Address */
Fastcgi_index index.php;
Fastcgi_param script_filename/usr/local/nginxweb/htdocs/$fastcgi _script_name;
Include Fastcgi_params;
}
Location ~/\.ht {
Deny all;
}
}
After saving exit, enter Nginx configuration file nginx.conf
/usr/local/nginx-1.2.8/conf# Vim nginx.conf
In parallel to the default server level and within the HTTP hierarchy, add the following to make the custom virtual host effective:
include/usr/local/nginx-1.2.8/vhosts/*;
After saving the exit, restart the Nginx server and reload the configuration file using the following command:
/usr/local/nginx-1.2.8/sbin#./nginx–s Reload
To write a PHP test page:
Enter the directory/usr/local/nginxweb/htdocs/, create a new test.php file, and enter the test.php page content:
<?php
Phpinfo ();
?>
Save exit
Use the browser to access the following address:
scott.qq.com:8001/test.php
This page will show instructions for configuring PHP with various function modules including fastcgi, MySQL, curl, redis, etc.
Http://www.2cto.com/os/201411/350799.html
Nginx+php-fpm+mysql+redis source code Compilation Installation Guide