http://dl.fedoraproject.org/pub/epel/



一、准备工作

    关闭防火墙、selinux,配置yum源,并移出系统已安装的httpd,mysql,php

    编译安装LAMP+phpMyAdmin


二、安装httpd-2.4.10

    ttpd-2.4.10需要较新版本的apr和apr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包。这里使用源码编译演示。

   1、安装开发工具支持 

            [[email protected] ~]# yum -y groupinstall "Development tools"

            [[email protected] ~]# yum -y groupinstall "Server Platform Development"

            [[email protected] ~]# yum -y install pcre


   2、安装apr    

            [[email protected] /]# tar xf apr-1.5.1.tar.bz2 -C /usr/src/

            [[email protected] /]# cd /usr/src/apr-1.5.1/

            [[email protected] apr-1.5.1]# ./configure --prefix=/usr/local/apr

            [[email protected] apr-1.5.1]# make && make install

    3、安装apr-util

            

            [[email protected] /]# tar xf apr-util-1.5.3.tar.bz2 -C /usr/src/

            [[email protected] /]# cd /usr/src/apr-util-1.5.3/

            [[email protected] apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util

                                         --with-apr=/usr/local/apr/

            [[email protected] apr-util-1.5.3]# make && make install

    4、安装httpd

             

            [[email protected] /]# tar xf httpd-2.4.10.tar.bz2  -C /usr/src/

            [[email protected] /]# cd /usr/src/httpd-2.4.10/

            [[email protected] httpd-2.4.10]# ./configure --prefix=/usr/local/apache 

            --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi 

            --enable-rewrite --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=event

            [[email protected] httpd-2.4.10]# make && make install

   编译参数介绍 

    --prefix=/usr/local/apache24  #→指定其安装位置
    --sysconfdir=/etc/httpd24  #→指定配置文件安装位置
    --enable-so   #→启用基于DSO的方式动态加载模块
    --enable-ssl   #→启用基于https协议的功能
    --enable-cgi   #→启用基于cgi协议的功能
    --enable-rewrite  #→启用支持URL重写的功能
    --with-zlib   #→指定支持在互联网上发送数据报文时,通用的压缩库的API
    --with-pcre  #→指定支持poll的cgi
    --with-apr=/usr/local/apr    #→指定par的安装路径
    --with-apr-util=/usr/local/apr-util/   #→指定par-util的安装路径
    --enable-modules=most   #→启用大多数常用的模块
    --enable-mpms-shared=all   #→启用加载所有的mpm模块
    --with-mpm=event     #→指定接下来httpd的工作模式是even

补充:


(1)构建MPM为静态模块

        在全部平台中,MPM都可以构建为静态模块。在构建时选择一种MPM,链接到服务器中。如果要改变MPM,必须重新构建。为了使用指定的MPM,请在执行configure脚本 时,使用参数 --with-mpm=NAME。NAME是指定的MPM名称。编译完成后,可以使用 ./httpd -l 来确定选择的MPM。 此命令会列出编译到服务器程序中的所有模块,包括 MPM。


(2)构建 MPM 为动态模块


        在Unix或类似平台中,MPM可以构建为动态模块,与其它动态模块一样在运行时加载。 构建 MPM 为动态模块允许通过修改LoadModule指令内容来改变MPM,而不用重新构建服务器程序。在执行configure脚本时,使用--enable-mpms-shared选项即可启用此特性。当给出的参数为all时,所有此平台支持的MPM模块都会被安装。还可以在参数中给出模块列表。默认MPM,可以自动选择或者在执行configure脚本时通过--with-mpm选项来指定,然后出现在生成的服务器配置文件中。编辑LoadModule指令内容可以选择不同的MPM。


5、修改httpd的主配置文件,设置其Pid文件路径


        [[email protected] ~]# vim /etc/httpd24/httpd.conf 

    编译安装LAMP+phpMyAdmin

   

 提供服务脚本

        [[email protected] ~]# vim /etc/rc.d/init.d/httpd24

        #!/bin/bash

        #

        # httpd        Startup script for the Apache HTTP Server

        #

        # chkconfig: - 85 15

        # description: Apache is a World Wide Web server.  It is used to serve \

        #        HTML files and CGI.

        # processname: httpd

        # config: /etc/httpd/conf/httpd.conf

        # config: /etc/sysconfig/httpd

        # pidfile: /var/run/httpd.pid

        

        # Source function library.

        . /etc/rc.d/init.d/functions

        

        if [ -f /etc/sysconfig/httpd ]; then

                . /etc/sysconfig/httpd

        fi

        

        # Start httpd in the C locale by default.

        HTTPD_LANG=${HTTPD_LANG-"C"}

        

        # This will prevent initlog from swallowing up a pass-phrase prompt if

        # mod_ssl needs a pass-phrase from the user.

        INITLOG_ARGS=""

        

        # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server

        # with the thread-based "worker" MPM; BE WARNED that some modules may not

        # work correctly with a thread-based MPM; notably PHP will refuse to start.

        

        # Path to the apachectl script, server binary, and short-form for messages.

        apachectl=/usr/local/apache/bin/apachectl

        httpd=${HTTPD-/usr/local/apache/bin/httpd}

        prog=httpd

        pidfile=${PIDFILE-/var/run/httpd.pid}

        lockfile=${LOCKFILE-/var/lock/subsys/httpd}

        RETVAL=0

        

        start() {

                echo -n $"Starting $prog: "

                LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

                RETVAL=$?

                echo

                [ $RETVAL = 0 ] && touch ${lockfile}

                return $RETVAL

        }

        

        stop() {

          echo -n $"Stopping $prog: "

          killproc -p ${pidfile} -d 10 $httpd

          RETVAL=$?

          echo

          [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

        }

        reload() {

            echo -n $"Reloading $prog: "

            if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then

                RETVAL=$?

                echo $"not reloading due to configuration syntax error"

                failure $"not reloading $httpd due to configuration syntax error"

            else

                killproc -p ${pidfile} $httpd -HUP

                RETVAL=$?

            fi

            echo

        }

        

        # See how we were called.

        case "$1" in

          start)

          start

          ;;

          stop)

          stop

          ;;

          status)

                status -p ${pidfile} $httpd

          RETVAL=$?

          ;;

          restart)

          stop

          start

          ;;

          condrestart)

          if [ -f ${pidfile} ] ; then

            stop

            start

          fi

          ;;

          reload)

                reload

          ;;

          graceful|help|configtest|fullstatus)

          $apachectl [email protected]

          RETVAL=$?

          ;;

          *)

          echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"

          exit 1

        esac

        

        exit $RETVAL

  赋权并开启服务测试

    编译安装LAMP+phpMyAdmin

         编译安装LAMP+phpMyAdmin     


