Lamp compiled and installed (FPM-mode connection PHP and httpd)

Source: Internet
Author: User
Tags php server php and mysql

This article focuses on the experiment where PHP connects httpd to work in an fpm manner. In the case of PHP's FPM mode, the simple point is that PHP can serve as a standalone server instead of working as a HTTPD program module in the same way as in the previous article. This time I will install each service separately on a single server to work.

First, topology diagram: Picture obscured, MySQL (10.0.0.105)

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/3F/81/wKiom1PKAmPCLH0RAAOD2MY9p38212.jpg "title=" Qq20140719133021.png "width=" 851 "height=" 640 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:851px;height:640px; "alt = "Wkiom1pkampclh0raaod2my9p38212.jpg"/>


Second, the platform and Software

System: centos6.4 2.6.32-358.el6.x86_64; To install the Development Library development tools

Yum Groupinstall "Development tools"

Package version: mysql-5.6.17-linux-glibc2.5-x86_64

httpd-2.4.6

php-5.5.10

Third, installation & Configuration

1, httpd: This part of the installation basically no difference, you can see my previous article. Simple Compile Lamp

# vim /etc/httpd24/httpd.conf //editing the Master profile Loadmodule proxy_module modules/mod_ proxy.soloadmodule proxy_fcgi_module modules/mod_proxy_fcgi.so//enable proxy and reverse proxy modules # vim /etc/ httpd24/extra/httpd-vhosts.conf //Edit Site Section <virtualhost *:80>    documentroot   "/web"     servername client.test.local    proxyrequests  off    proxypassmatch ^/(. *\.php) $ fcgi://10.0.0.103:9000/web/$1     //is mainly configured above these two, the first one is to close the forward proxy, the second, is to start with the root. php End of file      transfer to 10.0.0.103 server processing. There is a need to remind that in the PHP server to have and httpd server on the same Web site files, the directory does not need the same, as long as the specified in this article can be (this is the/web/). $ $ is a reference to the front/(. *\.php) $ expression. Words a little bit, do not know the explanation in place No.     <Directory  "/web" >        options  none        AllowOverride none         require all&Nbsp;granted    </directory></virtualhost># mkdir /web# cd  /web# cat > index.php << EOF> <?php>      phpinfo ();>      $link =mysql_connect (Localhost,root, ');   >        if  ($link)          >             echo  "Sueccess ... ";  >         else         >             echo  "Failure ..."    > ?>> eof//Create a test Web page file that can test PHP work and PHP's connection to MySQL.

The HTTPD server is modified for these needs.

2. mysql: Ibid.

3, PHP: This part is a little different, mainly in the compilation of selected parameters

# yum install openssl-devel  libxml2-devel# rpm -ivh  libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm libmcrypt-2.5.7-1.2.el6.rf.x86_64.rpm//These two installation packages are not official sources, to download it yourself. #tar  xf php-5.4.13.tar.bz2# cd php-5.4.13# ./configure --prefix=/usr/local/php  --with-mysql --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir  --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  -- enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt  -- with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  // Compared with the previous article is different, because it is independent operation does not need to become httpd module, so no longer need this parameter  --enable-maintainer-zts, and for MySQL communication needs--with-mysql. If in order to use phpMyAdmin do not report mysqli mistake, can add--WITH-MYSQLI#&NBSP;MAKE#&NBSP;MAKE&NBSP;TEST#&NBSP;MAKE&NBSP;INTALL#&NBSP;CP  php-5.4.13/php.ini-production /etc/php.ini# cp php-5.4.13/sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm//this startup service script. These two original files are in the extracted directory # chmod +x /etc/rc.d/init.d/php-fpm//give script execution permissions # chkconfig --add  php-fpm//Add the script to the boot Control service # chkconfig php-fpm on//turn on startup automatically # cp /usr/local/php/etc/ php-fpm.conf.default /usr/local/php/etc/php-fpm.conf //Change the PHP-FPM mode profile name, the parameters are basically modified here # vim / usr/local/php/etc/php-fpm.conf//main parameters pm.max_children = 50//the maximum number of processes that can be opened pm.start_servers =  5//number of initial boot processes pm.min_spare_servers = 2//minimum number of idle processes pm.max_spare_servers = 8//maximum idle processes pid =  /usr/local/php/var/run/php-fpm.pid//pid file as you know, there's not much to explain. error_log = log/php-fpm.log//error Log storage location, (hehe, at least I see from the name is the meaning, but inside are PHP-FPM server itself information, such as start) access.log =  /usr/local/php/var/log/$pool. access.log//This is about access to the PHP server log, the error is also in the inside listen = 10.0.0.103:9000// This is important because you want to provide services to other applications on the network, so listen to your NIC address. This one... 103 is the address of my network card, you can change it to yourself. Of course, you can also listen to any address, just write 9000 this port. Listen.allowed_clients = 10.0.0.101//look at the name to know is to restrict the address to provide services USER&NBSP;=&NBSP;NOBODYGROUP&NBSP;=&NBSP;NOBODY//PHP-FPM service users and groups, hey, I did not change. # mkdir /web# cd /web# chmod 660 -r /web && chown  .nobody -r /web# scp [email protected]:/web/* .//Copy the test page that was created on the httpd server. and give permissions to this/web folder. I did not modify the PHP-FPM service user, the default is nobody, so I will also give nobody. # service php-fpm startstarting php-fpm  done//Startup Success # netstat -tunlp  |grep 9000tcp        0       10.0.0.103:9000                 0.0.0.0:*                    listen      22583/php-fpm//View Network Listening interface, 9000 is in listening state

Iv. testing

Just find a browser to access, come out a lot of PHP information that PHP is working properly, the last line out success ... Instructions for PHP and MySQL

Connection is normal.

Postscript

Lazy, everyone will be next. If you are interested in studying together, you can send me a letter [email protected],.com.


This article is from the "Calm Nature Mastery" blog, please make sure to keep this source http://bluezombie.blog.51cto.com/1444792/1440302

Lamp compiled and installed (FPM-mode connection PHP and httpd)

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.