CentOS 7, apm + xcache, rpm包, php module;

    a) 一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress;

    b) 为phpMyAdmim提供https服务;

   主机IP:172.16.72.5

   关闭该主机防火墙:

     iptables -F

     setenforce 0

   安装php,mariadb,httpd

    LAMP综合应用_LAMP

   启动服务:

    LAMP综合应用_编译构建_02

  

  配置wordpress:

   使用mysql命令:

   进入数据库,创建数据库wpdb,并给该数据库创建用户,给用户给予操作权限

    LAMP综合应用_编译构建_03

    LAMP综合应用_编译构建_04

  

  将wordpress中的wp-config-sample.php复制为wp-config.php并修改其配置文件为:

    LAMP综合应用_编译构建_05

  在/myweb/vhosts/www1中构建index.php测试php是否能连接

    LAMP综合应用_构建_06

  结果可连接:

    LAMP综合应用_编译构建_07

  

   访问wordpress

    LAMP综合应用_编译构建_08

  wordpress配置成功;

 

 配置phpMyAdmin:

  在/etc/httpd/conf.d/ssl.conf下配置phpMyAdmin与其https

   LAMP综合应用_LAMP_09


  在本台主机上生成私钥与证书请求文件,并将证书请求文件发往私人CA处:

  #(umask 077;openssl genrsa -out /etc/httpd/conf/ssl/httpd.key 4096)

  #openssl req -new -key /etc/httpd/conf/ssl/httpd.key -out /etc/httpd/conf/ssl/httpd.csr

 -days 365

  #scp /etc/httpd/conf/ssl/httpd.csr 172.16.72.1:/tmp

  172.16.72.1私人CA处:

  生成私人CA:

  #(umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 4096)

  #openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem

  -days 365

  #openssl ca -in /tmp/httpd.csr -out /tmp/httpd.crt


  注意:私人CA的地址要与客户端证书请求文件一致;


  https访问静态页面,测试php连通性:

   LAMP综合应用_编译构建_10

  将phpMyAdmin导入/myweb/vhosts/www2下

   LAMP综合应用_编译构建_11

  

  直接访问:

   LAMP综合应用_构建_12


  xcache安装:

   可以编译安装,也可以联网使用yum源安装

   yum install php-xcache

   编辑/etc/php.d/xcache.ini

    LAMP综合应用_LAMP_13


  CentOS 7, amp + xcache, rpm包,php-fpm;

    a) httpd, php, mariadb分别部署在一个单独的主机上;

    b) 一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress;

    c) 为phpMyAdmim提供https服务;

   httpd的主机:172.16.72.5

   php-fpm的主机:172.16.72.2

   Mariadb的主机:172.16.72.9


   ①部署httpd

    关闭该主机防火墙:

      iptables -F

      setenforce 0

    使用本地光盘中的安装包安装httpd

    yum install httpd

    构建虚拟主机1在/etc/httpd/conf.d/vhosts-www.conf

     LAMP综合应用_构建_14

   httpd配置如上,开启反向代理,设置过滤器match过滤,将php的动态页面由172.16.72.2的主机

   访问;

   重新加载httpd服务systemctl reload httpd.service

   ②部署php-fpm

   关闭该主机防火墙:

    iptables -F

    setenforce 0

   安装php-fpm

     yum install php-fpm 

   安装php与mysql交互的php-mysql

     yum install php-mysql

   在该php-fpm主机上,构建在httpd配置文件中对应的映射路径/myweb/vhosts/www1

     mkdir -pv /myweb/vhosts/www1

   修改php-fpm的附属配置文件/etc/php-fpm.d/www.conf

   listen = 172.16.72.2:9000    (监控本机IP地址)

   listen.allowed_clients = 172.16.72.5 (监控httpd客户端传来的请求)

  映射路径下构建index.php,并将wordpress导入

    LAMP综合应用_编译构建_15

   index.php:测试httpd主机与php主机的连通性

    LAMP综合应用_构建_16

   测试结果:访问httpd主机,可以访问到php主机

    LAMP综合应用_构建_17

  安装wordpress:

    #cd wordpress

    #cp wp-config-sample.php wp-config.php

    #vim wp-config.php

    设置wordpress数据库信息

    LAMP综合应用_构建_18

  172.16.72.9为第三个Mariadb主机的IP地址

   

   ③部署Mariadb

   关闭防火墙:

     iptables -F

     setenforce 0

   安装Mariadb

     #yum install mariadb-server

     #mysql (进入mysql界面)

   给用户设置访问权限:

    LAMP综合应用_LAMP_19

 

  访问结果:

   www.wujunqi.com/wordpress/index.php

    LAMP综合应用_编译构建_20


 安装phpMyAdmin:

   设置https:

   在/etc/httpd/conf.d/ssl.conf中设置

   LAMP综合应用_LAMP_21

  www2中的静态资源:

   LAMP综合应用_编译构建_22

  关闭防火墙:

   iptables -F

   setenforce 0

  重载httpd:

   systemctl reload httpd.service

  httpd主机中的phpadmin虚拟主机访问自身静态资源结果:

   LAMP综合应用_编译构建_23

  将phpMyAdmin导入到第二台主机的/etc/myweb/www2目录下

  通过https://www.wujunqi2.com/index.php确定php与数据库是否连接  

  访问结果:

     LAMP综合应用_LAMP_24

    LAMP综合应用_构建_25


   访问phpMyAdmin

    LAMP综合应用_构建_26


  xcache安装:

   可以编译安装,也可以联网使用yum源安装

   yum install php-xcache

   编辑/etc/php.d/xcache.ini

    LAMP综合应用_LAMP_13


   CentOS 7, amp + xcache,编译安装,php-fpm;

     a) httpd, php, mariadb分别部署在一个单独的主机上,以及都在同一主机;

