instance of lamp-deploy amp with XCache and php-fpm in CentOS7

Source: Internet
Author: User
Tags fpm

First, the use of PHP module method to deploy Amp+xcache

1. Install httpd, PHP, Mariadb-server, Php-mysql (slightly) in the host (192.168.109.136) using RPM package, then turn on the MARIADB service

At this time in the/etc/httpd/conf.modules.d/directory has a file 10-php.conf, which is recorded in the need to load the PHP module information is libphp5.so file, then php through the module and httpd link.

2. Configure a virtual host, the configuration file/etc/httpd/conf.d/vhost2.conf file is as follows:

<virtualhost 192.168.109.136:8000> ServerName www.ppp213.cn documentroot "/myvhost/vhost2" <directory "/ Myvhost/vhost2 "> Options none allowoverride none Require all granted </directory></vir Tualhost>

3. Configure a virtual host and set up an HTTPS service for it, method: http://blog.51cto.com/papapa213/2108143, then you need to make the following changes to the/etc/httpd/conf.d/ssl.conf file:

....... <virtualhost 192.168.109.136:443>documentroot "/myvhost/vhost1" ServerName www.ppp213.edu:443 < Directory "/myvhost/vhost1" > allowoverride None Require all granted </directory> SSLCERTIFICATEFILE/ETC/HTTPD/SSL/HTTPD.CRT//certificate file path Sslcertificatekeyfile/etc/httpd/ssl/httpd.key//private key path ......


4. Create/myvhost/vhost1,/myvhost/vhost2 directory, you can follow http://blog.51cto.com/papapa213/2112852 The method in the phpMyAdmin and WordPress respectively deployed into Vhost1 and Vhost2, at this time, respectively, to link, get back the result is a successful configuration.




Test on another host using the AB directive:

Ab-c 100-n https://192.168.109.136/index.php

Ab-c 100-n http://192.168.109.136:8000/index.php


The following results were obtained:


5. Configure Php-xcache

To install Php-xcache using the RPM package, you need to configure the Epel source yourself and add the following lines to the/etc/yum.repo.d/centos-base.repo file:

[epel]name=centos-$releasever-epelbaseurl=http://mirrors.sohu.com/fedora-epel/$releasever/$basearch/gpgcheck=0


Then use yum clean all; The Yum Makecache command reread the cache, which can be installed using Yum directly Php-xcache


Re-loading the httpd and accessing the host again, you can see that there are xcache related parameters:


At this point, use the AB command again with another host to test:


The acceleration effect is not seen, which may be due to the incompatibility of the XCache version installed with the RPM package, which will be followed by a compile-and-install approach to the XCache installation deployment.


Ii. deploying the amp using the PHP-FPM approach

1. Install httpd on the host (192.168.109.5) using the RPM package, uninstall the PHP package on the host (192.168.109.136), and install the PHP-FPM package

2. Modify the configuration file on the host (192.168.109.136) as follows/etc/php-fpm.d/www.conf

listen=9000listen.allowed_clients=192.168.109.5

and open the PHP-FPM service


3. Configure/etc/httpd/conf.d/vhost1.conf,/etc/httpd/conf.d/vhost2.conf on the host (192.168.109.5)

<virtualhost 192.168.109.5:80> ServerName www.ppp213.net proxyrequests Off #使用ProxyPassMatch可以使 File name with regular expression matching fixed suffix Proxypassmatch ^/(. *\.php) $ fcgi://192.168.109.136:9000/myvhost/vhost1/$1</virtualhost>
<virtualhost 192.168.109.5:8000> ServerName www.ppp213.org proxyrequests Off proxypassmatch ^/( . *\.php) $ fcgi://192.168.109.136:9000/myvhost/vhost2/$1</virtualhost>

Open HTTPD Service


4. Access to the configured resources on the 192.168.109.136 is now accessible through 192.168.109.5



Third, compile and install httpd, PHP, mariadb and XCache

Install the above services on (192.168.109.5) using the compile-and-install method, first uninstall the previously installed httpd

1. Get the source code

Apache:http://httpd.apache.org (2.4.27)

mariadb:https://mariadb.org/download/(5.5.57)

PHP:www.php.net (5.6.31)


2. Configuring the development environment

Yum Groupinstall "Development Tools" "Server Platform Development"


3. Compile and install httpd-2.4.27

1) Compile and install Apr




2) Compile and install Apr-util




3) Compile and install httpd

Tar XF httpd-2.4.27.tar.bz2 CD httpd-2.4.27/

You can now use the./configure--help to view the Help document


./configure--prefix=/usr/local/apache-2427--sysconfdir=/etc/httpd24--enable-so--enable-ssl--enable-cgi-- Enable-rewrite--enable-modules=most--enable-mpms-shared=all--with-apr=/usr/local/apr-152--with-apr-util=/usr/ local/apr-util-154--with-zlib--with-pcre--with-mpm=event

To start compiling the installation:

Make-j 4 && make install



Finishing work after installation is complete

① Exporting binary files:

Create/etc/profile.d/httpd24.sh

Export Path=/usr/local/apache-2427/bin: $PATH


Then use the source command to make it effective


② Export Header file:

ln-sv/usr/local/apache-2427/include//usr/include/httpd/


③ added in/etc/httpd24/httpd.conf:

Pidfile/var/run/httpd.pid


You can now start the httpd service with the Apachectl Start command:

To test on another host:



4. Installing MARIADB

1) Unzip the binary package and create the users and groups to start the service and manage the data:


2) Create the appropriate directory and modify the permissions:


Add content later in/ETC/MY.CNF:

DataDir =/mydata/data

Innodb_file_per_table = On

Skip_name_resolve = On


To create a startup script:


3) Exporting binary files

Create the/etc/profile.d/mariadb5557.sh file with the following contents:

Export Path=/usr/local/mysql/bin: $PATH


4) Export Header file

Ln-sv/usr/local/mysql/include/usr/include/mysql

5) Export the library file:

Create the/etc/ld.so.conf.d/mariadb5557.conf file with the following contents:

/usr/local/mysql/lib


Ldconfig-v

6) Initializing the database

scripts/mysql_install_db--user=mysql--datadir=/mydata/data/


7) Start the service:

Service mysqld Start


5. Compiling and installing PHP

To compile php-5.6.31 correctly, you may need to resolve the following dependencies

Libxml2-devel Gd-level Freetype-devel Libmcrypt-devel


(to be added)


6. Compile and install XCache:

After unpacking the XCache package, there is no configure file, you need to use the Phpize tool to generate, you can install Php-devel package to obtain the Phpize tool, and then execute XCache in Phpize directory, you can get configure files, Compile and install Now



Finally, you can see the XCache module generated by the compilation:


Copy the Xcache.ini file under the XCache directory to the/ETC/PHP.D directory:


After modifying the/etc/php.d/xcache.ini file, the path of the xcache.so module file is corrected.


At this point, restart the PHP-FPM service, visit the site, you can see the XCache module is loaded

instance of lamp-deploy amp with XCache and php-fpm in CentOS7

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.