一、测试环境:CentOS 7,ip地址:172.16.233.2
httpd基于主机名的方式实现如下应用
vhost1: pma.bengbengtu.com, phpMyAdmin
vhost2: wp.bengbengtu.com, wordpress
vhost3: dz.bengbengtu.com, Discuz
二、使用安装包: httpd+mariadb+php
httpd-2.4.6-31.el7.centos.x86_64
mariadb-5.5.41-2.el7_0.x86_64
php-5.4.16-23.el7_0.3.x86_64
三、实现过程
(1)先搭建LAMP,过程如下:
#yum install httpd php php-mysql mariadb-server [root@localhost ~]# getenforce Enforcing [root@localhost ~]# vim /etc/selinux/config //关闭selinux [root@localhost ~]# setenforce 0 [root@localhost ~]# getenforce Permissive [root@localhost ~]# iptables -F //清理防火墙规则 [root@localhost ~]# systemctl disable firewalld.service // 关闭防火墙 [root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# mysql_secure_installation //初始化mariadb,给root用户设置密码,匿名用户删除 [root@localhost ~]#mkdir /www/html/{pma,wp,dz} [root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf //创建httpd的虚拟主机,基于主机名
启动httpd,在每个目录中建立index.php文件,测试没问题!
(2)安装phpMyAdmin
使用的安装包为phpMyAdmin-4.3.5-all-languages.zip
[root@localhost ~]# yum install -y unzip [root@localhost ~]# ll total 9276 -rw-------. 1 root root 1429 Sep 18 23:00 anaconda-ks.cfg drwxr-xr-x. 10 root root 4096 Jan 5 2015 phpMyAdmin-4.3.5-all-languages -rw-r--r--. 1 root root 9489114 Sep 19 07:21 phpMyAdmin-4.3.5-all-languages.zip [root@localhost ~]# mv phpMyAdmin-4.3.5-all-languages /www/html/pma/ [root@localhost pma]# ln -sv phpMyAdmin-4.3.5-all-languages pma ‘pma’ -> ‘phpMyAdmin-4.3.5-all-languages’ [root@localhost pma]# cd pma/ [root@localhost pma]# tr -d 'a-zA-Z0-9_' < /dev/urandom | head -30 | md5sum cb5c094fbc66e3b71c29744b28aff277 - [root@localhost pma]# vim config.inc.php
配置完成,测试,出现问题
/windows/system32/Drivers/etc/hosts //在本机中添加主机名解析 172.16.233.2 pma.bengbengtu.com wp.bengbengtu.com dz.bengbengtu.com [root@localhost pma]# tail /var/log/httpd/error_log //查看错误日志 [root@localhost pma]# yum install -y php-mbstring // 解决方法
至此phpMyAdmin部署完成!
(3)WordPress
使用的安装包为:wordpress-4.3.1-zh_CN.zip
[root@localhost ~]# unzip wordpress-4.3.1-zh_CN.zip [root@localhost ~]# mv wordpress /www/html/wp/ [root@localhost ~]# mysql MariaDB [(none)]> create database wordpress; //创建wordpress数据库 Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all on wordpress.* to 'wpuser'@'localhost' identified by 'wppasswd'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) [root@localhost wp]# chmod 777 wordpress/ //给Wordpress目录权限 [root@localhost wp]# ll total 4 drwxrwxrwx. 5 root root 4096 Sep 16 22:38 wordpress
至此WordPress部署完成!
(4)discuz
使用的安装包为:Discuz_X3.2_SC_UTF8.zip
[root@localhost ~]# unzip Discuz_X3.2_SC_UTF8.zip [root@localhost ~]# rm -rf readme/ utility/ [root@localhost ~]# mv upload/* /www/html/dz/ [root@localhost ~]# chmod 777 /www/html/dz/ [root@localhost ~]# cd /www/html/dz/
[root@localhost dz]# cp config/config_global_default.php config/config_global.php [root@localhost dz]# mv config/config_ucenter_default.php config/config_ucenter.php [root@localhost dz]# chmod 777 data/{cache,avatar,plugindata,download,addonmd5,template,threadcache,attachment/{album,forum,group}} [root@localhost dz]# chmod 777 data [root@localhost dz]# chmod 777 data/attachment/ [root@localhost dz]#chmod 777 data/log/ [root@localhost dz]# chmod 777 uc_client/data/cache/ [root@localhost dz]# chmod 777 uc_server/data/{cache,avatar,backup,logs,tmp,view}
至此discuz部署完成!