b) 一个虚拟主机提供phpMyAdmin,另一个虚拟主机提供wordpress;

c) 为phpMyAdmim提供https服务;

  

   编译安装httpd,php,mariadb在同一主机上:

    关闭防火墙:

     iptables -F

     setenforce 0

    确定在该主机上没有使用rpm包的形式安装过php,php-fpm,mariadb-server,mysql-server,    httpd

    安装编译环境:

     yum groupinstall "Development Tools" "Server Platform Development"

    编译安装apr-1.5.2:

     将apr-1.5.2,apr-util-1.5.4,httpd-2.4.27导入到主机中,并解压

     #cd apr-1.5.2

     #./configure --prefix=/usr/local/apr152

     #make -j 4

     #make install


    编译安装apr-util-1.5.4:

     #tar xf apr-util-1.5.4.tar.gz

     #cd apr-util-1.5.4

     #./configure --prefix=/usr/local/apr-util154 --with-apr=/usr/local/apr152

     #make -j #

     #make install

  

    编译安装httpd-2.4.27:

     #tar xf httpd-2.4.27.tar.gz

     #cd httpd-2.4.27

     #./configure --prefix=/usr/local/apache24 --with-apr=/usr/local/apr152 --with-apr-      util=/usr/local/apr-util154 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --      enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-      mpm=prefork --with-pcre --with-zlib

     #make -j 4

     # make install

     注意:需要实现安装pcre-devel,当时用--with-pcre时

         yum install pcre-devel

         若出现mod_ssl缺失,则安装openssl-devel

         yum install openssl-devel

    导出二进制文件:在/etc/profile.d下

      LAMP综合应用_编译构建_28

      LAMP综合应用_构建_29

     . /etc/profile.d/httpd24.sh

     使文件生效,并查看

      LAMP综合应用_构建_30

     输出PATH变量,可看出,该文件中的环境变量已生效


    因为在/usr/local/apache24下没有lib等库文件,所以不需要导出库文件;


    导出头文件:

      LAMP综合应用_编译构建_31

   启动httpd:

      LAMP综合应用_构建_32

    

   编译安装MariaDB:

    将mariadb-5.5.57-linux-x86_64.tar.gz导入

    #tar -xf mariadb-5.5.57-linux-x86_64.tar.gz -C /usr/local

    #cd /usr/local

    #ln -sv mariadb-5.5.57-linux-x86_64 mysql

    #cd mysql

    #groupadd -r -g 306 mysql

    #useradd -r -u 306 mysql

    #chown -R mysql:mysql *

    #mkdir -pv /mydata/data

    #chown mysql:mysql /mydata/data

    #cp support-file/my-large.cnf /etc/my.cnf

    #cp support-file/mysql-server /etc/init.d/mysqld

   修改/etc/my.cnf配置文件

    LAMP综合应用_编译构建_33

   导出二进制文件:/etc/profile.d/mariadb5557.sh

   export PATH=/usr/local/mysql/bin:$PATH

   

   导出库文件:/etc/ld.so.conf.d/mariadb5557.conf

   /usr/local/mysql/lib


   ldconfig -v

   并将/etc/ld.so.conf.d/中的mariadb-x86_64.conf改成不以conf结尾的;


   初始化数据库:

    scripts/mysql_install_db --user=mysql --datadir=/mydata/data


   启动数据库:

    service mysqld start

    LAMP综合应用_编译构建_34


  编译php:

    将php-5.6.31.tar.bz2导入

    #tar -xf php-5.6.31.tar.bz2

    #cd php-5.6.31

    #./configure --prefix=/usr/local/php56 --enable-fpm --with-mysql=/usr/local/mysql --     with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl --enable-mbstring --       enable-xml --enable-sockets --with-freetype-dir --with-libxml-dir=/usr --with-zlib --     with-apxs2=/usr/local/apache24/bin/apxs --with-config-file-path=/etc/php56.ini --       with-config-file-scan-dir=/etc/php56.d

    #make -j 4

    #make install

    #cp php.ini-production /etc/php56.ini

    #mkdir /etc/php56.d

    #cp sapi/fpm/php-fpm.conf /etc/php56.d

    #vim /etc/profile.d/php56.sh

    导出二进制文件

      export PATH=/usr/local/php56/bin:/usr/local/php56/sbin:$PATH

    #. /etc/profile.d/php56.sh将其写入

    导出库文件

    #vim /etc/ld.so.conf.d/php56.conf

      /usr/local/php56/lib

    #ldconfig -v

    导出头文件

    #ln -sv /usr/local/php56/include /usr/include/php-fpm

    到这步php-fpm就可以执行了;

    使用#php-fpm -y /etc/php56.d/php-fpm.conf start

    注意:在启动前,务必将进程php-fpm关闭,否则启动会失败


  为php-fpm提供SysV风格脚本,并将其添加至服务列表:

    # cp sapi/fpm/init.d.php-fpm  /etc/rc.d/init.d/php-fpm

    # chmod +x /etc/rc.d/init.d/php-fpm

    # chkconfig --add php-fpm

    # chkconfig php-fpm on

   在/etc/rc.d/init.d/php-fpm下写入:

    LAMP综合应用_构建_35

   执行:

    LAMP综合应用_编译构建_36


   至此httpd,mariadb,php-fpm全部编译完成;


 在编译环境下安装wordpress:

 将wordpress安装包导入,解压

 httpd配置

  虚拟主机配置,将虚拟主机写入/etc/httpd24/extra/httpd-vhostsconf

   LAMP综合应用_LAMP_37

  如果直接这么写,httpd会报语法错误proxy,需要将/etc/httpd24/httpd.conf主配置文件中的

 proxy_module和proxy_http的注释消除,使其执行

    LAMP综合应用_LAMP_38

    LAMP综合应用_编译构建_39

  

  mariadb配置:

   创建wordpress数据库,并设置用户权限;

    LAMP综合应用_构建_40

  

  将wordpress中的wp-config-sample.php备份改名;

  #cp wp-config-sample.php wp-config.php

  修改wp-config.php的配置

   LAMP综合应用_构建_41

 在/myweb/vhosts/www1中写入一个index.php文件测试php,httpd,mariadb的连通性

   LAMP综合应用_构建_42


 访问www.wujunqi.com

   LAMP综合应用_编译构建_43

   LAMP综合应用_构建_44

  

 连通性没有问题,访问wordpress进行安装;

 访问www.wujunqi.com/wordpress

   LAMP综合应用_编译构建_45

  访问成功

 

  安装phpMyAdmin:

   配置https:

    生成私人CA:这里就不过多阐述了,上面都说过很多次了;

    将证书请求文件返还到客户端:

      LAMP综合应用_编译构建_46

    

    修改主配置文件/etc/httpd/httpd.conf

      LAMP综合应用_构建_47

      LAMP综合应用_编译构建_48

      LAMP综合应用_构建_49

      LAMP综合应用_构建_50


    将https相关代码写在/etc/httpd/extra/httpd-ssl.conf

     LAMP综合应用_编译构建_51

    重启httpd服务

    apachectl restart

    将私人CA的公钥导入浏览器

    

    访问phpMyAdmin

     LAMP综合应用_构建_52


 将httpd,mariadb,php-fpm分别便宜到三台主机上,第一台虚拟主机实现wordpress,第二台主机实现phpMyAdmin和其https功能;

  

  编译httpd在172.16.72.4主机上:

    关闭防火墙:

     iptables -F

     setenforce 0

    确定在该主机上没有使用rpm包的形式安装过php,php-fpm,mariadb-server,mysql-server,    httpd

    安装编译环境:

     yum groupinstall "Development Tools" "Server Platform Development"

     yum install pcre-devel zlib-devel openssldevel apr-devel apr-util-devel 


    编译安装apr-1.5.2:

     将apr-1.5.2,apr-util-1.5.4,httpd-2.4.27导入到主机中,并解压

     #cd apr-1.5.2

     #./configure --prefix=/usr/local/apr152

     #make -j 4

     #make install


    编译安装apr-util-1.5.4:

     #tar xf apr-util-1.5.4.tar.gz

     #cd apr-util-1.5.4

     #./configure --prefix=/usr/local/apr-util154 --with-apr=/usr/local/apr152

     #make -j #

     #make install

  

    编译安装httpd-2.4.27:

     #tar xf httpd-2.4.27.tar.gz

     #cd httpd-2.4.27

     #./configure --prefix=/usr/local/apache24 --with-apr=/usr/local/apr152 --with-apr-      util=/usr/local/apr-util154 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --      enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-      mpm=prefork --with-pcre --with-zlib

     #make -j 4

     # make install

  

    在httpd中的/etc/httpd24/extra/httpd-vhosts.conf中

    wordpress相关配置文件

     LAMP综合应用_编译构建_53

    phpMyAdmin相关配置在/etc/httpd24/httpd.ssl.conf

     LAMP综合应用_编译构建_54

     LAMP综合应用_编译构建_55  

     LAMP综合应用_LAMP_56

     LAMP综合应用_LAMP_57

     LAMP综合应用_编译构建_58

     LAMP综合应用_编译构建_59


   编译php-fpm在172.16.72.5主机上,该主机上已经编译了httpd,mariadb,编译方式如上;

   修改编译后的php-fpm的主配置文件,让其能够接收到172.16.72.4主机上发过来的httpd请求;

   在/etc/php56.d/php-fpm.conf中

     LAMP综合应用_LAMP_60

   监听172.16.72.4主机发来的请求:

     LAMP综合应用_编译构建_61

   测试172.16.72.4主机是否能访问到172.16.72.5主机中的index.php

   172.16.72.5中:

     LAMP综合应用_LAMP_62

   测试结果:

       LAMP综合应用_编译构建_63

    

   编译Mariadb在172.16.72.9主机上:

   编译方法如上;

   编译成功后创建wordpress的数据库,以及使用该数据库的用户和密码,用户的权限;

     LAMP综合应用_构建_64

   

   在172.16.72.5主机上导入wordpress安装包,修改其配置文件

     cp wp-config-sample.php wp-config.php

   修改wp-config.php

     LAMP综合应用_LAMP_65

    将MySQL主机指向172.16.72.9主机中的mariadb;

   到此wordpress配置结束;

   重载三个主机的相关配置;

  

   访问wordpress进行安装:

   www.wujunqi.com/wordpress/index.php

    LAMP综合应用_构建_66


  设置https的phpMyAdmin

  将phpMyAdmin导入172.16.72.5主机中

   LAMP综合应用_LAMP_67

  之前已经在httpd的172.16.72.4主机中的httpd-ssl.conf中设置https相关代码;以之前从私人CA,即172.16.72.9主机上获取的请求证书,将其导入浏览器中;直接访问即可;

  谷歌浏览器中的证书导入:

   LAMP综合应用_构建_68

  直接访问即可:

  https://www.wujunqi2.com/phpMyAdmin-3.5.4-all-languages

   LAMP综合应用_编译构建_69