1.本次试验基于LAMP平台搭建()所搭建的环境,搭建三款基于LAMP的站点(WordPress,Drupal以及数据库管理软件phpMyadmin).,另外,本文中关于各站点的安装步骤可能不太详尽,请谅解

    :本篇博客中除特殊说明外大部分站点文件操作需要在webphp两台主机上进行

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

wKiom1PrkImAAyVaAACiJK0WWuw873.jpg 

根据提示信息创建指定文件,这里由于原来没有编译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

现在,安装条件全部满足,会提示用户设置数据库,按要求设置即可

wKioL1PrkayRZRdLAAGLZp8GqRg837.jpg 

 

5.配置安装WordPress

解压

[root@web ~]# unzip wordpress-3.9-zh_CN.zip -d /web/wordpress/
#按提示提供配置文件,安装


 

wKioL1PrkbGzWsaGAAEhrjdbK2g285.jpg 

根据提示按步骤进行安装

wKiom1PrkJvz52FPAABktEEVIF8976.jpg 

安装成功

 

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'; # 设置服务器地址

 wKioL1PrkbeiKoGqAACcaYC-oiM745.jpg

:由于phpmysql不在一台服务器上,所以需要在mysql设定指定用户从php访问的权限才可访问服务器,没有权限的数据库在这里是看不到的

 

wKiom1PrkKSyUdRNAAEr7Ie3N6Y127.jpg

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 []:admin@test.com
 
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文件中的配置


wKioL1PrkcHy1Wt_AADc3xJzMqA405.jpg 

 


安装完成,由于本文比较侧重于LAMP平台搭建,且篇幅有限,对于站点安装方面可能不太详细,建议大家在安装站点时,不要仅仅参考本篇博客,另外找点其他的文档.