(1) 三者分离于三台主机;(编译安装,模块或php-fpm);
(2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress;
(3) xcache;
(4) 尝试mpm为非prefork机制;
host | ip | software | 平台 |
---|---|---|---|
主机1 | 172.18.253.33 | httpd | CentOS 6 |
主机2 | 172.18.253.34 | php-fpm | CentOS 6 |
主机3 | 172.18.253.35 | mariadb | CentOS 6 |
1.实验前先将 iptables 和 SELinux 均设置为关闭状态,避免影响实验结果。
2.首先配置 mariadb的服务器主机3,再配置 php-fpm的服务器主机2,最后配置httpd的服务器主机1,按照从后到前的顺序。
二进制安装MariaDB
初始化数据库安全设置
mysql_secure_installation
配置MariaDB
# 授权root可从172.18.253.0/24网段内的主机登录操作所有数据库。 MariaDB [(none)]> grant all privileges on *.* to 'root'@'172.18.253.%' identified by 'mageedu'; # 给wordpress创建数据wpdb。 MariaDB [(none)]> create database wpdb; # 给wordpress创建用户wp。 MariaDB [(none)]> create user 'wp'@'172.18.253.%' identified by 'mageedu'; # 授权wp可从172.18.253.0/24网段内的主机登录操作wpdb数据库。 MariaDB [(none)]> grant all privileges on wpdb.* to 'wp'@'172.18.253.%' identified by 'mageedu'; # 重载权限表 MariaDB [(none)]> flush privileges; # 退出MariaDB [(none)]> \q
测试连接MariaDB
[root@localhost ~]# yum install -y mysql [root@localhost ~]# mysql -uroot -h172.18.253.35 -pmageedu
环境配置:安装开发工具包
# yum -y groupinstall "Server Platform Development" "Development tools" # yum -y install bzip2-devel libmcrypt-devel libxml2-devel
编译安装php
~]# tar -xf php-5.4.40.tar.bz2 ~]# ./configure --prefix=/usr/local/php5 --with-openssl --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts ~]# make && make install
配置php、php-fpm
# cp php.ini-production /etc/php.ini ]# mkdir /etc/php.d/ ]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf ]# vim /usr/local/php/etc/php-fpm.conf # 配置启用pid文件和error_log pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm/error.log
安装php-mysql
]# yum -y install php-mysql
编译安装xache
# yum install php-devel # cd xcache-3.2.0 # phpize (在当前目录生成configure 脚本,让它了解php环境) # ./configure �enable-xcache �with-php-config=/usr/bin/php-config # make && make install # cp xcache.ini /etc/php.d/
环境配置:安装开发工具包
# yum -y groupinstall "Server Platform Development" "Development tools" # yum -y install pcre-devel
编译安装httpd2.4
(1) apr-1.4+
# ./configure --prefix=/usr/local/apr 【指明安装到/usr/local/apr目录下】 # make && make install 【第一个命令如果成功运行则执行第二个】
(2) apr-util-1.4+
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 【当安装某包时依赖某程序包,告诉他位置,此处 --with-apr=/usr/local/apr 则表示告诉依赖包的 apr包 在 /usr/local/apr目录下】 # make && make install
(3) httpd-2.4(安装时可以指明以那个用户来运行,不指定的话默认是daemon用户)
# ./configure �prefix=/usr/local/apache24 �sysconfdir=/etc/httpd24 �enable-so �enable-ssl �enable-cgi �enable-rewrite(支持URL重写) �with-zlib �with-pcre �with-apr=/usr/local/apr �with-apr-util=/usr/local/apr-util �enable-modules=most �enable-mpms-shared=all �with-mpm=worker # make && make install
设置httpd24 服务service 启动 和开机默认启动方法
查看验证是否为worker模型
安装wordpress(本处提供安装方法,安装包自行下载)
安装phpMyAdmin(本处提供安装方法,安装包自行下载)
cp phpMyAdmin-4.4.14.1-all-language.zip /webcom/c.org/pma unzip phpMyAdmin-4.4.14.1-all-language.zip ln -sv phpMyAdmin-4.4.14.1-all-language phpadmin cd phpadmin/cp config.sample.inc.php config.inc.php openssl rand -base64 15 vim config.inc.phpsystemctl restart httpd.service
配置虚拟主机1
[root@localhost ~]# vim /etc/httpd/conf.d/virtualhost1.conf <VirtualHost *:80> ServerName www.b.net DocumentRoot "/webcom/b.net/wp" <Directory "/webcom/b.net/wp"> Options None AllowOverride None Require all granted </Directory> </VirtualHost> [root@localhost ~]# mkdir -pv /webcom/b.net/wp mkdir: created directory ‘/webcom/b.net’ mkdir: created directory ‘/webcom/b.net/wp’
配置虚拟主机2
[root@localhost ~]# vim /etc/httpd/conf.d/virtualhost2.conf <VirtualHost *:80> ServerName www.c.org DocumentRoot "/webcom/c.org/pma" <Directory "/webcom/c.org/"> Options None AllowOverride None Require all granted </Directory> </VirtualHost> [root@localhost ~]# mkdir -pv /webcom/c.org/pma mkdir: created directory ‘/webcom/c.org’ mkdir: created directory ‘/webcom/c.org/pma’
至此,实验完成!