Three hosts deploy lamp (fast-cgi)
Three hosts deploy lamp (fast-cgi)
Experimental requirements:
Create two virtual hosts, web1,web2, run phpMyadmin and wordpress respectively, and provide https services for phpMyadmin.
Three hosts:
1.Cehtos7.2 runs httpd.2-4 a network card eno16777728 bridge mode ip 172.16.254.7916
2.centos7.2 runs php-fpm a network card eno16777728 bridge mode ip 172.16.250.205Univer 16
3.centos7.2 runs mariadb-server a network card eno16777728 bridge mode ip 172.16.252.180x16
The required software packages for installation on three hosts:
1.yum-y install httpd samba mod-ssl
2.Yum-y install php-fpm php-mysql cifs-utils php-mbstring
3.Yum-y install mariadb-server
Configuration of Httpd hosts:
Create the root directory of the two virtual sites:
Mkdir / data/web {1, no. 2}-pv
Chown apache:apache / data/web {1,2}
Share these two directories / data/web1,/data/web2 through samba.
Vim / etc/samba/smb.conf [php]
Comment=php data
Path=/data/web1
Browseable=yes
Write list=apache
[wordpress]
Comment=wordpress data
Path=/data/web2
Browseable=yes
Write list=apache
Pdbedit-a-u apache
Passwdord 123456
Start samba server
Systemctl start smb.service
Systemctl start nmb.service
Create a configuration file for two virtual host web1,web2:
ServerName www1.wudang.com
DocumentRoot / data/web1
DirectoryIndex index.php
ErrorLog logs/www1_error_log
CustomLog logs/www1_access_log combined
ProxyRequests Off
ProxyPassMatch ^ / (. *\ .php) $fcgi://172.16.250.205:9000/data/web1/$1
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
ServerName www2.shaolin.com
DocumentRoot / data/web2
DirectoryIndex index.php
ErrorLog logs/www2_error_log
CustomLog logs/www2_access_log combined
ProxyRequests Off
ProxyPassMatch ^ / (. *\ .php) $fcgi://172.16.250.205:9000/data/web2/$1
Options Indexes FollowSymLinks
AllowOverride none
Require all granted
Download phpMyAdmin-4.4.14.1-all-languages.zip wordpress-4.3.1-zh_CN.zip
Extract the two application packages to the site root:
Unzip phpMyAdmin-4.4.14.1-all-languages.zip
Unzip wordpress-4.3.1-zh_CN.zip
Create a soft connection file for the two application roots:
Ln-svf / data/web1/ phpMyAdmin-4.4.14.1-all-languages / data/web1/mpa
Ln-svf / data/web2/wordpress / data/web2/wordpress
Configure the connection between the two applications and the database mariadb:
Cp / data/web1/mpa/config.sample.inc.php / data/web1/mpa/config.inc.php
Vim / data/web1/mpa/config.inc.php
$cfg ['blowfish_secret'] =' 1rnbfOvowLY6GABA;-Random number to generate key
$cfg ['Servers'] [$I] [' host'] = 'localhost';-mariadb host address
Cp / data/web2/wordpress/wp-config-sample.php / data/web2/wordpress/wp-config.php
Vim / data/web2/wordpress/wp-config.php
Define ('DB_NAME',' wordpress');-pre-created database
/ * * MySQL database user name * /
Define ('DB_USER',' jack');-user name for managing the database
/ * * MySQL database password * /-password for Jack users to connect to the database
Define ('DB_PASSWORD',' 123456')
/ * * MySQL host * /
Define ('DB_HOST',' 172.16.254.79');-address of the mariadb database
Start mariadb
Configuration of Mariadb-server hosts:
Systemctl strart mariadb.service
Connect to the database
Mysql
Create a database user:
Grant all on *. * to 'jack'@'%' identified by' 123456'
Flush privileges
Start httpd
Systemctl start httpd
Configuration of Php-fpm hosts:
Mkdir / data/web {1,2}
Mkdir / data/web {1, no. 2}-pv
Mount.cifs-o username=apache / / 172.16.254.79/php / data/web
Mount.cifs-o username=apache / / 172.16.254.79/wordpress / data/web2
Mkdir / var/lib/php/session
Chown apache:apache / var/lib/php/session
Vim / etc/php-fpm.d/www.conf
Listen = 172.16.250.205VR 9000
; Default Value: any
# listen.allowed_clients = 127.0.0.1-allow reverse access for any host
Start php-fpm
Systemctl start php-fpm
Http service test: add a record to the win7 hosts file of the tester
172.16.254.79 www1.wudang.com www2.shaolin.com
Http://www1.wudang.com/mpa
Http://www2.shaolin.com/wordpress
Create a CA certificate:
(umask 066; openssl genrsa-out private/cakey.pem 1024)
Openssl req-new-x509-key private/cakey.pem-days 3650-out cacert.pem
Create the site phpMyadmin private key and certificate:
(umask 066 days OpenSSL genrsa-out / etc/httpd/web1/php.key 1024) openssl req-new-key / etc/httpd/web1/php.key-days 365-out / etc/httpd/web1/php.csr
Openssl ca-in / etc/httpd/web1/php.csr-out certs/php.crt
Listen 443 httpsi
DocumentRoot "/ data/web1/"
ServerName www1.wudang.com:443
ProxyRequests Off
ProxyPassMatch ^ / (. *\ .php) $fcgi://172.16.250.205:9000/data/web1/$1
SSLProtocol All-SSLv2
DirectoryIndex index.php
SSLEngine on
ErrorLog logs/www1_ssl_error_log
LogLevel warn
SSLCertificateFIle / etc/httpd/web1/php.crt
SSLCertificateKeyFile / etc/httpd/web1/php.key
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
Import CA's certificate into the trusted root certificate authority in the browser.
Https Test:
Https://www1.wudang.com/mpa