博客 2016-01-01


安装需要的依赖:

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \
glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs \
e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap \
openldap-devel nss_ldap openldap-clients openldap-servers pcre-devel libxslt \
libxslt-devel  libtool-ltdl libtool-ltdl-devel

 wget http://au1.php.net/get/php-7.0.1.tar.gz/from/this/mirror


./configure --prefix=/usr/local/php_7.0.1 --with-config-file-path=/usr/local/php_7.0.1/etc  --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql   --with-apxs2



改apache配置文件内模块为libphp7.so

vim /etc/httpd/conf/httpd.conf
LoadModule php7_module        /usr/lib64/httpd/modules/libphp7.so


增加一行解析

/etc/httpd/conf.d/php.conf


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


验证php 版本:

<?php
phpinfo();
?>

遇到问题:


with-apx2 checking for Apache 2.0 handler-module support via DSO through
yum install httpd-devel


php configure: error: Don't know how to define struct flock on this system, set --enable-opcache=no
export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib



如下是编译apache, 如果自己编译的话


wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz 
tar -zxvf libmcrypt-2.5.7.tar.gz 
cd libmcrypt-2.5.7 
./configure
make
make install 
cd ..


wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
 tar -zxf apr-1.5.2.tar.gz
cd apr-1.5.2
 ./configure --prefix=/usr/local/apr 
 make -j18  && make install
 cd ..

 

 wget http://archive.apache.org/dist/apr/apr-util-1.5.3.tar.gz
 tar -zxf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
 make -j18 && make install
 cd ..
 wget http://mirrors.noc.im/apache//httpd/httpd-2.4.18.tar.gz
 tar xzf httpd-2.4.18.tar.gz 
cd httpd-2.4.18
./configure --prefix=/usr/local/apache_2.4.18 \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util 
make -j18 && make install


这个编译的话,最好在php 前面,然后--with-apx2=/youPath/bin/apx2