安装图形库,为编译PHP做准备,依次安装下列程序软件
libxml2-2.7.2.tar.gz
jpegsrc.v8b.tar.gz
libpng-1.4.3.tar.gz
freetype-2.4.1.tar.gz
gd-2.0.35.tar.gz
shell># cd /home/jinnan/tar
shell># tar zxvf libxml2-2.7.2.tar.gz
shell># cd libxml2-2.7.2
shell>#./configure --prefix=/usr/local/libxml2 \
--without-zlib
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -zxvf jpegsrc.v8b.tar.gz
shell># cd jpeg-8b
shell>#./configure --prefix=/usr/local/jpeg \
--enable-shared 或 --enable-static
shell># make && make install
--enable-shared 把jpeg需要的函数库程序都编译到该软件里边
优点:函数调用速度快
缺点:软件本身比较大
--enable-static 静态方式函数处理,需要什么函数,马上include来
优点:软件本身比较小
缺点:函数调用速度慢
shell># cd /home/jinnan/tar
shell># tar zxvf libpng-1.4.3.tar.gz
shell># cd libpng-1.4.3
shell>#./configure #和zlib一样不要带参数,让它默认安装到相应目录
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar zxvf freetype-2.4.1.tar.gz
shell># cd freetype-2.4.1
shell>#./configure --prefix=/usr/local/freetype
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -zvxf gd-2.0.35.tar.gz
shell># mkdir -p /usr/local/gd
shell># cd gd-2.0.35
shell>#./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg/ \
--with-png --with-zlib \
--with-freetype=/usr/local/freetype
shell># make && make install
shell># cd /home/jinnan/tar
shell># tar -jxvf php-5.3.6.tar.bz2
shell># cd php-5.3.6
shell>#./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/http2/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib --with-libxml-dir=/usr/local/libxml2 \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--enable-mbstring=all \
--enable-mbregex \
--enable-shared
shell># make && make install
复制php.ini配置文件到指定目录
shell># cp php.ini-development /usr/local/php/lib/php.ini
配置Apache使其支持php
vi /usr/local/http2/conf/httpd.conf
1) 在httpd.conf(Apache主配置文件)中增加:
AddType application/x-httpd-php .php
2) 找到下面这段话:
DirectoryIndex index.html
在index.html 前面添加index.php
3) 建立php测试网页
vi /usr/local/ http2/htdocs/index.php
输入如下内容:
phpinfo();
?>
4) 重启apache
shell># /usr/local/http2/bin/apachectl restart
shell># service httpd restart
5) 再次浏览器查看http://虚拟机IP
如果看到php信息,工作就完成了!