三、在centos7上安装mariadb-5.5.36

   1、为数据库建一个文件存放目录

        [[email protected] ~]# mkdir /mymariadb

        [[email protected] ~]# fdisk /dev/sdb

        [[email protected] ~]# kpartx -a /dev/sdb

        [[email protected] ~]# pvcreate /dev/sdb1

        [[email protected] ~]# vgcreate myvg /dev/sdb1

        [[email protected] ~]# lvcreate -L 11G -n mymariadb myvg

        [[email protected] ~]# mke2fs -t ext4 -b 4096 -m 3 /dev/myvg/mymariadb 

        [[email protected] ~]# vim /etc/fstab 

                        dev/myvg/mymariadb     /mymariadb  ext4    defaults     0 0

        [[email protected] ~]# mount -a

        [[email protected] ~]# mkdir -p /mymariadb/mysql


    2、新建用户以安全方式运行myql

        [[email protected] ~]# mkdir -p /mymariadb/mysql

        [[email protected] ~]# groupadd -r mysql

        [[email protected] ~]# useradd -g mysql -r mysql -s /sbin/nologin 

        [[email protected] ~]# chown -R mysql:mysql /mymariadb/mysql/

   

    3、为数据库提供主配置文件

        [[email protected] src]# tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local/

        [[email protected] src]# cd /usr/local/

        [[email protected] local]# ln -sv mariadb-5.5.36-linux-x86_64/ mysql

        [[email protected] local]# cd mysql/

        [[email protected] mysql]# chown -R root:mysql ./*

        [[email protected] mysql]# mkdir /etc/mysql

        [[email protected] mysql]# cp support-files/my-large.cnf /etc/my.cnf

        [[email protected] mysql]# vim /etc/my.cnf 

                            datadir = /mymariadb/mysql

                            (必须在 [mysqld] 下添加)

  

   4、初始化数据库,并提供服务脚本

        [[email protected] mysql]# scripts/mysql_install_db --user=mysql 

                            --datadir=/mymariadb/mysql/   

        

        [[email protected] mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld

        [[email protected] mysql]# chmod +x /etc/rc.d/init.d/mysqld 

        [[email protected] mysql]# chkconfig --add mysqld

        [[email protected] mysql]# chkconfig --list mysqld

        [[email protected] mysql]# vim /etc/profile.d/mysqld.sh 

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

        [[email protected] mysql]# source /etc/profile.d/mysqld.sh 

        [[email protected] mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql

        [[email protected] mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf

        [[email protected] mysql]# ldconfig  (重新加载库)

        [[email protected] mysql]# service mysqld restart

           Shutting down MySQL. SUCCESS! 

           Starting MySQL.. SUCCESS! 

        [[email protected] mysql]# ss -tnl

        State    Recv-Q Send-Q       Local Address:Port           Peer Address:Port 

   

        LISTEN      0      50              *:3306                   *:*  

    编译安装LAMP+phpMyAdmin



四、安装php-5.3.5

    1、解决依赖关系,这里利用yum安装,自己配置好源

    epel源 http://mirrors.sohu.com/fedora-epel/6/x86_64/

        [[email protected] ~]# yum -y groupinstall Desktop Platform Development

        [[email protected] ~]# yum -y install bzip2-devel libmcrypt-devel

        [[email protected] /]#tar xf libmcrypt-2.5.7.tar.gz 

        [[email protected] /]#cd libmcrypt-2.5.7

        [[email protected] /]#./configure

        [[email protected] /]#make && make install

                

  2、编译安装php-5.3.5

        [[email protected] /]# tar xf php-5.3.5.tar.bz2 -C /usr/local/

        [[email protected] /]# cd /usr/local/php-5.3.5/

        [[email protected] /]#./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml  --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2  --enable-maintainer-zts

        [[email protected] php-5.4.31]# make && make install

 编译参数介绍       

-prefix=/usr/local/PHP           php 安装目录    

--with-apxs2=/usr/local/apache/bin/apxs

--with-config-file-path=/usr/local/PHP/etc   指定php.ini位置

--with-mysql=/usr/local/mysql   mysql安装目录,对mysql的支持

--with-mysqli=/usr/local/mysql/bin/mysql_config    mysql高级访问接口

--with-openssl ;可以支持ssl

--enable-mbstring ;启动多字节字符支持

--with-freetype-dir ;这是让PHP支持GD库的配置选项

--with-jpeg-dir

--with-png-dir

--with-zlib;支持zlib的压缩库

--with-libxml-dir=/usr

--enable-xml ;支持xml格式

--enable-sockets;支持socket方式通信

--with-apxs2=/usr/local/apache/bin/apxs;php针对此接口来编译进apache

--with-mcrypt;支持加密工具

--with-config-file-path=/etc;配置文件文件

--with-config-file-scan-dir=/etc/php.d;找/etc/php.d/下一.ini结尾的文件作为配置文件

--with-bz2

--enable-maintainer-zts;如果MPM为event和worker模型,编译时此处须启用,如果为prefork,它是以mod_php的方式安装的。


说明:

1、这里为了支持apache的worker或event这两个MPM,编译时使用了--enable-maintainer-zts选项。

2、如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。

#  --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd

#本机     -with-mysql=/usr/local/mysql --with-openssl 

        --with-mysqli=/usr/local/mysql/bin/mysql_config

 

    3、为php提供配置文件

        [[email protected] php-5.4.31]# cp php.ini-production /etc/php.ini

    4、编辑apache配置文件httpd.conf,以apache支持php

                [[email protected] php-5.4.31]# vim /etc/httpd24/httpd.conf

            #定位至AddType

            #添加以下俩行

            AddType application/x-httpd-php  .php
                     AddType application/x-httpd-php-source  .phps
                 #定位至DirectoryIndex index.html
                 #修改为:
                 DirectoryIndex  index.php  index.html

   5、 测试

        先给mysql创建一个远程登录帐号

        编译安装LAMP+phpMyAdmin


    6、在httpd服务器上添加一个测试页

        

        [[email protected] /]# cd /usr/local/apache/htdocs

        [[email protected] htdocs]# mv index.html index.php

        [[email protected] htdocs]# vim index.php

    添加如下

编译安装LAMP+phpMyAdmin


编译安装LAMP+phpMyAdmin



五、搭建phpMyadmin管理平台以及phpcms个人


    1、在httpd服务器上关闭主机,开启虚拟主机

        [[email protected] /]# vim /etc/httpd24/httpd.conf

    

编译安装LAMP+phpMyAdmin

编译安装LAMP+phpMyAdmin


    2、编辑虚拟主机文件

    [[email protected] /]# vim /etc/httpd24/extra/httpd-vhosts.conf


编译安装LAMP+phpMyAdmin


    3、安装phpMyadmin

        [[email protected] src]# tar xf phpMyAdmin-3.5.1-all-languages.tar.bz2 

        [[email protected] src]# cp -r phpMyAdmin-3.5.1-all-languages/*                                                         /usr/local/apache/htdocs/phpmyadmin/

        [[email protected] src]# cd /usr/local/apache/htdocs/phpmyadmin/

        [[email protected] phpmyadmin]# cp config.sample.inc.php config.inc.php

        [[email protected] phpmyadmin]# vim config.inc.php 

        编译安装LAMP+phpMyAdmin

    4、访问测试

    

编译安装LAMP+phpMyAdmin

编译安装LAMP+phpMyAdmin


搭建phpcms

     1、编辑虚拟主机文件

        [[email protected] /]# vim /etc/httpd24/extra/httpd-vhosts.conf

    

编译安装LAMP+phpMyAdmin


    2、安装phpcms

        [[email protected] src]# unzip phpcms_v9.5.5_UTF8.zip 

        [[email protected] src]# cd phpcms_v9_UTF8/

        [[email protected] src]# cp -r install_package/ /web/myhttp/htdocs/

        [[email protected] src]# mv install_package/ install

    3、修改phpcms数据库的配置文件

        [[email protected] src]# cd /web/myhttp/htdocs/install/caches/configs

        [[email protected] configs]# vim database.php 

编译安装LAMP+phpMyAdmin


    4、安装测试

    编译安装LAMP+phpMyAdmin


后面就按提示一步一步执行就可以了

详情查看:http://www.phpcms.cn/