一、实验环境
CentOS6.5
软件:php-5.3.27.tar.gz
二、实验步骤
1、php安装准备
1)php依赖包安装准备
yum -y install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
yum -y install libxslt-devel
yum -y install openssl-devel
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
2、安装php
1)解压php-5.3.27
tar xf php-5.3.27
2)编译安装php
cd php5.3.27
./configure \
--prefix=/application/php5.3.27 \
--with-apxs2=/application/apache/bin/apxs \
--with-mysql=/application/mysql \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/usr/local/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-zend-multibyte \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir
make && make install
ln -s /applcation/php5.3.27 /application/php
3)拷贝配置文件到/application/php/lib/php.ini
cp /home/chen/tools/php-5.3.27/php.ini-production /application/php/lib/php.ini
3、配置apache支持php
1)在/application/apache/conf/httpd.conf配置文件AddType application/x-compress .Z/AddType application/x-gzip .gz .tgz后面加上如下两行:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2)加上首页文件 index.php
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
3)如修改如下两项,则需要创建用户并授权
user daemon
group daemon
user daemonchen
group daemonchen
useradd daemonchen -s /sbin/nologin/ -M
chown -R daemonchen.daemonchen /var/html/www/
4)到站点根目录写一个测试文件index.php,然后同构浏览器访问。
<?php
phpinfo();
?>
完成上诉步骤后,如图所示: