centos6.5(update到6.9,2.6.32-696.16.1.el6.x86_64 )已安装apache2.2.34和mysql5.1.72
一:安装依赖,部分依赖已在安装apache和mysql时安装
yum install -y libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel pcre-devel bzip2-devel
二:编译参数
如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。
如果之前已经编译过php,先执行一下make clean
./configure \
--prefix=/usr/local/php5.6.34 \
--with-config-file-path=/usr/local/php5.6.34/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-mcrypt \
--enable-mbregex \
--enable-mbstring \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext
--with-apxs2=/usr/local/apache2/bin/apxs 这一行指定使用使用mod_php方式和apache整合。
编译成功会有以下内容
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
三:make &&make install
*****************************
整合apache
编辑httpd.conf, 修改以下内容(红色标注)
vim /usr/local/apache2/conf/httpd.conf
1 User www
3 Groupwww
4
5
6
7
8 DirectoryIndex index.php index.html index.htm
9
10
11
12
13 AddType application/x-compress .Z
14 AddType application/x-gzip .gz .tgz
15
16 AddType application/x-httpd-php .php .phtml
17 AddType application/x-httpd-php-source .phps
用 phpinfo(); 页面测试正常