PHP-FPM Server of Lamp architecture

Source: Internet
Author: User

Introduction to PHP

Install PHP

Resolving dependencies

# Please configure the Yum source (System installation source and Epel source) and execute the following command: Yum " Desktop Platform Development " Yum Install bzip2-devel libmcrypt-devel mhash-devel

Compiling and installing php-5.4.26

tar XF php-5.4. . Tar . BZ2CD php-5.4.  - . /configure--prefix=/usr/local/php--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd-- With-openssl--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-  bz2make do  test make intall# provides configuration file for PHP CP Php.ini-production/etc/php.ini

Configure PHP-FPM

# for php-FPM provides the SYSV init script and adds it to the list of services:CPsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-FPMchmod+x/etc/rc.d/init.d/php-Fpmchkconfig--add php-fpmchkconfig PHP-fpm on# to PHP-FPM provides configuration files:CP/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf# editing PHP-fpm configuration file: # Vim/usr/local/php/etc/php-fpm.conf# Configure FPM with the relevant options for the value you need and enable the PID file Pm.max_children= -pm.start_servers=5pm.min_spare_servers=2pm.max_spare_servers=8PID=/usr/local/php/var/run/php-fpm.pid# Next you can start PHP-fpm: Service PHP-FPM start# uses the following command to verify the positive (if the command output has several PHP-The FPM process indicates that the boot was successful)PSAux |grepphp-fpm# By default, FPM listens on 127.0.0. 1 for 9000 ports, you can also use the following command to verify that it is already listening on the appropriate socket. Netstat-TNLP |grepphp-fpmtcp0      0 127.0.0.1:9000              0.0.0.0:* LISTEN689/php-fpm

Configure HTTPD

Enabling the relevant modules for httpd

2 . 4 has been dedicated to a module for the implementation of FASTCGI, this module is mod_proxy_fcgi.so, it is actually as a mod_proxy.so module expansion, so, these two modules are loaded LoadModule proxy_module Modules/mod_proxy.soloadmodule proxy_fcgi_module modules/mod_proxy_fcgi.so

Configure the virtual host to support the use of fastcgi

# When using a virtual host, you need to first disable the DocumentRoot entry for the master profile and enable httpd-vhosts.conf config file # simultaneously listening on port 8080VI/ect/httpd/httpd.conf# DocumentRoot"/usr/local/apache/htdocs"~~~# Virtual Hostsinclude/etc/httpd/extra/httpd-vhosts.conf~~~Listen8080===========================# Borrow phpMyAdmin's virtual host setup instructions firstVI/etc/httpd/extra/httpd-vhosts.conf<virtualhost *:8080>DocumentRoot"/www/phpmyadmin.com"ServerName phpmyadmin.com errorlog"Logs/phpmyadmin.com-error_log"Customlog"Logs/phpmyadmin.com-access_log"Common # Close forward proxy proxyrequests off # Send a file request ending in. php to PHP-FPM process, php-FPM needs to know at least the running directory and URI Proxypassmatch^/(. *\.php) $ fcgi://192.168.1.111:9000/www/phpmyadmin.com/$1<directory"/www/phpmyadmin.com">Options Indexes followsymlinks allowoverride None Require all granted</Directory></VirtualHost>

Edit httpd configuration file

/etc/httpd/httpd.conf# Add the following two lines   AddType application/x-httpd-php  . PHP   AddType Application /x-httpd-php-source  . phps# to DirectoryIndex index.html, modified to    DirectoryIndex  index.php  index.html

Edit Test Page

# dynamic content is placed on the PHP server, so the following files are in 192.168.1. 111 Up #VI/www/phpmyadmin/index.php<?Php$link= Mysql_connect ('192.168.1.112','PMA','pma123');if($link)Echo "Success ...";ElseEcho "Failure ..."; Mysql_close ();?>

Access test

# Browser Test to access http: // 192.168.1.110:8080

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.