At present, the Web server has very few run static page, if you want to run dynamic Web site that of course can not be separated from the database, although in the previous article has written how MySQL is installed, but feel a long time did not install MySQL, now only to post the steps, do not do too much explaining the
#tar ZXVF mysql-5.0.40.tar.gz
#/usr/local/mysql/bin/mysql_install_db--user=mysql//initialization of MySQL database
#/usr/local/mysql/bin/mysqld_safe &/Start MySQL
#/usr/local/mysql/bin/mysqladmin-u root password 123456//set MySQL password
#echo "/usr/local/mysql/bin/mysqld_safe &" >>/etc/rc.local
Pcre is a regular expression used in Perl to allow the installed software to support regular expressions. By default, Nginx handles only static Web requests, that is, HTML. If it is from a dynamic Web request, such as *.php, then Nginx will query the path according to the regular expression and then the *. PHP is given to PHP to handle
#rpm-qa | grep pcre//query system has not installed Pcre, the general installation system is the default installed, so we have to delete the system from the
#cp/lib/libpcre.so.0///before removing the pcre from the system, you should back up libpcre.so.0 this file, because the RPM package is too relevant, we can not install pcre when we do not libpcre.so.0 this file when we delete it.
#rpm-E--nodeps pcre-6.6-1.1//delete system with Pcre
# tar ZXVF pcre-8.00.tar.gz
#cp/libpcre.so.0/lib///libpcre.so.0 copy to/lib directory before we remove the pcre from the system
#./configure//Configuration Pcre, because Pcre is a library, not like Pache, PHP, Postfix and so on, so we choose the default path when installing, this will be installed in the back of other things to avoid unnecessary trouble, After this is done, the following figure appears, showing our configuration of the Pcre
Iii. installation of Nginx
On the Internet, see a lot of people installed nginx very troublesome, configuration with a lot of options, I ask you really realize so multi-functional mody? The more I watched the more depressed. The installation nginx if it is to follow the steps of the author Step-by-Step down, installation nginx only need to specify Nginx installation path can be
#tar ZXVF nginx-0.8.24.tar.gz
#./configure--prefix=/usr/local/nginx//Here you only need to specify a path in this link
#echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local
Nginx started with two processes, master main process, worker for the work process, the following figure
After starting Nginx, we can enter http://localhost view in the browser, the following figure
Since the installation of PHP, that GD is indispensable, this GD installation is no longer described
#tar XVF Libpng-1.2.10.tar.tar
#tar XVF Jpegsrc.v7.tar.tar
#tar XVF Freetype-2.3.9.tar.tar
4. Installation Fontconfig
#tar ZXVF fontconfig-2.4.2.tar.gz
#tar ZXVF gd-2.0.32.tar.gz
This place is the most important place because by default Nginx and PHP are a little bit out of touch with each other. In the past, a lot of friends have built apache+php,apache+php compiled after the module file, and nginx+php need PHP to generate executable files, so to use fastcgi technology to achieve n Ginx and PHP integration, This is as long as our installation is enabled fastcgi. This time we installed PHP not only used fastcgi, but also used php-fpm such a dongdong, PHP-FPM plainly is a management of a fastcgi manager, it as a PHP plug-in pure in, In the installation of PHP to use PHP-FPM need to php-fpm in the form of patches installed into PHP, and PHP to be consistent with the PHP-FPM version, this is necessary, remember!
First we download PHP and php-fpm to the same directory, this time for php-5.3.0.tar.bz2 and php-5.3.0-fpm-0.5.12.diff.gz, download to the same directory
#tar XVF php-5.3.0.tar.bz2
#gzip-CD php-5.3.0-fpm-0.5.12.diff.gz | Patch-d PHP-5.3.0-P1//Add php-5.3.0-fpm-0.5.12.diff.gz to php-5.3.0 in patch form
Note: nginx+php consolidation must be enabled when installing--enable-fastcgi and--ENABLE-FPM, both options are described above. After execution, the system will prompt--enable-fastcgi is an unknown option, we do not have to ignore
Now we're going to start php-fpm.
This error is reported when you start PHP-FPM, because PHP-FPM doesn't know to run PHP with that user and group, so we have to modify a file to remove the comments from the file (open the file to delete the red part), Then PHP-FPM will run PHP with nobody users and groups.
#echo "/usr/local/php/sbin/php-fpm Start" >>/etc/rc.local
V. Integrating Nginx with PHP
As has been said above, Nginx not handle the request of dynamic Web pages, and Nginx will get the dynamic request to PHP, the following we open Nginx configuration file to see
#vi/usr/local/nginx/conf/nginx.conf//Marked part is the one we want to revise later.
Looking at the graph, Nginx already knows how to get the requested message to Php,nginx when *.php request is received, the request passes through 9000 ports to PHP. Let's get rid of these annotations, as shown below
Note: The/usr/local/nginx/html above is the path to our PHP site placement
Then only nginx himself know how to find PHP is not good, but also need PHP know how to find Nginx,ps: You see the street on the jjmm date is not mutual know each other, or do not know what method and the other joint? We don't need to worry about that, PHP-FPM has defined in the configuration file where to accept the PHP request, we can open the configuration file to see
As shown in the figure above, we have already seen nginx through the local 9000 port to the PHP request to PHP, and the above figure we can see that PHP is from the local 9000-port listening data, Nginx and PHP through the local 9000 port to complete the data request.
We have already defined the PHP site's storage path in the Nginx configuration file, the path asks/usr/local/nginx/html
Below we create a new PHP page test page in this directory, the file name is test.php, the contents are as follows
After restarting PHP and Nginx (you can kill the process by shutting it down and then starting) we enter http://localhost/test.php in the browser and the following interface is successful