PHP5在Linux下安装

ougexingfuba 2008-10-19

Linux下安装PHP5的主要步骤:

1.下载php5;地址:http://cn.php.net/downloads.php

2.解压软件包后进入该目录
tar -xzvf php-5.2.6.tar.gz
cd php-5.2.6 

3.php安装mysql的模块的一些准备工作
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
注意(以后再重新编译不需要执行这些操作) 

4.编译安装
#./configure --prefix=/opt/php5 --with-apxs2=/opt/httpd/bin/apxs --with-zlib --with-config-file-path=/etc --bindir=/usr/bin --sbindir=/usr/sbin --with-curl --with-exec-dir=/usr/bin --with-xml --with-xmlrpc=shared --enable-magic-quotes --enable-sockets --enable-mbstring=all --with-mysql=/usr/bin
#make

# make install 

5.apache 配置
a、# touch /opt/httpd/conf/extra/httpd-php.conf
    文件内容如下:#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#

LoadModule php5_module modules/libphp5.so

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

b、修改 httpd.conf,在最后添加一行
   vi httpd.conf
  ....
  # php modele
   Include conf/extra/httpd-php.conf

c、重启 apache 使之生效。

相关推荐