php 5.6 + apache 2.4.25

第一步,安装基础组件

                     tar -xf apr-1.5.2.tar.gz

cd apr-1.5.2

./configure --prefix=/usr/local/apr

make

make install

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

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

make

make install

                     yum install libtool-ltdl-devel db4-devel openldap-devel cyrus-sasl-devel expat-devel apr-devel apr-util-devel pcre pcre-devel -y

                     tar -xzvf pcre-8.39.tar.gz

                     cd pcre-8.39

                     ./configure

                     make

                     make install

rpm -ivh libmcrypt-2.5.7-5.el5.x86_64.rpm

rpm -ivh libmcrypt-devel-2.5.7-5.el5.x86_64.rpm

rpm -ivh mhash-0.9.2-6.el5.x86_64.rpm

rpm -ivh mhash-devel-0.9.2-6.el5.x86_64.rpm

rpm -ivh mcrypt-2.6.8-10.el5.x86_64.rpm

第二步,安装httpd

tar -xf httpd-2.4.25.tar.gz

cp -rp apr-1.5.2 httpd-2.4.25/srclib/apr

cp -rp apr-util-1.5.4 httpd-2.4.25/srclib/apr-util

cd httpd-2.4.25

./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=prefork--with-included-apr

make

make install

 

第三步,安装PHP

yum -y install gcc gcc-c++ libxml2 libxml2-devel bzip2 bzip2-devel libmcrypt libmcrypt-devel openssl openssl-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel readline readline-devel libxslt-devel perl perl-devel psmisc.x86_64 recode recode-devel libtidy libtidy-devel  

tar -xzvf php-5.6.27.tar.gz

cd php-5.6.27

./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --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-curl --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-bz2 --disable-maintainer-zts --with-gd --without-per --disable-phar

make

make install

注:关闭线程安全

--enable-maintainer-zts 改为--disable-maintainer-zts

 

cp php.ini-production /usr/local/php/etc/php.ini

修改php.ini

vi /usr/local/php/etc/php.ini

取消注释date.timezone = Asia/Shanghai

(略备用wget  http://pear.php.net/go-pear.phar

/usr/local/php/bin/php go-pear.phar

 

第四步, 修改httpd.conf

      vim /etc/httpd24/httpd.conf

      1、添加如下二行

      AddType application/x-httpd-php  .php

      AddType application/x-httpd-php-source  .phps

 

      2、定位至DirectoryIndex index.html

       修改为:

       DirectoryIndex  index.php  index.html

      3、添加

       PidFile  "/var/run/httpd24.pid"

       检查语法/usr/local/apache/bin/apachectl -t

     注:(/usr/local/apache/modules/libphp5.so 确保有这个模块)

 

第五步,配置启动httpd脚本

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/httpd24.pid}

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

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

 

 

 

附权:

chmod +x /etc/rc.d/init.d/httpd24

chkconfig --add httpd24

 

service httpd24 start

第六步,编辑相关测试页面

开启mysql服务

编写连接mysql测试页面:

     vim /yd/index.php

<?php

      $link = mysql_connect('127.0.0.1','root','3QgXSno9TEpBK2rz');

      if ($link)

        echo "Success...";

      else

        echo "Failure...";

      mysql_close();

?>

编写phpindo测试页面:index.php

<?php phpinfo(); ?>

 

第七步,配置php支持redis、memcache、zip

     yum install autoconf

     wget http://10.0.42.1:4201/soft/phpredis-master.zip

     cd phpredis-master

     /usr/local/php/bin/phpize

     ./configure --with-php-config=/usr/local/php/bin/php-config

     Make

     Make install

 

                 tar -xf memcache-2.2.7.tgz

cd memcache-2.2.7

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

 

tar -xf zip-1.13.5.tgz

cd zip-1.13.5

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

 

     vi /usr/local/php/etc/php.ini

     尾部加入extension=/usr/local/php/lib/php/extensions/no-debug-zts-20131226/redis.so

         extension=/usr/local/php/lib/php/extensions/no-debug-zts-20131226/memcache.so

        extension=/usr/local/php/lib/php/extensions/no-debug-zts-20131226/zip.so

 

     重启httpd

     Service httpd24 restart

   查看phpinfo

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值