一 软件包    

#libmcrypt-2.5.7.tar.gz

#curl-7.40.0.tar.gz     

#libpng-1.6.15.tar.gz

#freetype-2.5.4.tar.gz  

#libxml2-2.9.2.tar.gz

#gdbm-1.11.tar.gz       

#gettext-0.19.4.tar.gz  

#mhash-0.9.3.tar.gz

#jpegsrc.v9a.gz         

#libgd-2.1.0.tar.bz2  #最好用.bz2的用.gz的会在编译PHP时出错 

#zlib-1.2.8.tar.gz

#libiconv-1.14.tar.gz

#php-5.6.4.tar.gz

把这些包从共享目录拷到/root/

cp -r ~/shared/php ./

cd php

 

 

二,编译安装zlib

tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure #zlib不要制定安装路径了
make
make install


 

 

三,编译安装libjpeg

tar zxf jpegsrc.v9a.gz
cd jpeg-9a/
./configure --prefix=/usr/local/libjpeg --enable-shared --enable-static
make
make install
cd ..
\rm -r jpegsrc.v9a.gz jpeg-9a
 


 

四,编译安装libpng

tar zxf libpng-1.6.15.tar.gz
cd libpng-1.6.15
./configure --prefix=/usr/local/libpng-1
makemake install
cd ..
\rm -r libpng-1.6.15.tar.gz libpng-1.6.15


 

 

五,编译安装freetype

tar zxf  freetype-2.5.4.tar.gz
cd freetype-2.5.4
./configure=/usr/local/freetype
make
make install
cd ..
\rm -r freetype-2.5.4.tar.gz freetype-2.5.4


 

 

六,编译安装libgd

yum install bzip2 -y
tar jxf libgd-2.1.0.tar.bz2 
cd libgd-2.1.0
#configure时不要指定prefix了,编译PHP时会出错
./configure  --with-jpeg=/usr/local/libjpeg 	--with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-zlib
make
make install
cd ..
\rm -r libgd-2.1.0.tar.bz2 libgd-2.1.0


 

 

七,编译安装curl

tar zxf curl-7.40.0.tar.gz 
cd curl-7.40.0
./configure --prefix=/usr/local/curl
make install
cd ..
\rm -r curl-7.40.0.tar.gz curl-7.40.0


 

 

八,编译安装gdbm

tar zxf  gdbm-1.11.tar.gz
cd  gdbm-1.11
./configure --prefix=/usr/local/gdbm
make
make install
cd ..
\rm -r gdbm-1.11.tar.gz gdbm-1.11


 

 

九,编译安装libcrympt

tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure --prefix=/usr/local/libmcrypt
make
make install
cd ..
\rm -r libmcrypt-2.5.7.tar.gz libmcrypt-2.5.7


 

 

十,编译安装gettext

tar zxf  gettext-0.19.4.tar.gz 
cd gettext-0.19.4
./configure --prefix=/usr/local/gettext
make 
make install
cd ..
\rm -r gettext-0.19.4.tar.gz gettext-0.19.4


 

 

十一,编译安装iconv

tar zxf  libiconv-1.14.tar.gz
cd libiconv-1.14
./iconv --prefix=/usr/local/libiconv
make 
make install
cd ..
\rm -r libiconv-1.14.tar.gz libiconv-1.14


 

 

十二,编译安装libxml2

yum install python-devel -y
tar zxf libxml2-2.9.2.tar.gz
cd libxml2-2.9.2
./configure --prefix=/usr/local/libxml2
make
make install
cd ..
\rm -r libxml2-2.9.2.tar.gz libxml2-2.9.2


 

 

十三,编译安装mhash

tar zxf mhash-0.9.3.tar.gz
cd mhash-0.9.3
./configure --prefix=/usr/local/mhash
make
make install
cd ..
\rm -r mhash-0.9.3.tar.gz mhash-0.9.3


 

 

十四,编译安装php

tar zxf  php-5.6.4.tar.gz

cd  php-5.6.4

#对于默认安装即./configure没有带prefix参数的可以直接只写出--with-XXX不用赋值

#具体参数可通过./configure --help来查询

./configure  \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--enable-calendar \
--with-mysql=/usr/local/mysql \
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config \
--with-iconv=/usr/local/libiconv \
--enable-mbstring \
--with-curl=/usr/local/curl \
--enable-exif \
--with-gd \
--with-zlib \
--with-jpeg-dir=/usr/local/libjpeg \
--with-png-dir=/usr/local/libpng \
--with-freetype-dir=/usr/local/freetype \
--with-gdbm=/usr/local/gdbm \
--with-libxml-dir=/usr/local/libxml2 \
--enable-gd-native-ttf \
--enable-sockets \
--with-mcrypt=/usr/local/libmcrypt \
--with-gettext=/usr/local/gettext \
--with-mhash=/usr/local/mhash \
--enable-shmop
make
make install
cd ../..
\rm -r php
cp ./php-production.ini  /usr/local/php/lib/php.ini


#php.ini的位置也可在编译时指定:----with-config-file-path=YOURPATH

 

 

十五,配置Apache httpd.conf

要改的有如下几处

1.# vi  /usr/local/apache/conf/httpd.conf

查找AddType application/x-gzip .gz .tgz

在其下加入 

AddType application/x-tar .tgz

AddType application/x-httpd-php .php

AddType image/x-icon .ico

 

2.修改DirectoryIndex 行,添加index.php

修改为DirectoryIndex  index.php  index.html

 

 

十六,修改php.ini

找到timezone,修改为timezone=Asia/Shanghai

 

 

十七,测试

#Apache服务器根路径新建index.php文件如下

cd /home/htdocs/

vi index.php

<?php

phpinfo();

?>

 

在主机输入地址虚拟机IP地址,查看模块是否加载

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