1.安裝好開發包租
yum groepinstall -y “development tools””server platform development ”
2.再依次安裝mariadb資料庫, httpd服務,php-xcache服務
yum install mariadb-service
vim /etc/my.conf
在[mysql]
innodb_file_per_table = on
skip_name_resolve = on
重新開機服務後,檢查程序和端口運作
systemctl reatart mariadb.service
ps aux
ss -ntl
檢查資料庫是否可以使用
$mysql
安裝httpd服務以及依賴包
yum install http php php-gd php-mysql php-mbstring php-xml
預設配置就可以達到我們所需要求
重新開機服務
sysctemctl restart httpd.service
檢視服務是否運作,端口是否打開
ps aux
ss -ntl
檢測httpd服務是否能被解析
vim /var/www/html/index.php
<?php
phpinfo();
?>
檢測mysql資料庫是否能被解析
$vim /var/www/html/index.php
$conn = mysql_connect(‘127.0.0.1’,’root’,’’);
if($conn)
echo "ok";
else
echo "failure";
mysql_close();
安裝php-xccahe
yum install php-xcache
編輯配置檔案
vim /etc/httpd/xcache.ini
重新加載服務
systemctl httpd reload
檢測是否能解析
vim /var/www/hmtl/index.php
phpinfo();
完成amp安裝後,在建立基于ip位址的虛拟機
ip addr add 172.16.54.2/16 dev eno16777736
ip a l
其中172.16.54.1提供wordpress
編輯虛拟主機172.16.54.1的配置檔案
vim /etc/httpd/conf.d/vhost1.conf
下載下傳wordpress.zip安裝包,并解壓
将解壓後的安裝包移動到/data/vhosts/www1/目錄下
将wp-config-sample.php 改名為wp-config.php
在建立wpdb資料庫
#mysql>grant all on wpdb.* to 'wpuser'@'172.16.%.$' identified by 'wppass';
#mysql>create database wpdb;
#mysql>exit;
在編輯wordpress的配置檔案
vim wp-config.php
将資料庫檔案資訊填在對應的位置
name wpdb
user wpuser
password wppass
host 172.16.54.2
vim /data/vhosts/www1/index.php
在重新開機服務,浏覽器172.16.54.1
在172.16.54.2上面提供phpmyadmin服務
vim /etc/httpd/conf.d/vhost2.conf
安裝phpmyadmin
yum install phpmyadmin
編輯其配置檔案
vim /etc/httpd/conf.d/phpmyadmin
将apache [2.4]下的
<require>都指向172.16
require ip 172.16
(b)
yum install mod_ssl
172.16.54.6 ca
cd /etc/pki/ca
(umask 077;openssl genrsa -out private/cakey.pem 2048 )
openssl req -new -x509 -key private/cakesy.pem -out cacert.pem
[cn beijing beijing magedu ops magedu.com @admin.com]
/etc/httpd/ssl
(umask 077;openssl genrsa -out private/httpd.key 1024)
openssl req -new -key httpd.key -out httpd.csr
scp httpd.csr 172.16.54.6:/tmp
[ca]
openssl ca -in /tmp/httpd.csr -out /etc/pki/certs/httpd.crt
scp certs/httpd.crt 172.16.54.1:/etc/httpd/ssl
vim /etc/httpd/conf.d/ssl.conf
servername www2.magedu.com:443
documentroot "/data/vhosts/www2"
servername www2.mageducom/phpmyadmin/:443
sslcertifcatefile /etc/httpd/ssl/httpd.crt
sslcertifcatekeyfile /etc/httpd/ssl/httpd.key
systemctl httpd reload
172.16.54.1 http
172.16.54.2 php-fpm
172.16.54.3 mariadb
yum -y instal httpd
vim /etc/httpd/conf.d/vhost1.conf
<virtualhost 172.16.54.1:80>
servername www1.magedu.com
documentroot "/data/vhost/www1"
proxyrequests on
directoryindex index.php
proxypassmatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www1/$1
<directory "/data/vhost/www1">
options none
allowoverride none
require all granted
</directory>
</virtualhost>
vim /etc/httpd/conf.d/vhost2.conf
servername www2.magedu.com
documentroot "/data/vhost/www2"
proxypassmatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www2/$1
<directory "/data/vhost/www2">
options none
allowoverride none
require all granted
</directory>
vim /etc/resolv.conf
dns=172.16.54.1
nameserver 172.16.0.1
vim /etc/hosts
172.16.54.1 www1.magedu.com www2.magedu.com
mkdir -pv /data/vhost/www{1,2}
vim /data/vhost/www1/index.html
http111111
vim /data/vhost/www2/index.html
http222222
########172.16.54.2#########
yum install php-fpm
vim /etc/php-fpm.d/www.conf
listen = 172.16.54.2:9000
listen.allowed_clients = 172.16.54.2
mkdir -pv /data/vhost/www{1,2}
vim /data/vhost/www1/index.php
<h1>php</h1>
$conn = mysql_connect('172.16.54.3','wpuser','wppass');
if($conn)
echo "ok";
else
echo "failure";
phpinfo();
unzip wordpress-4.3.1-zh_cn.zip
mv wordpress /data/vhost/www1
cd /data/vhost/www1/wordpress/
mv wp-config-sample.php wp-config.php
vim wp-config.php
define('db_name', 'wpdb');
define('db_user', 'wpuser');
define('db_password', 'wppass');
define('db_host', '172.16.54.3');
unzip phpmyadmin-4.4.14.1-all-languages.zip
mv phpmyadmin-4.4.14.1-all-languages /data/vhost/www2/
cd /data/vhost/www2/
ln -s phpmyadmin-4.4.14.1languages myadmin
cd myadmin/
ln -s config.sample.inc.php config.inc.php
openssl rand -base64 10
vim config.inc.php
$cfg['blowfish_secret'] = '4pnju4r8p4waqxd'; /* you must fill in this for cookie auth! */
/*
* servers configuration
*/
$i = 0;
* first server
$i++;
/* authentication type */
$cfg['servers'][$i]['auth_type'] = 'cookie';
/* server parameters */
$cfg['servers'][$i]['host'] = '172.16.54. 3';
$cfg['servers'][$i]['connect_type'] = 'tcp';
$cfg['servers'][$i]['compress'] = false;
$cfg['servers'][$i]['allownopassword'] = false;
######172.16.54.3###########
yum install mariadb-server
systemctl start mariadb.service
mysql> grant all on wpdb.* to 'wpuser'@'172.16.%.%' identified by 'wppass';
mysql> create database wpdb;
172.16.54.2
cd /etc/pki/ca/
(umask 077; openssl genrsa-out private/cakey.pem 2048)
openssl req -new -x509 -key private/cakey.pem -out cacert.pem
cn
beijing
magedu
ops
ca.magedu.com
touch index.txt
echo 01 > serial
172.16.54.1
yum install mod_ssl
mkdir ssl
cd ssl
(umask 077; openssl genrsa -out httpd.key 1024)
openssl req -new -key httpd.key -out httpd.csr
www2.magedu.com
scp httpd.csr 172.16.54.2:/tmp
openssl ca -in /tmp/httpd.csr -out /etc/pki/ca/certs/httpd.crt
scp certs/httpd.crt 172.16.54.1:/etc/httpd/ssl/
vim /etc/httpd/conf.d/ssl.conf
documentroot "/data/vhost/www2/myadmin"
servername www2.magedu.com:443
sslcertificatefile /etc/httpd/ssl/httpd.crt
sslcertificatekeyfile /etc/httpd/ssl/httpd.key
<virtualhost _default_:443>
proxypassmatch ^/(.*\.php)$ fcgi://172.16.54.2:9000/data/vhost/www2/$1
openssl s_client -connect 172.16.54.1:443 -cafile /etc/pki/ca/cacert.pem
ab -c 100 -n 1000 http://www1.magedu.com/data/vhost/www1/index.html 靜态資料
time per request: 22.433 [ms] (mean) time per request: 0.231 [ms] (mean, across all concurrent requests)
transfer rate: 1855.00 [kbytes/sec] received