HPH-FPM lamp Platform

Source: Internet
Author: User

Create a PHP-FPM Service Group

650) This. width = 650; "Title =" php-fpm .png "src =" http://s3.51cto.com/wyfs02/M00/45/D0/wKioL1PrmMLy5QDQAAHT-dRHcoI557.jpg "alt =" wKioL1PrmMLy5QDQAAHT-dRHcoI557.jpg "/>

 

Is the working principle of PHP-FPM

1. Compile and install the php-5.4.26

Download the source code file of PHP by yourself. Here we will install php2.4 as an example.

1. Solve the dependency:

Configure the yum source (which can be a local system disk) and run the following command:

# Yum-y groupinstall "X software development"

To enable the compiled PHP to support mcrypt extensions, you also need to install the following two programs: libmcrypt-devel; mhash-devel.

2. Compile and install the php-5.4.26

 

# Tar xf php-5.4.26.tar.bz2 ** unzip the source file

# Cd php-5.4.26

#. /Configure -- prefix =/usr/local/PhP5 -- With-mysql -- With-OpenSSL -- With-mysqli -- enable-mbstring -- With-FreeType-dir -- With-JPEG-dir -- with-PNG-dir -- With-zlib -- With-libxml-Dir =/usr -- enable-XML -- enable-sockets -- enable-FPM -- With-mcrypt -- With-config-File -Path =/etc -- With-config-file-scan-Dir =/etc/PHP. D -- with-bz2

* *** -- Prefix =/usr/local/PhP5 specifies the installation path. For details about other parameters, see the official documentation.

# Make & make intall

 

Provide a configuration file for PHP:

# Cp PHP. ini-production/etc/PHP. ini PHP will be available after decompression

650) This. width = 650; "Title =" A php.png "src =" http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1PrlH7zmM3fAANNAC29320775.jpg "alt =" wkiom1prl1_zmm3faannac29320775.jpg "/>

3. Configure PHP-FPM

 

Provide the sysv init script for PHP-FPM and add it to the service list:

# Cp SAPI/FPM/init. d. php-FPM/etc/rc. d/init. d/PHP-FPM

# Chmod + x/etc/rc. d/init. d/PHP-FPM ** grant the script running permission

# Chkconfig -- add PHP-FPM ** add PHP-FPM to the startup list

# Chkconfig PHP-FPM on ** Add a startup level for the service

 

Provide configuration files for PHP-FPM:

# Cp/usr/local/PHP/etc/php-fpm.conf.default/usr/local/PHP/etc/php-fpm.conf

 

Edit the configuration file of PHP-FPM:

# Vim/usr/local/PhP5/etc/php-fpm.conf

Configure FPM related options for your required values and enable the PID file (the last line below ):

PM. max_children = 50

PM. start_servers = 5

PM. min_spare_servers = 2

PM. max_spare_servers = 8

PID =/usr/local/PHP/var/run/php-fpm.pid file in your own installation path

* *** Here, listen must listen to the IP address of the local machine.

650) This. width = 650; "Title =" php ipipip.png "src =" http://s3.51cto.com/wyfs02/M01/45/CF/wKiom1PrluPhzH8vAAIy0c0ZVIU640.jpg "alt =" wkiom1prluphzh8vaaiy0c0zviu640.jpg "/>

 

Next we can start PHP-FPM:

# Service PHP-FPM start

# SS-tnl check whether PHP port 9000 is listened

 

650) This. width = 650; "Title =" php port png.png "src =" http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1PrlEzgntIiAAJPfyk__0A324.jpg "alt =" wkiom1prlezgntiiaajpfyk1_0a324.jpg "/>

 

 

3. Configure httpd-2.4.9

 

1. Enable httpd-related modules

 

After Apache httpd 2.4, there has been a dedicated module for FastCGI implementation. This module is mod_proxy_fcgi.so, which is actually used as an extension of the mod_proxy.so module. Therefore, both modules must be loaded.

Loadmodule proxy_module modules/mod_proxy.so

Loadmodule proxy_fcgi_module modules/mod_proxy_fcgi.so

 

 

2. Configure virtual hosts to support fcgi

 

Add the following lines to the corresponding VM.

Proxyrequests off

Proxypassmatch ^/(. * \. php) $ fcgi: // 127.0.0.1: 9000/path/to/document_root/$1

 

Http://www.magedu.com/admin/index.php

 

/Web/host1/admin/index. php

Fcgi: // 127.0.0.1: 9000/web/hosts/admin/index. php

650) This. width = 650; "Title =" virtual profiles profile .png "src =" http://s3.51cto.com/wyfs02/M01/45/CF/wKiom1PrlvmT7m-EAAMvxJvegFE283.jpg "alt =" wKiom1PrlvmT7m-EAAMvxJvegFE283.jpg "/>

 

 

