Centos+nginx+php+mysql detailed configuration (plot)

Source: Internet
Author: User
Tags bz2 diff install php php mysql

First, install MySQLAt present, the Web server has rarely run static pages, if you want to run a dynamic site that of course, can not be separated from the database, although in the previous article has written how to install MySQL, but feel for a long time not installed MySQL, now only the steps posted out, do not do too much to explain the #useradd mysql# Tar zxvf mysql-5.0.40.tar.gz#cd mysql-5.0.40#./configure--prefix=/usr/local/mysql#make && make install#/usr/ local/mysql/bin/mysql_install_db--user=mysql//Initialize MySQL database #chown-r mysql/usr/local/mysql/var#/usr/local/mysql/ Bin/mysqld_safe &//start mysql#/usr/local/mysql/bin/mysqladmin-u root password 123456//set MySQL password #cp support -files/my-medium.cnf/etc/my.cnf#echo "/usr/local/mysql/bin/mysqld_safe &" >>/etc/rc.localSecond, installation Pcre         Pcre is a regular expression used by Perl to enable the installed software to support regular expressions. By default, Nginx only handles static Web requests, which is HTML. If it is from a dynamic Web request, such as *.php, then Nginx will query the path according to the regular expression, then the *. PHP to PHP to handle #rpm-qa | The grep pcre             //query system has no pcre installed, General installation system is installed by default, so we have to delete the system comes with the #cp/lib/libpcre.so.0/          // Before deleting the system comes with the pcre, you need to back up libpcre.so.0 this file, because the RPM package is too strong, after the deletion of libpcre.so.0 this file when we installed Pcre is not installed #rpm-e--nodeps pcre-6.6-1.1         //Delete the system comes with pcre# tar zxvf pcre-8.00.tar.gz#cd pcre-8.00#cp/libpcre.so.0/lib/             // Remove the libpcre.so.0 copy of the system from the Pcre before the backup to the/lib directory #./configure        //configuration Pcre, Because Pcre is a library, and not such as Pache, PHP, Postfix and so on, so we install the default path can be installed, this will be installed in the other things to avoid some unnecessary trouble, after the execution of this will show that the above shows our configuration of the Pcre #make && make install   Third, install NginxOn the Internet, see a lot of people are very troublesome to install Nginx, configuration with a lot of options, do you really realize so multifunctional? The more I see the more depressed. This installation nginx if is to follow the above author step by step step down, install nginx only need to specify Nginx installation path can #tar ZXVF nginx-0.8.24.tar.gz#cd nginx-0.8.24#./configure-- Prefix=/usr/local/nginx//Here you only need to specify a path #make && make Install#/usr/local/nginx/sbin/nginx//Kai Nginx#echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.localnginx after the start of two processes, master process, the worker is a worker process, such as after starting Nginx, We can enter http://localhost view in the browser, such asiv. installation of PHP        since the installation of PHP, that GD is not rare, the installation of this GD is no longer described in 1, installation Libpng#tar XVF LIBPNG-1.2.10.TAR.TAR#CD libpng-1.2.10#./configure--prefix=/usr/local/png#make;make install#ln-s/usr/local/png/ lib/*/usr/lib/ 2, installation jpeg#mkdir/usr/local/jpeg#mkdir/usr/local/jpeg/bin#mkdir/usr/local/jpeg/lib#mkdir/usr/ Local/jpeg/include#mkdir/usr/local/jpeg/man#mkdir/usr/local/jpeg/man/man1#tar XVF JPEGSRC.V7.TAR.TAR#CD jpeg-7#./ Configure--prefix=/usr/local/jpeg--enable-shared--enable-static#make;make install#ln-s/usr/local/jpeg/lib/*/usr /lib/ 3, installing Freetype#tar xvf freetype-2.3.9.tar.tar#cd freetype-2.3.9#./configure--prefix=/usr/local/freetype# Make;make install 4, installation Fontconfig#tar zxvf FONTCONFIG-2.4.2.TAR.GZ#CD fontconfig-2.4.2#./configure--prefix=/ Usr/local/fontconfig--with-freetype-config=/usr/local/freetype/bin/freetype-config#make;make install 5, Installation Gd#tar zxvf gd-2.0.32.tar.gz#cd gd-2.0.32#./configure--prefix=/usr/local/gd--with-png=/usr/local/png--wiTh-jpeg=/usr/local/jpeg--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/fontconfig#cp/usr/local /png/include/png.h./#cp/usr/local/png/include/pngconf.h./#make; make install 6, install php              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, downloaded 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 as patches to php-5.3.0 #cd php-5.3.0#./configure--prefix=/usr/local/php--with-gd=/usr/ LOCAL/GD--with-jpeg-dir=/usr/local/jpeg--with-png-dir=/usr/local/png--with-freetype-dir=/usr/local/freetype-- With-mysql=/usr/local/mysql--enable-fastcgi--enable-fpm Note: nginx+php consolidation,--enable-fastcgi and--ENABLE-FPM must be enabled at the time of installation, These two options are what you have described above. After execution the system will prompt--enable-fastcgi is an unknown option, we do not have to ignore #make#make INSTALL#CP php.ini-dist/usr/local/php/etc/php.ini     Below we are going to start php-fpm#/usr/local/php/sbin/php-fpm start PHP-FPM when the error is reported above, because php-fpm himself does not know to run PHP with that user and group, So we have to modify a file, the comments in the file can be removed (open the file to delete the Red section), and then PHP-FPM will be nobody users and groups to run PHP.   #vi/USR/LOCAL/PHP/ETC/PHP-FPM.CONF #/USR/LOCAL/PHP/SBIN/PHP-FPM Start#ps-aux | grep php#echo "/usr/LOCAL/PHP/SBIN/PHP-FPM Start ">>/etc/rc.local    Five, the integration of Nginx and PHPAs already mentioned above, Nginx does not handle the request of Dynamic Web page, and Nginx will get the dynamic request to PHP, below we open nginx configuration file to see #vi/usr/local/nginx/conf/nginx.conf// The marked part is we want to modify the next look, Nginx already know how to get the request communicated to Php,nginx in the *.php request, will send the request through 9000 port to PHP. Let's get rid of these annotations, asNote: The above/usr/local/nginx/html is the path of our PHP site placementThen only nginx himself know how to find PHP not yet, but also need PHP know how to find Nginx,ps: You have seen the street on the jjmm date when there is not mutual understanding of each other, or do not know what method and the other joint? We don't have to worry about that, PHP-FPM has defined in the config file where to accept PHP requests, we can open the configuration file and see #vi/usr/local/php/etc/ Php-fpm.conf as shown, we have seen in the previous nginx is through the local Port 9000 PHP request forwarded to PHP, and we can see that PHP itself is from the local 9000 port listening data, Nginx and PHP complete the data request through the 9000 port of this machine.VI. TestingWe have in Nginx configuration file has defined the PHP site storage path, the path asked/usr/local/nginx/html below we in this directory to create a new PHP page test page, the file name is test.php, the following restart PHP and Nginx after ( Can be closed with the kill process, and then start) we enter http://localhost/test.php in the browser, the following interface is successful

Articles you may be interested in:
    • Parse the default installation path for Apache, PHP, and MySQL in CentOS
    • CentOS 6.4 Installation Configuration Lamp server (APACHE+PHP5+MYSQL)
    • CentOS 6.4 Installation Configuration Lnmp server (nginx+php+mysql)
    • Compile and install LNMP and configure PHP environment for CentOS 6.4 system specific steps
    • CENTOS6 steps to install PHP MySQL gd with Yum
    • CentOS 5.5 uses Yum to install lamp (PHP operating environment)
    • Linux+php+apache+oracle installation of Apache under the CentOS environment
    • Linux+php+apache+oracle Environment set up CentOS under the source code compilation and installation of PHP

Centos+nginx+php+mysql detailed configuration (plot)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.