溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

yum安裝lamp及Xcache加速

發(fā)布時間:2020-07-03 08:06:53 來源:網(wǎng)絡(luò) 閱讀:464 作者:m591892406 欄目:數(shù)據(jù)庫

LAMP的搭建:

           使用兩臺虛擬機(jī),一臺虛擬機(jī)安裝httpd及php,把php作為模塊編譯進(jìn)httpd中,另一臺安裝mysql,讓php能調(diào)用mysql來讀取數(shù)據(jù)。  

           虛擬機(jī)1:172.18.250.76  Centos6.7        安裝httpd、php

           虛擬機(jī)2:172.18.250.10  Centos6.7        安裝mysql

       利用httpd創(chuàng)建兩基于域名的虛擬主機(jī),分別運(yùn)行wordpress博客和phpmyadmin數(shù)據(jù)庫。

       

  一:yum安裝httpd

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

    1、編輯配置文件,注釋DocumentRoot

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
#DocumentRoot "/var/www/html"

   2、創(chuàng)建虛擬主機(jī)文件,編輯文件

[root@localhost php]# vim /etc/httpd/conf.d/vhost.conf
NameVirtualHost 172.18.250.76:80

<VirtualHost 172.18.250.76:80>
   ServerName www.a.com
   DocumentRoot "/www/blog"
   <Directory " ">
   Options None
   Allowoverride None
   Order allow,deny
   allow from all
   </Directory>
</virtualHost>

<VirtualHost 172.18.250.76:80>
   ServerName www.b.net
   DocumentRoot "/www/php"
   <Directory " ">
   Options None
   Allowoverride None
   Order allow,deny
   allow from all
   </Directory>
</virtualHost>

  3、啟動httpd服務(wù),查看監(jiān)聽端口

[root@localhost php]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address       Foreign Address     State     PID/Program name   
tcp       0     0    :::80                   :::*           LISTEN      2201/httpd

   4、創(chuàng)建虛擬主機(jī)路徑,并驗(yàn)證能否正常訪問

[root@localhost conf.d]# mkdir -p /www/blog
[root@localhost conf.d]# mkdir -p /www/php
[root@localhost conf.d]# cd /www/php
[root@localhost php]# echo "
[root@localhost conf.d]# cd /www/blog
[root@localhost blog]# echo "www.a.com">index.html

  重啟httpd服務(wù),驗(yàn)證:

 yum安裝lamp及Xcache加速

yum安裝lamp及Xcache加速

二、yum安裝php

[root@localhost php]# yum -y install php
[root@localhost php]# httpd -M    //查看httpd所加載的模塊
 php5_module (shared)             //php已經(jīng)編輯進(jìn)httpd

    驗(yàn)證php能否正常加載:

[root@localhost php.d]# vim /www/blog/index.php
 <?php
    phpinfo();
 ?>

  yum安裝lamp及Xcache加速 

 三、安裝mysql

[root@lsj ~]# yum -y install mysql-server
[root@lsj ~]# service mysqld start

  授權(quán)一個遠(yuǎn)程賬號,讓PHP能訪問mysql

mysql> grant all on *.* to admin@'172.18.250.76' identified by "admin";

  安裝mysql驅(qū)動,支持php遠(yuǎn)程

[root@localhost modules]# yum -y install php-mysql
[root@localhost modules]# vim /www/blog/index.php 
 <?php
    $conn = mysql_connect ('172.18.250.10','admin','admin');
    if ($conn)
      echo "success";
    else
      echo "false"
?>

  yum安裝lamp及Xcache加速

四、安裝wordpress和phpmyadmin軟件

[root@localhost wordpress]# unzip wordpress-4.3.1-zh_CN.zip
[root@localhost blog]# cd wordpress
[root@localhost wordpress]# cp wp-config-sample.php wp-config.php
[root@localhost wordpress]# vim wp-config.php 
/** WordPress數(shù)據(jù)庫的名稱 */
define('DB_NAME', 'mytest');

/** MySQL數(shù)據(jù)庫用戶名 */
define('DB_USER', 'admin');

/** MySQL數(shù)據(jù)庫密碼 */
define('DB_PASSWORD', 'admin');

/** MySQL主機(jī) */
define('DB_HOST', '172.18.250.10');

 驗(yàn)證能都正常登陸:

yum安裝lamp及Xcache加速

登陸博客:
yum安裝lamp及Xcache加速

[root@localhost blog]# cd /www/php/
[root@localhost php]# unzip phpMyAdmin-4.4.14.1-all-languages.zip
[root@localhost php]# ln -s phpMyAdmin-4.4.14.1-all-languages pma

 生成一段隨機(jī)數(shù),用作登陸phpmyadmin

[root@localhost pma]# cp config.sample.inc.php config.inc.php  
[root@localhost pma]# openssl rand -base64 30
d8yhR7wOU5+HzeZjGEusyAmNiQv/+rTzWQuoDiCR
[root@localhost pma]# vim config.inc.php
$cfg['blowfish_secret'] = 'd8yhR7wOU5+HzeZjGEusyAmNiQv/+rTzWQuoDiCR';
$cfg['Servers'][$i]['host'] = '172.18.250.10';