Proxyrequests off: Disable forward proxy

Proxypassmatch. the file request ending with PHP is sent to the PHP-FPM process. php-FPM must at least know the running directory and Uri: the two parameters are specified after 9000. The passing of other parameters has been encapsulated by mod_proxy_fcgi.so and does not need to be specified manually.

 

3. Edit the Apache configuration file httpd. conf so that Apache can recognize pages in PHP format and support the PHP homepage.

 

# Vim/etc/httpd. conf

1. Add the following two rows:

Addtype application/X-httpd-PHP. php

Addtype application/X-httpd-PHP-source. PHPs

 

2. Locate directoryindex index.html

To:

Directoryindex index. php index.html

 

650) This. width = 650; "style =" float: none; "Title =" php .png "src =" http://s3.51cto.com/wyfs02/M02/45/D0/wKioL1PrmEeRELuSAAGz5dCVtwY841.jpg "alt =" wkiol1prmeerelusaagz5dcvtwy841.jpg "/>

650) This. width = 650; "style =" float: none; "Title =" php master profile 2.png "src =" http://s3.51cto.com/wyfs02/M02/45/CF/wKiom1Prly7TYlvTAAB0NSBhWTk610.jpg "alt =" wkiom1prly7tylvtaab0nsbhwtk610.jpg "/>

650) This. width = 650; "style =" float: none; "Title =" httpconfig file add.png "src =" http://s3.51cto.com/wyfs02/M01/45/D0/wKioL1PrmEfCBhZuAACp28AtKJo603.jpg "alt =" wkiol1prmefcbhzuaacp28atkjo603.jpg "/>

 

 

In versions earlier than Apache httpd 2.4, either PHP is run as an Apache module or a third-party module is added to support PHP-FPM implementation.

 

3. Compile and install the database mariadb-5.5.36

 

1. Install a MySQL database: mariadb-5.5.36-linux-x86_64.tar.gz on the host with IP address 172.16.1.72

2. decompress the package and move it to the/usr/local directory.

# Tar-xvf mariadb-5.5.36-linux-x86_64.tar.gz unzip the file to the current directory

# Music mariadb-5.5.36-linux-x86_64/usr/local/mariadb

 

# Cd/usr/local/mariadb/enter the MySQL installation directory

# Scripts/mysql_install_db -- user = MySQL -- datadir =/mydata initialize MySQL, specify the running user, and specify the data storage location
# Chown-r root./* set the owner of all files in the mariadb directory to the root user.

Provides the primary configuration file for mysql users.
# Cp support-files/my-large.cnf/etc/My. CNF

# Vim/etc/My. CNF edit MySQL master configuration file

 

 

# Cp support-files/MySQL. Server/etc/rc. d/init. d/mysqld copy the MySQL running script to the/etc/rc. d/init. d directory.

# Chkconfig -- add mysqld add directory to startup list

# Chkconfig mysqld on Add a startup level for MySQL

Thread_concurrency = 2 set the number of CPUs * 2

Datadir =/mydata specifies the data storage location in the configuration file

# Chown-r MySQL/mydata: Set the owner of all files in the mydata directory to MySQL

# Service mysqld start service

# CD ..

# Ln-SV mariadb/MySQL connect the mariadb directory to the MySQL directory

# Service mysqld start MySQL Service

# SS-NTL check whether MySQL is listened to by a port

# Vim/etc/profile. d/MySQL. Sh add Environment Variables

#./Etc/profile. d/MySQL. Sh read the modified environment variable

# Grant all on discuz. * to [email protected] 1.71 identified by '000000'; grant the user of the username week the permission to all the tables in the discuz directory

 

4. The following uses discuz installation as an example to check whether PHP-FPM is successfully built.

1. Download The discuz software to your local device.

2. decompress the package to/web/zhou.com on the HTTP server.

650) This. width = 650; "Title =" discuz http.png "src =" http://s3.51cto.com/wyfs02/M02/45/D0/wKioL1Prne_i85RpAACQNsAINrc410.jpg "alt =" wkiol1prne_i85rpaacqnginrc410.jpg "/>

3. decompress the package to the/web/zhou.com directory of the PHP server. Copy the three files in the figure to the/web/zhou.com directory of the HTTP server and overwrite the original directory.

650) This. width = 650; "Title =" discuz php.png "src =" http://s3.51cto.com/wyfs02/M01/45/D0/wKioL1PrngzDYruBAACXl2XrXgs396.jpg "alt =" wkiol1prngzdyrubaacxl2xrxgs396.jpg "/>

4. Enter http: // 172.16.1.70/upload/Forum. php in the browser.

 


 

This article is from the "journey forward by cainiao" blog and will not be reposted!

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.