RPM Package Lnmp
nginx-Host: 172.16.40.99
php-fpm-Host: 172.16.40.11
mariadb-Host: 172.16.40.88
I. Installation, configuration nginx-Host: 172.16.40.99
Installation:
# yum Install Nginx
# Nginx Launcher
# Nginx-s Stop Stop
# NGINX-T Test configuration file is correct
# nginx-s Reload Overloaded configuration file
Configure two virtual hosts:
# vim/etc/nginx/conf.d/vhosts1.conf
server {
Listen 80;
server_name www1.ryanpeng.com;
ROOT/DATA/VHOST/WWW1;
Location ~ \.php$ {
Fastcgi_index index.php;
Fastcgi_pass 172.16.40.11:9000;
Fastcgi_param Script_filename/data/vhost/www1$fastcgi_script_name;
(indicates that files ending in. php are passed to php-fpm for processing, where the address is the PHP server address)
include fastcgi_params;
}
}
# vim/etc/nginx/conf.d/vhosts2.conf
server {
Listen 80;
server_name www2.ryanpeng.com;
root/data/vhost/www2;
Location ~ \.php$ {
Fastcgi_index index.php;
Fastcgi_pass 172.16.40.11:9000;
Fastcgi_param Script_filename/data/vhost/www2$fastcgi_script_name;
include fastcgi_params;
}
}
# mkdir-pv/data/vhost/www{1,2}
www{1,2} (Add test page under directory to test if Nginx is running the virtual host properly)
index.php (for steering PHP-FPM host)
###--Virtual Host configuration file with cache entry--###
server {
Listen 80;
ROOT/DATA/VHOST/WWW1;
Location ~ \.php$ {
Fastcgi_cache_valid 1m;
Fastcgi_cache one;
Fastcgi_cache_key $uri;
Fastcgi_cache_min_uses 2;
Fastcgi_cache_methods GET;
Fastcgi_index index.php;
Fastcgi_pass 172.16.40.11:9000;
Fastcgi_param Script_filename/data/vhost/www1$fastcgi_script_name;
Include Fastcgi_params;
}
Location/{
Rewrite/(. *) $ https://www1.ryanpeng.com/$1;
}
}
###--https Virtual Host profile 80 port changed to 443--###
server {
listen 443 SSL;
ROOT/DATA/DATA/WWW1;
SSL on;
ssl_certificate Www1.cacert;
Ssl_certificate_key Www1.key;
Ssl_session_cache shared:ssl:1m;
ssl_session_timeout 1m;
ssl_ciphers high:!anull:! MD5;
Location ~ \.php$ {
Fastcgi_cache_valid 1m;
Fastcgi_cache one;
Fastcgi_cache_key $uri;
Fastcgi_cache_min_uses 2;
Fastcgi_cache_methods GET;
Fastcgi_index index.php;
Fastcgi_pass 172.16.40.11:9000;
Fastcgi_param Script_filename/data/data/www1$fastcgi_script_name;
Include Fastcgi_params;
}
}
Two. Installation configuration PHP-FPM Host: 172.16.40.11
Installation:
# rpm-q PHP # # #确保之前没有php程序
# yum Install php-fpm php-mysql php-mbstring
# mkdir/var/lib/php/session
# useradd-r Nginx
# chown nginx.nginx/var/lib/php/session/
Configuration:
# vim/etc/php-fpm.d/www.conf
Listen = 172.16.40.11:9000 (set the PHP server listening address to listen locally to address external communication)
listen.allowed_clients = 172.16.40.99(listens for IP addresses with httpd service)
# mkdir-pv/data/vhost/www{1,2}
# vim/data/vhost/www1/index.php
This is Vhost1
<?php
Phpinfo ();
?>
# vim/data/vhost/www2/index.php
This is Vhost2
<?php
Phpinfo ();
?>
Test www1.ryanpeng.com,www2.ryanpeng.com separately to see if Nginx and PHP-FPM are connected successfully
Three. Installation Configuration MARIADB Host: 172.16.40.88
Installation start:
# yum Install Mariadb-server
# Systemctl Start Mariadb.service
To create a database and authorized users:
MariaDB [(None)]> grant all on db.* to ' dbuser ' @ ' 172.16.%.% ' identified by "dbpasswd";
MariaDB [(None)]> CREATE DATABASE db;
Build a PHP test page on the PHP server (172.16.40.11) to test if the PHP host can connect to the database host properly
# vim/data/vhost/www1/index.php
<?php
$conn = mysql_connect (' 172.16.40.88 ', ' dbuser ', ' dbpasswd ');
if ($conn)
echo "OK";
Else
echo "NO";
Phpinfo ();
?>
Test the connection is successful, if the display OK proves the connection is successful;
Four. Deploy WordPress and phpMyAdmin on virtual hosts respectively
On the PHP-FPM host (172.16.40.11), download Phpmyadmin-4.0.5-all-languages.zip and wordpress-4.3.1-zh_cn.zip;
The extracted files WordPress phpmyadmin-4.0.5-all-languages respectively moved to/data/vhost/under the WWW1 and WWW2 directory;
Deploy WordPress
# cd/data/vhost/www1/wordpress/
# CP wp-config-sample.php wp-config.php
# Vim wp-config.php
Define (' db_name ', ' wpdb ');
/** MySQL Database user name */
Define (' Db_user ', ' wpuser ');
/** MySQL Database password */
Define (' Db_password ', ' wppasswd ');
/** MySQL Host */
Define (' Db_host ', ' 172.16.40.88 ');
# Scp-r wordpress/172.16.40.99:/data/vhost/www1/
Deploying phpMyAdmin
# CD/DATA/VHOST/WWW2
# LN-SV Phpmyadmin-4.0.5-all-languages phpMyAdmin (create soft links for easy rollback)
# CD PhpMyAdmin
# CP config.sample.inc.php config.sample.php
# Vim config.sample.php
$cfg [' blowfish_secret '] = ' jacg7x2usbnwzg== '; (Generated using OpenSSL rand-base64 10)
$cfg [' Servers '] [$i] [' host '] = ' 172.16.40.88 '; (Database server address)
$cfg [' Servers '] [$i] [' user '] = ' dbuser ';
$cfg [' Servers '] [$i] [' password '] = ' dbpass ';
# Scp-r phpmyadmin/172.16.40.99:/data/vhost/www2/
Log in to two virtual machines, test WordPress and phpMyAdmin
Five. Install the XCache on the PHP-FPM (172.16.40.11) Host:
Installing Php-xache
# yum-y Install Php-xcache
# systemctl Restart Php-fpm.service
Configuration file to make simple configuration
# Vim/etc/php.d/xcache.ini
Xcache.size = 300M
Pressure test before and after loading XCache
#ab-N 10000-c http://www1.ryanpeng.com/wordpress | Http://www2.ryanpeng.com/phpmyadmin
RPM Package Implementation LNMP