CentOS 7 yum installs lamp, which is located on different servers, and installs WordPress and phpmyadmin for it

Keywords: PHP phpMyAdmin MariaDB Database

System Platform: CentOS 7 1611

WordPress Download Address

phpMyAdmin Download Address (CentOS 7 recommends that you do not install the latest version, otherwise you need to compile the latest php-fpm)

httpd (192.168.1.200), php-fpm (192.168.1.201), mariadb (192.168.1.202) are installed on three hosts respectively.

And provide WordPress, phpMyAdmin applications


1. Install and configure httpd server

    1.1 Installation of httpd services 

  [root@node1 ~]# yum install -y httpd

 1.2 Edit httpd configuration file and create virtual host   

[root@node1 ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs
[root@node1 ~]# vim /etc/httpd/conf/httpd.conf
ServerName localhost:80
#DocumentRoot "/www/wp.com/htdcos"

<VirtualHost 192.168.1.200:80>
        ServerName www.wp.com
        DocumentRoot "/www/wp.com/htdocs/"
        ProxyRequests off
        ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/wp.com/htdocs/$1
        <Directory "/www/wp.com/htdocs/">
                Options None
                AllowOverride None
                Require all granted
        </Directory>
</VirtualHost>

<VirtualHost 192.168.1.200:80>
        ServerName www.pma.com
        DocumentRoot "/www/pma.com/htdocs/"
        ProxyRequests off
        ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.1.201:9000/www/pma.com/htdocs/$1
        <Directory "/www/pma.com/htdocs/">
                Options FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>
</VirtualHost>

2. Install and configure php-fpm services

 2.1 Install php-fpm, php-mbstring, php-mysql services

   [root@node2 ~]# yum -y install php-fpm php-mbstring.x86_64  php-mysql

 2.2 Modify php-fpm configuration file

  [root@node2 ~]# vim /etc/php-fpm.d/www.conf
 listen = 0.0.0.0:9000 #Represents listening on all ports
  ;listen.allowed_clients = 127.0.0.1 #When commented out, all hosts are allowed access by default

  2.3 Create / WordPress and phpmyadmin web file directories and place WordPress and phpmyadmin files in this folder  

[root@node2 ~]# mkdir -pv /www/{wp.com,pma.com}/htdocs

Note: If phpmyadmin login does not respond, please try the following operation:

[root@node2 pma]# mkdir /var/lib/php/session -pv
[root@node2 pma]# chown -R apache.apache /var/lib/php/session/
[root@node2 pma]# systemctl restart php-fpm.service

3. Install and configure mariadb services

  3.1 Install mariadb service (CentOS 7 has mariadb service, just start)

        [root@node3 ~]# yum -y install mariadb-server

        [root@node3 ~]# systemctl start  mariadb.service

  3.2 Create a database, add users and grant privileges        

  MariaDB [(none)]> create database wp; 
  MariaDB [(none)]> CREATE UESR 'wp'@'%.%.%.%' IDENTIFIED BY 'wppasswd';    
  MariaDB [(none)]> GRANT ALL ON *.* TO wpuser@'192.168.1.%' IDENTIFIED BY 'wppasswd';

4. Configure WordPress, phpMyAdmin

  4.1 Unzip the downloaded files and create links for phpmyadmin

  [root@node2 wordpress]# unzip wordpress-4.7.4-zh_CN.zip
  [root@node2 wordpress]# unzip phpMyAdmin-4.0.10.20-all-languages.zip
  [root@node2 html]# ln -sv phpMyAdmin-4.0.10.20-all-languages pma

   4.2 Modify WordPress Profile

  [root@node2 html]# cd wordpress/
  [root@node2 wordpress]# cp wp-config-sample.php wp-config.php
  [root@node2 wordpress]# vim wp-config.php
  define('DB_NAME', 'wp');                #Database name
  define('DB_USER', 'wp');          #User name for connecting to database
  define('DB_PASSWORD', 'wppasswd');         #Password used to connect to database
  define('DB_HOST', '192.168.1.202');        #Path of database

  4.3 Modify the configuration file of phpMyAdmin

[root@node2 wordpress]# cd /var/www/html/pma/
[root@node2 pma]# cp config.sample.inc.php config.php
[root@node2 pma]# openssl rand -base64 15        #Generate the random number required in the configuration file
A42B1Noto1YiqQMC3DV7
[root@node2 pma]# vim config.php
$cfg['blowfish_secret'] = 'A42B1Noto1YiqQMC3DV7'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$cfg['Servers'][$i]['host'] = '192.168.1.202';

  4.4 Copy WordPress and phpMyAdmin to the corresponding path on the httpd server

[root@node2 pma]# scp -P 22 /var/www/html/pma/*  root@192.168.1.200:/var/www/html/pma
[root@node2 pma]# scp -P 22 /var/www/html/wordpress/*  root@192.168.1.200:/var/www/html/wordpress


Posted by FlashHeart on Thu, 14 Feb 2019 13:36:17 -0800