您的位置:首页 > 运维架构 > Linux

linux 学习笔记 - php 环境安装与配置

2006-04-10 11:11 1566 查看
摘自:http://www.isswhu.cn/forums/viewthread.php?tid=11
http://article.21e.cn/view.php?pid=279
linux下安装最新apache2.0.52+php5+gd2+mysql

安装前的准备工作:

安装 bzip2-1.0.2.tar.gz

安装 freetype-2.1.9.tar.bz2 使 php 更好的支持字体

安装 gd-2.0.26gif.tar.gz 为 php 提供图像函数库

安装 jpegsrc.v6b.tar.gz 使 php 支持 jpeg

安装 libpng-1.2.8.tar.bz2 使 php 支持 png

安装 libxml2-2.6.16.tar.gz 使 php 支持 xml

安装 zlib-1.2.1.tar.bz2

各种文件下载地址或参考网站:

bzip2-1.0.2.tar.gz
http://www.digistar.com/bzip2/

freetype-2.1.9.tar.bz2
http://freetype.sourceforge.net/index2.html

gd-2.0.26gif.tar.gz & gd-2.0.26.tar.gz
http://www.rime.com.au/gd/

jpegsrc.v6b.tar.gz
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz

libpng-1.2.8.tar.bz2
http://www.libpng.org/pub/png/libpng.html

libxml2-2.6.16.tar.gz
http://xmlsoft.org/downloads.html

zlib-1.2.1.tar.bz2
http://www.gzip.org/zlib/

可以用gcc -v来查看是否安装了GCC,
#gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34)

安装XPM (我在安装过程中没碰到这个东东。。。。)
#rpm -ivhxpm-3.4k-2.i386.rpm

安装php5,一般要带上下面的参数:

# ./configure --prefix=/server/php --with-apxs2=/server/apache/bin/apxs --with-mysql=/server/mysql --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-ttf=/usr/local --with-freetype-dir=/usr/local --with-tiff-dir=/usr/local --with-zlib-dir=/usr/local --enable-gd-native-ttf --with-gzip --with-bz2 --with-dom --enable-exif --enable-ftp --with-iconv --with-kerberos --with-java=/usr/java/j2sdk1.4.1_01 --enable-mbstring=all --enable-mbregex --with-mime-magic --with-pdflib --enable-sockets --enable-wddx --with-expat-dir=/usr/local
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini //复制PHP.INI文件到正确位置

编辑apache配置文件httpd.conf #vi /usr/local/apache2/conf/httpd.conf

要改的有如下几处:

一般都在
#AddType application/x-tar .tgz
下加一行
#LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
如果你搜索其它地方没有以下这行

LoadModule php5_module modules/libphp5.so
请把上面的#号去掉

还有找到
DirectoryIndex index.html index.html.var
在后面加 index.php 让它把index.php做为默认页

找到
# don't use Group #-1 on these systems!
把下面的用户名和组改为
User apache
Group apache
(原来好像是nobody)

再找
#ServerName
把#去掉,后面的IP改成你的IP.

找到
DocumentRoot "/usr/local/apache2/htdocs"
把/usr/local/apache2/htdocs改为你存放网页文件的路径

为了让中文网页没乱码
找到
AddDefaultCharset iso8859-1
把后面的iso8859-1改为gb2312 或者是干脆off
其他的选项就自己修改吧!或者到http://article.21e.cn 有一个专门的httpd.conf的说明!

保存httpd.conf文件.

启动apache
# /usr/local/apache2/bin/apachectl start
如果没有出错,写一个测试页放到你网页目录下.访问就应该可以看到php的版本等信息了!

如无意外.PHP脚本已经可以连接mysql了.

用ZendOptimizer加速PHP
#tar zxvf ZendOptimizer-2.5.3-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-2.5.3-linux-glibc21-i386
#./install.sh

安装的经验:

注意仔细阅读 README INSTALL 或其他帮助类文档

./configure --help 查看配置选项

在 make 后,make install 之前可能有 make test 或 make check 用来试安装

如果想重新配置安装,需要尝试清除 .cache 的缓存文件和运行 make clean 等

可能会有 config.guess, config.status 或 config.nice 之类的文件来查看先前的配置,默认配置,或。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: