> CentOS > CentOS教程 >

CentOS 6.5安装PHP(LAMP)

1.清除系统中php痕迹:
yum remove php
rm -rvf /etc/php.ini

2.解压:
tar zxvf php-5.3.3.tar.gz -C /usr/src/

3.配置:
cd /usr/src/php-5.3.3/
(配置编译之前一定要检查一下两个目录文件是否存在)
ln -s /usr/lib64/libjpeg.so /usr/lib/
ln -s /usr/lib64/libpng.so /usr/lib/
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--enable-mbstring=all \
--enable-mbregex \
--enable-ftp \
--enable-sockets \
--with-mhash \
--with-pear \
--with-openssl \
--with-zlib \
--with-gd \
--enable-gd-native-ttf \
--with-png-dir=/usr/local/libpng \
--with-jpeg-dir=/usr/local/jpeg \
--with-freetype-dir=/usr/local/freetype \
--with-curl \
--disable-rpath \
--disable-debug

4.编译:
make

5.安装:
make install

6.建立PHP配置文件:
cp /usr/src/php-5.3.3/php.ini-development /usr/local/php/php.ini

7.配置httpd与php协同工作:
vi /usr/local/apache/conf/httpd.conf
#找到 AddType application/x-gzip .gz .tgz 在下面添加:
AddType application/x-httpd-php .php     (.php前面有空格)
AddType application/x-httpd-php-source .phps    (.phps前面有空格)

8.创建php测试页面:
vi /usr/local/apache/htdocs/phpinfo.php
输入以下内容:
(责任编辑:IT)