防报错依赖:
ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel openssl-devel libtool*zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-develgettext-devel curl curl-devel pam-devel e2fsprogs-devel krb5-devel libidn libidn-devel libxslt-devel readline-devel gmp-devel
编译安装:
# tar xf php-5.4.13.tar.bz2
# cd php-5.4.13
# ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-mhash \
--with-bz2 \
--with-curl \
--with-freetype-dir \
--with-gd \
--with-gettext \
--with-gmp \
--with-imap-ssl \
--with-jpeg-dir \
--with-mcrypt \
--with-sqlite3 \
--with-openssl \
--with-png-dir \
--with-readline \
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-mysql=/usr/local/mysql \
--enable-bcmath \
--enable-calendar \
--enable-ctype \
--enable-dom \
--enable-exif \
--enable-ftp \
--enable-gd-native-ttf \
--enable-intl \
--enable-json \
--enable-mbstring \
--enable-pcntl \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-soap \
--enable-sockets \
--enable-tokenizer \
--enable-wddx \
--enable-xml \
--enable-zip \
--enable-opcache \
--enable-maintainer-zts
PS:
如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。
例如: ./configure –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd
# make
# make test #时间巨长
# make intall
为php提供配置文件:
# cp php.ini-production /etc/php.ini
编辑apache配置文件httpd.conf,以apache支持php
# vim /etc/httpd/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
而后重新启动httpd,或重读配置文件测试php是否正常使用