CentOS7, apm + xcache, rpm包, php module;
a) 一個虛拟主機提供phpMyAdmin,另一個虛拟主機提供wordpress;
b) 為phpMyAdmim提供https服務;
對部署做壓力測試,并對比測試結果,寫出測試報告;
目錄:
一、部署環境及虛拟主機配置
二、安裝WordPress和phpMyAdmin
三、簽署CA及提供https服務
四、壓力測試
---------------------------------------------------------------------------------------
一、部署環境及虛拟主機配置
1.用yum快速安裝部署試驗環境需要的軟體程式:
yum install -y httpd php php-mysql php-gd php-mbstring php-xml mariadb-server mod_ssl
檢視端口是否開啟:
<a href="https://s4.51cto.com/wyfs02/M02/A5/3B/wKioL1m59WTwHnzLAABCtbQyqtM285.png" target="_blank"></a>
一切正常!
為了避免出現問題,提前關閉SElinux和防火牆。
2.進入mysql,授權建立使用者,重新整理,如下:
MariaDB[(none)]> GRANT ALL ON wpdb.* TO 'wpuser'@'172.16.%.%' IDENTIFIED BY'123456';
MariaDB[(none)]> create database wpdb;
MariaDB[(none)]> flush privileges;
3.建立兩個虛拟主機:
mkdir/var/www/html/www{1,2}
在/etc/httpd/conf.d/目錄下建立vhosts.conf檔案,配置以下内容
在各個虛拟主機的根目錄下面建立index.html的首頁檔案:
echo “Thisis www1.qhdlink.com” > /var/www/html/www1/index.html
echo “Thisis www2.qhdlink.com” > /var/www/html/www2/index.html
用httpd –t 驗證文法沒錯,并重新開機。
4.本地域名解析增加條目,在/etc/hosts檔案中添加:
172.16.1.3www1.qhdlink.com www2.qhdlink.com
将/var/www/html/www1/目錄下的index.html改為index.php
并打開index.php将其内容改為如下:
<a href="https://s4.51cto.com/wyfs02/M01/06/8B/wKiom1m59fPQYbrXAAAURqW9e1U659.png" target="_blank"></a>
将第二台虛拟主機的上述該檔案改為同樣的内容。
5.測試php頁面是否可以正常連接配接 以及資料庫連接配接是否正常
<a href="https://s3.51cto.com/wyfs02/M00/06/8B/wKiom1m59h3xZNRxAAB2Vad068w968.png" target="_blank"></a>
<a href="https://s3.51cto.com/wyfs02/M00/A5/3B/wKioL1m59fPgEsYGAACC6LLTsh8482.png" target="_blank"></a>
兩台虛拟主機都顯示OK
二、安裝WordPress和phpMyAdmin
1.從官網下載下傳兩個軟體,并傳到虛拟機,解壓縮
2.将WordPress解壓後的檔案夾移動至第一個虛拟主機的資源映射路徑下:
mvwordpress /var/www/html/www1/
cd進入該目錄下,執行以下指令,并且修改配置檔案
mv wp-config-sample.php wp-config.php
vim wp-config.php
<a href="https://s2.51cto.com/wyfs02/M02/06/8B/wKiom1m59kSDVtlpAABR1OLh_X4604.png" target="_blank"></a>
3.wordpress基本上已經配置好了,打開浏覽器輸入www1.qhdlink.com/wordpress進行測試:
<a href="https://s5.51cto.com/wyfs02/M00/A5/3B/wKioL1m59jWzAv31AAHcqj3zUcU111.png" target="_blank"></a>
測試成功!
4..下面進行phpMyAdmin的安裝:
提示:
(1)如果phpMyAdmin的版本過高,安裝後會出現版本不相容的情況,建議安裝phpMyAdmin低版本的,我安裝的是4.0.10.20版本。
(2)如果出現如下情況:
<a href="https://s3.51cto.com/wyfs02/M01/A5/3B/wKioL1m59qPg85atAAAKRKL1AxI472.png" target="_blank"></a>
則直接yuminstall php-mbstring再重新開機httpd服務就可以了。
5.将phpMyAdmin解壓出來的所有檔案移動到第2個虛拟主機資源映射路徑下:
[root@zj03~]# mv phpMyAdmin-4.0.10.20-all-languages/* /var/www/html/www2/phpmyadmin/
6.cd進入該目錄下,執行以下指令,并且修改配置檔案:
mv config.sample.inc.php config.inc.php
<a href="https://s3.51cto.com/wyfs02/M02/06/8B/wKiom1m59wHT2kUCAABGGDJSdsg011.png" target="_blank"></a>
第一個劃線處是用于傳輸加密。
第二個是虛拟機的位址。
7.phpMyAdmin基本上已經配置好了,打開浏覽器輸入www2.qhdlink.com/phpmyadmin/進行測試:
<a href="https://s3.51cto.com/wyfs02/M00/A5/3B/wKioL1m59wXwqoa9AAIKDVyHsno057.png" target="_blank"></a>
到這裡測試全部成功,然後我們最後要為myadmin提供https服務
三、簽署CA及提供https服務
1.簽署CA憑證并為phpmyadmin提供https服務;
在主機上安裝mod_ssl子產品因為需要http來加載子產品并啟動443端口前面已經安裝了
<a href="https://s5.51cto.com/wyfs02/M00/A5/3B/wKioL1m59zOg74tqAAAuIZ3vhJU778.png" target="_blank"></a>
注意:本次私建CA和節點申請證書在同一台機器完成。
2.建立私有CA
生成密鑰
首先進入CA目錄下
[root@zj03 ~]# cd /etc/pki/CA
在CA目錄下生成密鑰
<a href="https://s3.51cto.com/wyfs02/M00/06/8B/wKiom1m593SwVcROAAAWJdQpZR4130.png" target="_blank"></a>
3.生成自簽證書
[root@zj03CA]# openssl req -new -x509 -key private/cakey.pem -out cacert.pem
<a href="https://s2.51cto.com/wyfs02/M01/06/8B/wKiom1m594qwUfxvAAA1MFfUTHM519.png" target="_blank"></a>
4.補充檔案
[root@zj03CA]# touch index.txt
[root@zj03CA]# echo 01 > serial
5.生成私鑰并且生成證書簽署請求:
[root@zj03~]#mkdir -pv /etc/httpd/ssl
<a href="https://s4.51cto.com/wyfs02/M02/06/8B/wKiom1m597bSMiUMAAB-OhiPKr8194.png" target="_blank"></a>
複制目錄cphttpd.csr /tmp/
6.CA簽發證書
簽發證書
<a href="https://s4.51cto.com/wyfs02/M01/06/8B/wKiom1m599Kh86RsAAIzPW7IDU8258.png" target="_blank"></a>
7.把簽署好的證書發還給請求者。
~]# cp/etc/pki/CA/certs/httpd.crt /etc/httpd/ssl/
8.配置httpd支援使用ssl,及使用的證書
<a href="https://s2.51cto.com/wyfs02/M02/06/8B/wKiom1m59-2SC0kBAAAwQ_hTbHM899.png" target="_blank"></a>
9.然後ss -tnl 檢視一下443端口起來沒
<a href="https://s5.51cto.com/wyfs02/M00/A5/3B/wKioL1m5996zeKx2AABDsgDBqnI778.png" target="_blank"></a>
10.打開浏覽器,顯示如下
<a href="https://s4.51cto.com/wyfs02/M02/06/8B/wKiom1m5-Enjq2nnAADCS8L2JrM728.png" target="_blank"></a>
表明我們的試驗成功了!
四、壓力測試
測試并發
[root@zj03CA]# ab -c 10 -n 1000 www2.qhdlink.com/wordpress/index.php
ServerSoftware: Apache/2.4.6
ServerHostname: www2.qhdlink.com
ServerPort: 80
DocumentPath: /wordpress/index.php
DocumentLength: 0 bytes
ConcurrencyLevel: 10
Timetaken for tests: 79.144 seconds
Completerequests: 1000
Failedrequests: 0
Writeerrors: 0
Non-2xxresponses: 1000
Totaltransferred: 339000 bytes
HTMLtransferred: 0 bytes
Requestsper second: 12.64 [#/sec] (mean)
Timeper request: 791.438 [ms] (mean)
Timeper request: 79.144 [ms] (mean,across all concurrent requests)
Transferrate: 4.18 [Kbytes/sec] received
ConnectionTimes (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 240 770 736.3 669 6496
Waiting: 240 768 731.3 668 6429
Total: 240 770 736.4 669 6497
Percentageof the requests served within a certain time (ms)
50% 669
66% 718
75% 747
80% 765
90% 805
95% 878
98% 4807
99% 6494
100% 6497 (longest request)
為php安裝xcache加速器測試資料:
yum 安裝php-xcache
yuminstall php-xcache
~]# ab-c 10 -n 1000 www2.qhdlink.com/wordpress/index.php
ServerPort: 80
Timetaken for tests: 69.750 seconds
Requestsper second: 14.34 [#/sec] (mean)
Timeper request: 697.503 [ms] (mean)
Timeper request: 69.750 [ms] (mean,across all concurrent requests)
Transferrate: 4.75 [Kbytes/sec] received
Processing: 139 683 1093.9 631 25635
Waiting: 139 682 1093.8 629 25635
Total: 139 683 1093.9 631 25635
50% 631
66% 686
75% 713
80% 734
90% 785
95% 824
98% 907
99% 1450
100% 25635 (longest request)
安裝php-xcache後速度有所提升!
本文轉自 Runs_ 51CTO部落格,原文連結:http://blog.51cto.com/12667170/1965178,如需轉載請自行聯系原作者