一、编译环境准备
apt-get install gcc
apt-get install make
apt-get install gcc-c++
apt-get install make automake
apt-get install cmake
apt-get install libpcre3 libpcre3-dev
apt-get install libtoolapt-get install openssl
apt-get install libxml2 libxml2-dev
apt-get install libmhash-dev
apt-get install libmcrypt-dev
apt-get install mcrypt
apt-get install curl
apt-get install libbz2-dev
apt-get install libssl-dev libsslcommon2-dev
上面就是一些编译工具外加一些可以借用的第三方软件,例如pcre和openssl mcrypt 等,这些第三方软件其实是为了给apache和php调用的,这样就能增加其功能。二、编译安装apache编译安装zlibtar -zxpf zlib-1.2.8.tar.gzcd zlib-1.2.8./configure –prefix=/data/service/zlib;make -j2 && make install编译安装aprtar -zxpf apr-1.5.2_change.tar.gz cd apr-1.5.2./configure –prefix=/data/service/apr;make -j2 && make install编译安装apr-utiltar -zxpf apr-util-1.5.4.tar.gzcd apr-util-1.5.4./configure –prefix=/data/service/apr-util –with-apr=/usr/local/apr/bin/apr-1-config;make -j2 && make install编译安装apachetar -zxpf httpd-2.4.16.tar.gz cd httpd-2.4.16
./configure --prefix=/data/service/apache2416 \--with-mpm=prefork \--enable-so \--enable-rewrite \--enable-mods-shared=most \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util
make -j2 && make install
备注:1.${APACHE_DIR} 是apache的安装目录,具体直接写也可以2.${SOFT_DIR} 是普通软件的安装目录,一般是/usr/local,这样方便使用,apr和apr-util之所以要特别写安装路径是因为apache编译的时候需要指定这2个软件的目录
三、编译安装php编译安装libiconvtar -zxpf libiconv-1.14.tar.gzcd libiconv-1.14
./configure --prefix=/data/service/libiconv ;make && make install编译安装curltar -zxpf curl-7.43.0.tar.gzcd curl-7.43.0./configure --prefix=/data/service/curl --with-ssl;make && make install编译安装freetypetar -zxpf freetype-2.6.tar.gzcd freetype-2.6./configure --prefix=/data/service/freetype ;make && make install编译安装jpegtar -zxpf jpegsrc.v9a.tar.gz cd jpeg-9a./configure --prefix=/data/service/jpeg-9b ;make && make install编译安装pngtar -zxpf libpng-1.6.18.tar.gzcd libpng-1.6.18./configure --prefix=/data/service/libpng ;make && make install编译安装gd./configure --prefix=/data/service/gd --with-libiconv-prefix=/data/service/libiconv --with-png=/data/service/libpng --with-freetype=/data/service/freetype --with-jpeg=/data/service/jpeg-9bmake && make install tar -zxpf gd-2.1.1.tar.gzcd libgd-gd-2.1.1cmake . ;make -j2 && make install编译安装phpcd /data/service/jpeg-9b/libln -sf libjpeg.so libjpeg.so.62.0.0ln -sf libjpeg.so libjpeg.so.62 tar -zxpf php-5.6.11.tar.gzcd php-5.6.11/
./configure --prefix=/data/service/php \--with-libdir=/lib/x86_64-linux-gnu \--includedir=/data/service/php/include \--sysconfdir=/data/service/php \--with-config-file-path=/data/service/php \--with-config-file-scan-dir=/data/service/php/php.d \--with-apxs2=/data/service/apache2416/bin/apxs \--with-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-jpeg-dir=/usr/lib \--with-png-dir=/usr/lib \--with-zlib-dir=/data/service/zlib \--with-freetype-dir=/data/service/freetype \--with-iconv-dir=/data/service/libiconv \--with-gd \--with-libxml-dir=/usr/lib/x86_64-linux-gnu \--with-mhash=/usr/lib/x86_64-linux-gnu \--with-mcrypt=/usr/lib/x86_64-linux-gnu \--with-openssl \--with-curl=/data/service/curl \--with-pear \--with-bz2 \--enable-bcmath \--enable-wddx \--enable-json=shared \--enable-calendar \--enable-mbstring \--enable-zip \--enable-sockets \--enable-soap \--enable-gd-native-ttf \--enable-gd-jis-conv \--disable-debug make ZEND_EXTRA_LIBS='-liconv' && make install
备注:1./usr/lib/x86_64-linux-gnu目录是debian apt get包下来默认的库安装位置,如果需要调用这些库,就需要写上这个目录。 2.php的编译脚本是根据需要写的,一般常用的是curl,gd,jpeg,png,freetype,libiconv,openssl,mysql。3.curl 的编译安装有些特别,在后面会说到。至于为什么加上ssl,是因为我需要用curl访问https的url。4.新版本的gd是用cmake来编译的。5.因为例如jpeg这些软件已经安装到/usr/local目录,所以在需要的时候要填写例如–with-jpeg-dir=/usr/local6.关于mysqli=mysqlnd 是php新版本之后优化对mysql的连接方式进行优化了,使用内置的连接驱动而不需要mysql_config,官方建议这样使用。Troubleshooting1.解决apr not found问题APR和APR-UTIL的下载地址:http://apr.apache.org/download.cgi,下载完执行如下代码: //解压该源代码包tar -zxf apr-1.4.5.tar.gz//进入该路径cd apr-1.4.5///配置并编译./configure –prefix=/usr/local/aprmakemake install2.解决APR-util not found问题 用同样的方法对apr-util进行处理: tar -zxf apr-util-1.3.12.tar.gz./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr/bin/apr-1-configmakemake install3.执行完上面两步后,当你输入./configure仍提示APR-util not found,这时需要在你的命令后面加上–with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util,3.curl编译报错需要修改configure脚本,将 $RM “$cfgfile” 改为 $RM -f “$cfgfile”
4.编译php报错configure: error: Cannot find OpenSSL’s
5.apache 2.4对于order权限有改动If you are using Apache 2.4,You have to check allow and deny rules,Check outhttp://httpd.apache.org/docs/2.4/upgrading.html#accessIn 2.2, access control based on client hostname, IP address, and other characteristics of client requests was done using the directives Order, Allow, Deny, and Satisfy.In 2.4, such access control is done in the same way as other authorization checks, using the new module mod_authz_host.The new directive is Require:2.2 configuration:Order allow,denyAllow from all2.4 configuration:Require all granted另外对于修改了order之后.htaccess文件依然不起效的原因是还需要一个配置 DirectoryIndex index.html index.php写在