PHP的安装
1.下载安装php支持包
(1) GD2
# cd /usr/local/src
#wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.41.tar.gz
#cd GD-2.41
#perl Makefile.PL
#make; make install
(2) LibXML2
# cd /usr/local/src
#wget http://www.xmlsoft.org/sources/libxml2-2.6.30.tar.gz
# tar xzvf libxml2-2.6.30.tar.gz
# cd libxml2-2.6.30
# ./configure –prefix=/usr/local/libxml2
# make; make install
2.编译安装
#cd /usr/local/src
#wget http://cn.php.net/distributions/php-5.2.9.tar.gz
# tar -zvxf php-5.2.9.tar.gz
# cd php-5.2.9
#./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql –with-libxml-dir=/usr/local/libxml2 –with-gd –enable-gd-native-ttf –with-jpeg-dir –with-png-dir –with-bz2 –with-freetype-dir –with-iconv-dir –with-zlib –enable-mbstring –with-mcrypt –disable-ipv6 –disable-cgi –disable-cli
若要想有mcrypt选项必须要安装libmcrypt-2.5.7.tar.gz这个包。
成功会出现:Thank you for using PHP.
# make; make install
3.整合apache与php
# cp php.ini-dist /usr/local/php/lib/php.ini
#/usr/local/php/lib/php.ini
修改php.ini文件
register_globals = Off为On
注:编辑apache配置文件httpd.conf,以apache支持php
# vi /usr/local/apache2/conf/httpd.conf
(1)检查添加如下行
And in the AddModule section of httpd.conf, somewhere under the ClearModuleList, add this:
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Tell Apache to parse certain extensions as PHP
AddType application/x-httpd-php .php .php5
AddType application/x-httpd-php-source .phps
AddOutputFilterByType DEFLATE text/html text/plain text/xml
检查是否有以下模块
LoadModule php5_module modules/libphp5.so
(2)定位至<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改为:
DirectoryIndex index.php index.html
修改完成后保存退出。
# /usr/local/apache2/bin/apachectl restart
(3)查看确认L.A.M.P环境信息
#vi /usr/local/apache2/htdocs/phpinfo.php
<?php
phpinfo();
?>
在浏览器中查看结果
http://x.x.x.x/phpinfo.php
确认 PHP 能够正常工作后,在 php.ini 中进行设置提升 PHP 安全性。
# vi /etc/php.ini
找到:
disable_functions =
设置为:
disable_functions = phpinfo,passthru,exec,system,popen,chroot,escapeshellcmd,escapeshellarg,shell_exec,proc_open,proc_get_status,ini_restore
最后,重新启动 Apache 服务即可。
-The End-