实验环境:CentOS7

1、配置虚拟主机

[root@conf.d localhost]#vi /etc/httpd/conf.d/vhost.conf  #配置在/etc/httpd/conf.d下启动会自动加载

 DirectoryIndex index.php     #给所有虚拟主机定义主页

<VirtualHost *:80>  #虚拟主机监听本机所有IP的80端口,本机IP为172.16.253.172
        ServerName www.text1.com  #虚拟主机的FQDN
        DocumentRoot "/data/www"  #网页文件的独立路径,并建立目录和相应文件

      ProxyRequests Off       ##关闭正向代理,即根据IP找主机名
      ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/www/$1    ##定义代理地址

    <Directory "/data/www">     #定义显示授权
        Options FollowSymLinks   #允许打开文件链接
        AllowOverride None      #覆盖禁止
        Require all granted     #请求权限允许
     </Directory>
ErrorLog /var/log/httpd/text1_error.log  #定义错误日志的存放路径,不需要手动创建文件
CustomLog /var/log/httpd/text1_access.log combined  #定义访问日志的存放路径,不需要手动创建文件
</VirtualHost>

 

#新建主页index.php
[root@www localhost]#cat /data/www/index.php <html> <title>centos7-1</title> <body> <h1>test page</h1> </body> </html> <h1><?php $conn = mysql_connect('172.16.253.172','testuser','testpass');  #测试PHP服务是否正常 if ($conn) echo "OK"; else echo "Failure"; ?> </h1> <?php phpinfo(); ?>

 

2、安装mariadb-server,请查看博客:http://www.cnblogs.com/wzhuo/p/6936476.html

3、安装php-fpm包及配置,请查看博客:http://www.cnblogs.com/wzhuo/p/6936999.html

4、下载安装phpMyAdmin

#解压下载的phpMyAdmin文件并复制到/data/www/下,修改其文件下的config.simple.inc.php的文件名为config.inc.php,
#并修改里面的内容$cfg['blowfish_secret'] = 'jngkasfnysagfehfcsdkjdfa8b6d';往单引号里面加字符串;
#由于文件名比较长,建立软连接
[root@~ localhost]#unzip phpMyAdmin-4.0.10.20-all-languages.zip
[root@~ localhost]#cp -av phpMyAdmin-4.0.10.20-all-languages /data/www/
[root@~ localhost]#cd /data/www/
[root@phpMyAdmin-4.0.10.20-all-languages localhost]#cp -av config.sample.inc.php config.inc.php
[root@phpMyAdmin-4.0.10.20-all-languages localhost]#cat config.inc.php
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * phpMyAdmin sample configuration, you can use it as base for
 * manual configuration. For easier setup you can use setup/
 *
 * All directives are explained in documentation in the doc/ folder
 * or at <https://docs.phpmyadmin.net/>.
 *
 * @package PhpMyAdmin
 */

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = 'jngkasfnysagfehfcsdkjdfa8b6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
[root@www localhost]#ln -sv phpMyAdmin-4.0.10.20-all-languages phpmyadmin
‘phpmyadmin/phpMyAdmin-4.0.10.20-all-languages’ -> ‘phpMyAdmin-4.0.10.20-all-languages’

5、测试:

  1)http://172.16.253.172

 

  2)http://172.16.253.172/phpmyadmin/

  报错:phpmyadmin提示:The mbstring extension is missing. Please check your PHP configuration.

[root@~ localhost]#yum -y install php-mbstring  #安装缺少的包
[root@~ localhost]#systemctl restart httpd.service  #重启httpd服务

 

  3)在/etc/httpd/conf.d/vhost.conf下,添加如下:

    ProxyPassMatch ^/(pmstatus.*)$ fcgi://127.0.1:9000/$1 或者

    ProxyPassMatch ^/(pmstatus|ping.*)$ fcgi://127.0.1:9000/$1

[root@www localhost]#httpd -t
Syntax OK
[root@www localhost]#systemctl restart httpd.service

 

 

 

附:三台主机搭建过程,http://www.cnblogs.com/wzhuo/p/6939970.html 。