1.本次試驗基於LAMP平臺搭建(一)所搭建的環境,搭建三款基於LAMP的站點(WordPress,Drupal以及數據庫管理軟件phpMyadmin).,另外,本文中關於各站點的安裝步驟可能不太詳盡,請諒解
注:本篇博客中除特殊說明外大部分站點文件操作需要在web和php兩臺主機上進行
2.分別在php.test.com服務器上下載所需要軟件,各軟件包地址如下:
Drupal:http://ftp.drupal.org/files/projects/drupal-7.31.tar.gz
Drupal漢化文件: http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.28.zh-hans.po
WordPress:http://cn.wordpress.org/wordpress-3.9-zh_CN.zip
PhpMyadmin:http://dow1.pc6.com/gm/phpMyAdmin.zip
3.在apache上配置虛擬主機並測試
a) 添加站點存放目錄
[root@web ~]# mkdir -vp /web/{phpmyadmin,drupal,wordpress} mkdir: created directory `/web' mkdir: created directory `/web/phpmyadmin' mkdir: created directory `/web/drupal' mkdir: created directory `/web/wordpress'
b) 添加虛擬主機配置文件httpd-vhosts
#在httpd.conf中添加如下信息,用於包含httpd-vhosts配置信息 Include /etc/httpd24/extra/httpd-vhosts.conf #httpd-vhosts文件信息如下 <VirtualHost *:80> DocumentRoot "/web/phpmyadmin" ServerName pma.test.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.21.251:9000/web/pma/$1 ErrorLog "logs/pma_error_log" CustomLog "logs/pma_access_log" common </VirtualHost> <VirtualHost *:80> DocumentRoot "/web/wordpress" ServerName wp.test.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.21.251:9000/web/wp/$1 ErrorLog "logs/wp_error_log" CustomLog "logs/wp_access_log" common </VirtualHost> <Directory /web/drupal> Require all granted </Directory> <Directory /web/phpmyadmin> Require all granted </Directory> <Directory /web/wordpress> Require all granted </Directory>
4.配置安裝Drupal
a) 分別在兩臺主機解壓Drupal安裝包到/web目錄
[root@web src]# tar xf ~/drupal-7.31.tar.gz -C /usr/local/src [root@web src]# cp -a /usr/local/src/drupal-7.31/* /web/drupal/
b) 複製漢化包到指定目錄下
[root@web src]# cp ~/drupal-7.28.zh-hans.po /web/drupal/profiles/standard/translations/ c)在db主機上爲創建數據庫drupal,創建MariaDB數據庫用戶drupal,並賦予對drupal數據庫的所有權限 MariaDB [(none)]> create database drupal; #創建數據庫 Query OK, 1 row affected (0.21 sec) MariaDB [(none)]> grant all on drupal.* to 'drupal'@'172.16.21.251' identified by '123456';#授予權限 Query OK, 0 rows affected (0.24 sec) MariaDB [(none)]> flush privileges; #刷新權限列表 Query OK, 0 rows affected (0.25 sec)
c) 在網頁訪問站點drupal.test.com,安裝drupal
根據提示信息創建指定文件,這裏由於原來沒有編譯gd模塊,需要進行如下操作進行編譯,並重啓php服務
[root@php gd]# cd /usr/local/src/php-5.4.26/ext/gd [root@php gd]# /usr/local/php5/bin/phpize [root@php gd]# ./configure --with-php-config=/usr/local/php5/bin/php-config [root@php gd]# make && make install [root@php no-debug-non-zts-20100525]# vim /etc/php.ini extension=gd.so#將此模塊加載到服務器 [root@php gd]# service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done
現在,安裝條件全部滿足,會提示用戶設置數據庫,按要求設置即可
5.配置安裝WordPress
解壓
[root@web ~]# unzip wordpress-3.9-zh_CN.zip -d /web/wordpress/ #按提示提供配置文件,安裝
根據提示按步驟進行安裝
安裝成功
6.配置安裝phpMyadmin
a) 分別在兩臺主機解壓phpmyadmin安裝包到/web/phpmyadmin目錄
[root@php ~]# unzip phpMyAdmin.zip -d /web/phpmyadmin/
b) 配置配置文件
$cfg['blowfish_secret'] = 'sdfgsdfgsh'; /* YOU MUST FILL IN THIS FOR COOKIE #設置cookie加密隨機字符串 $cfg['Servers'][$i]['host'] = '172.16.21.251'; # 設置服務器地址
注:由於php和mysql不在一臺服務器上,所以需要在mysql設定指定用戶從php訪問的權限纔可訪問服務器,沒有權限的數據庫在這裏是看不到的
7.設置phpmyadmin通過https訪問
#加載相應支持模塊 LoadModule ssl_module modules/mod_ssl.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so #生成祕鑰及證書 [root@web httpd24]# mkdir /etc/httpd24/ssl;cd /etc/httpd24/ssl [root@web ssl]# (umask 077;openssl genrsa -out /etc/httpd24/ssl/httpd.key 1024) Generating RSA private key, 1024 bit long modulus ............++++++ .......................................++++++ e is 65537 (0x10001) [root@web ssl]# openssl req -new -key httpd.key -out httpd.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:HN State or Province Name (full name) []:ZZ Locality Name (eg, city) [Default City]:^C [root@web ssl]# openssl req -new -key httpd.key -out httpd.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [XX]:CN State or Province Name (full name) []:HN Locality Name (eg, city) [Default City]:ZZ Organization Name (eg, company) [Default Company Ltd]:test Organizational Unit Name (eg, section) []:test Common Name (eg, your name or your server's hostname) []:pma.test.com Email Address []:[email protected] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: #編輯httpd-ssl.conf,,指定好虛擬主機以及證書和祕鑰的位置 DocumentRoot "/web/phpmyadmin" ServerName pma.test.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.21.251:9000/web/phpmyadmin/$1 ErrorLog "logs/pma_error_log" CustomLog "logs/pma_access_log" common SSLCertificateFile "/etc/httpd24/ssl/httpd.crt" SSLCertificateKeyFile "/etc/httpd24/ssl/httpd.key" #註釋pma.test.comzaihttpd-vhost文件中的配置
安裝完成,由於本文比較側重於LAMP平臺搭建,且篇幅有限,對於站點安裝方面可能不太詳細,建議大家在安裝站點時,不要僅僅參考本篇博客,另外找點其他的文檔.