设为首页 收藏本站
查看: 1447|回复: 0

编译安装LAMP+phpMyAdmin

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-8-14 17:36:58 | 显示全部楼层 |阅读模式
一、准备工作
    关闭防火墙、selinux,配置yum源,并移出系统已安装的httpd,mysql,php

    wKiom1PrELvhQC2ZAAM-fNhJrDI080.jpg

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

            [iyunv@90sec /]# tar xf apr-1.5.1.tar.bz2 -C /usr/src/
            [iyunv@90sec /]# cd /usr/src/apr-1.5.1/
            [iyunv@90sec apr-1.5.1]# ./configure --prefix=/usr/local/apr
            [iyunv@90sec apr-1.5.1]# make && make install
    2、安装apr-util


            [iyunv@90sec /]# tar xf apr-util-1.5.3.tar.bz2 -C /usr/src/
            [iyunv@90sec /]# cd /usr/src/apr-util-1.5.3/
            [iyunv@90sec apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util
                                         --with-apr=/usr/local/apr/
            [iyunv@90sec apr-util-1.5.3]# make && make install
    3、安装httpd


            [iyunv@90sec /]# tar xf httpd-2.4.10.tar.bz2  -C /usr/src/
            [iyunv@90sec /]# cd /usr/src/httpd-2.4.10/
            [iyunv@90sec 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
            [iyunv@90sec 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。

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

        [iyunv@90sec ~]# vim /etc/httpd24/httpd.conf
    wKioL1PrJAPA3XSiAAC8lcYgSlE895.jpg

提供服务脚本

        [iyunv@90sec ~]# 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 $@
          RETVAL=$?
          ;;
          *)
          echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
          exit 1
        esac

        exit $RETVAL
  赋权并开启服务测试
    wKiom1PrJKiQ42R5AAGqCib8reQ862.jpg
          wKiom1PrJd7iG0SUAAC2PU-9DNM566.jpg      


三、在centos7上安装mariadb-5.5.36

   1、为数据库建一个文件存放目录
        [iyunv@90src ~]# mkdir /mymariadb
        [iyunv@90src ~]# fdisk /dev/sdb
        [iyunv@90src ~]# kpartx -a /dev/sdb
        [iyunv@90src ~]# pvcreate /dev/sdb1

        [iyunv@90src ~]# vgcreate myvg /dev/sdb1
        [iyunv@90src ~]# lvcreate -L 11G -n mymariadb myvg
        [iyunv@90src ~]# mke2fs -t ext4 -b 4096 -m 3 /dev/myvg/mymariadb
        [iyunv@90src ~]# vim /etc/fstab

                        dev/myvg/mymariadb     /mymariadb  ext4    defaults     0 0
        [iyunv@90src ~]# mount -a
        [iyunv@90src ~]# mkdir -p /mymariadb/mysql

    2、新建用户以安全方式运行myql
        [iyunv@90src ~]# mkdir -p /mymariadb/mysql
        [iyunv@90src ~]# groupadd -r mysql
        [iyunv@90src ~]# useradd -g mysql -r mysql -s /sbin/nologin
        [iyunv@90src ~]# chown -R mysql:mysql /mymariadb/mysql/

    3、为数据库提供主配置文件
        [iyunv@90src src]# tar xf mariadb-5.5.36-linux-x86_64.tar.gz -C /usr/local/
        [iyunv@90src src]# cd /usr/local/
        [iyunv@90src local]# ln -sv mariadb-5.5.36-linux-x86_64/ mysql
        [iyunv@90src local]# cd mysql/
        [iyunv@90src mysql]# chown -R root:mysql ./*
        [iyunv@90src mysql]# mkdir /etc/mysql

        [iyunv@90src mysql]# cp support-files/my-large.cnf /etc/my.cnf
        [iyunv@90src mysql]# vim /etc/my.cnf
                            datadir = /mymariadb/mysql
                            (必须在 [mysqld] 下添加)


   4、初始化数据库,并提供服务脚本
        [iyunv@90src mysql]# scripts/mysql_install_db --user=mysql
                            --datadir=/mymariadb/mysql/   


        [iyunv@90src mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
        [iyunv@90src mysql]# chmod +x /etc/rc.d/init.d/mysqld
        [iyunv@90src mysql]# chkconfig --add mysqld
        [iyunv@90src mysql]# chkconfig --list mysqld
        [iyunv@90src mysql]# vim /etc/profile.d/mysqld.sh
                             export PATH=/usr/local/mysql/bin:$PATH
        [iyunv@90src mysql]# source /etc/profile.d/mysqld.sh
        [iyunv@90src mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql
        [iyunv@90src mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
        [iyunv@90src mysql]# ldconfig  (重新加载库)
        [iyunv@90src mysql]# service mysqld restart
           Shutting down MySQL. SUCCESS!
           Starting MySQL.. SUCCESS!
        [iyunv@90src mysql]# ss -tnl
        State    Recv-Q Send-Q       Local Address:Port           Peer Address:Port

        LISTEN      0      50              *:3306                   *:*  
    wKioL1PrZZiCHL80AAGvCS0ZbDQ647.jpg


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

    epel源 http://mirrors.sohu.com/fedora-epel/6/x86_64/
        [iyunv@90sec ~]# yum -y groupinstall Desktop Platform Development
        [iyunv@90sec ~]# yum -y install bzip2-devel libmcrypt-devel
        [iyunv@90sec /]#tar xf libmcrypt-2.5.7.tar.gz
        [iyunv@90sec /]#cd libmcrypt-2.5.7
        [iyunv@90sec /]#./configure
        [iyunv@90sec /]#make && make install

  2、编译安装php-5.3.5
        [iyunv@90sec /]# tar xf php-5.3.5.tar.bz2 -C /usr/local/

        [iyunv@90sec /]# cd /usr/local/php-5.3.5/
        [iyunv@90sec /]#./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
        [iyunv@90sec 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

    3、为php提供配置文件

        [iyunv@90sec php-5.4.31]# cp php.ini-production /etc/php.ini
    4、编辑apache配置文件httpd.conf,以apache支持php
                [iyunv@90sec 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


wKiom1PrloKhhQ_WAAG79MuMcd8499.jpg






运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-23821-1-1.html 上篇帖子: lamp平台三种实现方式 下篇帖子: Linux之使用rpm包搭建LAMP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表