驗(yàn)證網(wǎng)頁是否能打開:
yum安裝lamp及Xcache加速

 安裝個php-mbstring,支持中文字符集

[root@localhost pma]# rpm -ivh php-mbstring-5.3.3-40.el6_6.x86_64.rpm

 刷新頁面:
yum安裝lamp及Xcache加速

輸入剛才授權(quán)的賬號密碼:

yum安裝lamp及Xcache加速

。。。。。。

解決思路:
1、升級mysql版本。
2、降級phpmyadmin版本。

降低版本的方法:

[root@localhost pma]# cd libraries/
[root@localhost libraries]# vim common.inc.php
if (PMA_MYSQL_INT_VERSION < 50500) {
 改成
if (PMA_MYSQL_INT_VERSION < 50100 {

 再次刷新,輸入賬號密碼:

yum安裝lamp及Xcache加速

 OK,數(shù)據(jù)庫登錄成功。

五、安裝Xcache對php進(jìn)行加速

[root@localhost libraries]# yum -y install php-xcache

 1、先測試沒開啟加速前的請求速度:

[root@localhost setup]# ab -n100 -c10 http://172.18.250.76/wordpress/index.php
Benchmarking 172.18.250.76 (be patient).....done
Server Software:        Apache/2.2.15
Server Hostname:        172.18.250.76
Server Port:            80
Document Path:          /wordpress/index.php
Document Length:        0 bytes
Concurrency Level:      10
Time taken for tests:   4.792 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      36800 bytes
HTML transferred:       0 bytes
Requests per second:    20.87 [#/sec] (mean)
Time per request:       479.161 [ms] (mean)
Time per request:       47.916 [ms] (mean, across all concurrent requests)
Transfer rate:          7.50 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.8      0      20
Processing:   143  459 331.6    352    1783
Waiting:      143  458 331.6    343    1783
Total:        143  460 331.4    360    1783

Percentage of the requests served within a certain time (ms)
  50%    360
  66%    405
  75%    512
  80%    581
  90%    895
  95%   1375
  98%   1720
  99%   1783
 100%   1783 (longest request)

 2、重啟httpd服務(wù),開啟Xcache,在測試下

[root@localhost setup]# ab -n100 -c10 
 Benchmarking 172.18.250.76 (be patient).....done
Server Software:        Apache/2.2.15
Server Hostname:        172.18.250.76
Server Port:            80
Document Path:          /wordpress/index.php
Document Length:        0 bytes
Concurrency Level:      10
Time taken for tests:   1.659 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      100
Total transferred:      36800 bytes
HTML transferred:       0 bytes
Requests per second:    60.27 [#/sec] (mean)   //三倍加速請求
Time per request:       165.908 [ms] (mean)
Time per request:       16.591 [ms] (mean, across all concurrent requests)
Transfer rate:          21.66 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   2.6      0      10
Processing:    41  158  27.5    158     235
Waiting:       40  158  27.6    158     235
Total:         41  159  28.7    158     245

Percentage of the requests served within a certain time (ms)
  50%    158
  66%    166
  75%    168
  80%    171
  90%    192
  95%    213
  98%    240
  99%    245
 100%    245 (longest request)

六:對訪問phpmyadmin網(wǎng)頁時進(jìn)行SSL加密認(rèn)證    

      簽證及CA認(rèn)證是怎么進(jìn)行可以參考我的博文:Linux中加密解密技術(shù)及CA認(rèn)證

    1、先下載mod_ssl模塊,因?yàn)閔ttpd2.2沒包含這個模塊

[root@localhost ssl]# yum -y install mod_ssl

       2、編輯/etc/httpd/conf.d/ssl.conf文件

[root@localhost ssl]# vim /etc/httpd/conf.d/ssl.conf 
DocumentRoot "/www/php"      //取消注釋,修改虛擬主機(jī)的url
ServerName      //虛擬主機(jī)名 
SSLEngine on                 //確保為on
SSLCertificateFile /etc/httpd/ssl/httpd.crt       //存放簽署的證書
SSLCertificateFile /etc/httpd/ssl/httpd.key       //存放私鑰的位置

   3、重啟httpd服務(wù)器,查看443端口是否啟用

[root@localhost ssl]# netstat -ntlp
tcp    0   0 :::443          :::*                        LISTEN      6080/httpd

   4、驗(yàn)證頁面是否能訪問

 yum安裝lamp及Xcache加速

 5、從虛擬機(jī)把CA證書下載到windows主機(jī)上

[root@www CA]# sz cacert.pem

 6、把證書導(dǎo)入到瀏覽器當(dāng)中

yum安裝lamp及Xcache加速

7、重新打開瀏覽器,輸入虛擬主機(jī)名:
yum安裝lamp及Xcache加速

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI