CentOS 7 separated from three hosts to build a lamp based on fcgi

Source: Internet
Author: User
Tags install wordpress


First, the requirements

CentOS 7, lamp (PHP-FPM);
(1) The three main machines separated from each other;
(2) A virtual host is used to provide phpmyadmin; Another virtual host is used to provide WordPress;
(3) XCache


Planning

First set of 192.168.1.112 Httpd-2.4.6-40.el7.centos.x86_64 httpd Server
Second set of 192.168.1.113 Php-fpm-5.4.16-36.el7_1.x86_64 PHP-FPM Server
Third set of 192.168.1.114 Mariadb-5.5.47-1.el7_2.x86_64

MARIADB Server

Close all Selinux,iptables


Practice

Installing package groups based on fcgi mode

1.CentOS 6 Series

PHP-5.3.2 and Previous versions: the FPM mechanism is not supported by default, and needs to be patched and installed by itself;

httpd-2.2: The FCGI protocol is not supported by default, the FCGI module needs to be compiled by itself;

Solution: Compile and install httpd-2.4, php-5.3.3 and above version;

2.CentOS 7 Series

192.168.1.112:[[email protected] ~]# yum install-y httpd

192.168.1.113:[[email protected] ~]# yum install-y php-fpm php-mysql

192.168.1.114:[[email protected] ~]# yum install-y mariadb-server


3. Configuration changes

3.1 httpd Server

3.1.1 Open browser 192.168.1.112 to see Apache test page


3.1.2 Configuration Modifications

Configuration file/etc/httpd/conf/httpd.conf/etc/httpd/conf.d/*.conf

Here you can create a new configuration file with a. conf end in httpd.conf or under CONF.D.

Vim/etc/httpd/conf.d/fcgi.conf

DirectoryIndex index.php #主页为index. phpproxyrequests Off #关闭正向解析ProxyPassMatch ^/(. *\.php) $ fcgi://192.168.1.113:9000 /var/www/html/$1 #以. The end of PHP is forwarded to/var/php under the PHP-FPM server

/var/www/html can be defined by itself, provided that the appropriate directory is created on the PHP-FPM server


3.2 php-fpm Server connection to httpd server

3.2.1 Configuration file/etc/php-fpm.d/www.conf

Listen = 192.168.1.113:9000 #监听的本机的地址和端口 listen.allowed_clients = 192.168.1.112 #允许httpd服务器转发过来

the httpd and PHP-FPM servers are now connected

3.2.2, test it.

Create a new index.php content in the/var/www/html directory of the PHP-FPM server as follows

<?php phpinfo (); ?>

you can see the details of PHP-FPM by entering 192.168.1.112 now

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/7F/3B/wKiom1cXMcCjmHCkAADf5c4GG00251.png "title=" Phpfpm.png "alt=" Wkiom1cxmccjmhckaadf5c4gg00251.png "/>


3.3 Connecting the mariadb to the PHP-FPM

3.3.1 Configuring the MARIADB server

Add an accessible user to the PHP-FPM server on the MARIADB server

Mariadb>grant all on * * to [e-mail protected] ' 192.168.%.% ' identified by ' test '; mariadb> flush Privileges;

Edit/etc/my.cnf

Add below [mysqld]

Skip_name_resolve = On

3.3.2 Configuring the PHP-FPM server

Installing the Php-mysql Drive

Yum Install Php-mysql-y

test the PHP-FPM server and the MARIADB server

Edit/var/php/index.php under the PHP-FPM server

<?php $con = mysql_connect (' 192.168.1.114 ', ' Test ', ' test ');    if ($con) echo "OK";        else echo "failed";      Phpinfo (); ?>

Open the 192.168.1.112 URL again to see

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7F/3B/wKiom1cXNe-jZB1dAAD_5ceYqz4219.png "title=" Phpfpm.png "alt=" Wkiom1cxne-jzb1daad_5ceyqz4219.png "/>

At this point, the connection is complete.


Next build WordPress,phpmyadmin and XCache


Planning

First set of 192.168.1.112 httpd Server Wordpress
Second set of 192.168.1.113 PHP-FPM Server XCache
Third set of 192.168.1.114 MARIADB Server PhpMyAdmin

1, install the XCache (in the Epel source)

[email protected] html]# yum install-y php-xcache[[email protected] html]# Systemctl Reload PHP-FPM

2, install the phpMyAdmin (in the PHP-FPM server)

To https://www.phpmyadmin.net/downloads/

Download it and unzip it.

[[email protected] html]# unzip phpmyadmin-4.0.5-all-languages.zip-d pma[[email protected] html]# Yum install Php-mbstri Ng #安装中文支持

Configuration

[[Email protected] html]# CD Pma[[email protected] pma]# CP config.sample.inc.php config.inc.php $cfg [' Blowfish_secret '    ] = ' a8b7c6d '; $cfg [' Servers '] [$i] [' host '] = ' 192.168.1.106 '

3. Install WordPress

To https://cn.wordpress.org/

This article is from the "Tao Sound Still" blog, please make sure to keep this source http://zhaoyongtao.blog.51cto.com/10955972/1765813

CentOS 7 separated from three hosts to build a lamp based on fcgi

Related Article

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.