php5.0 要求libxml2-2.6.0以上更高的版本,这一解析器提供php5.0 新的XML API
===============================================================================================================================================
安装 libxml2
tar -zxvf libxml2-2.6.19.tar.gz
cd libxml2-2.6.19
./configure --prefix=/usr/local/libxml2
make
make install
这一步结束时,libxml2被安装在/usr/local/下。
================================================================================================================================================
安装 zlib
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
这一步结束时,zlib被安装在/usr/local/下。
===============================================================================================================================================
安装 libpng
tar -zxvf libpng-1.2.10.tar.gz
cd libpng-1.2.10
cp scripts/makefile.linux makefile
make
make install
注意:这里的makefile不是用./configure 生成的,而是直接从script/目录里拷一个
这一步结束时,zlib被安装在/usr/local/lib下
=============================================================================================================================================
安装 freetype
tar -zxvf freetype-2.2.1.tar.gz
cd freetype-2.2.1
./configure --prefix=/usr/local/freetype
make
make install
这一步结束时,freetype被安装在/usr/local/lib下
============================================================================================================================================
安装 jpeg6
建立目录
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
注意:这里./configure一定要带--enable-shared参数,不然,不会生成共享库
=============================================================================================================================================
安装 gd
tar -zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --prefix=/usr/local/gd --with-png=/usr/local/lib --with-freetype=/usr/local/freetype --with-jpeg=/usr/local/jpeg6
make && make install
==============================================================================================================================================
安装 curl 支持ftp库函数
tar -zxvf curl-7.15.0.tar.gz
cd curl-7.15.0
./configure --prefix=/usr/local/curl
make && make install
===============================================================================================================================================
安装 Apache2
以Apache使用php有两种方式:作为动态模块,其在运行状态时可以载入到web服务器,
或者作为静态模块,其可直接编译到web服务器代码中。对于文本,我们着重于第一种方式。
为了能让Apache2.0模块使php动态载入,Apache服务器必须以动态共享对象(DSO,Dynamic Shared Object)编译。
可以通过传递 --enable-so 参数到 Apache 2
tar -jxvf httpd-2.2.2.tar.bz2
cd httpd-2.2.2
./configure --prefix=/usr/local/apache2 --enable-so --enable-dav --enable-rewrite make && make install
//切记要支持Zend Optimizer不可加 --with-mpm=worker选项
这一过程将会设置,编译,以及将服务器安装到/usr/local/下。
启动apache守护进程:
/usr/local/apache2/bin/apachectl start (开启 start 关闭 stop 重启 restart)
打开浏览器,输入http://localhost 就能看到一个apache的欢迎页面了,这表示我们已经成功的安装了apache2 。
==============================================================================================================================================
安装 Mysql5
groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-5.0.17.tar.gz
cd mysql-5.0.17
./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-extra-charsets=all --with-big-tables --with-charset=utf8 --with-collation=utf8_unicode_ci
make
make install
cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
启动服务:
/usr/local/mysql/share/mysql/mysql.server start (启动start 关闭stop 重启restart)
键入mysql回车就可已看到欢迎界面。说明我们已成功安装了mysql
说明:
--with-extra-charsets=all 对多语言支持
--with-unix-socket-path=/usr/local/mysql/var/mysql.sock 这个是指定mysql服务启动后。联机套接字文件所处的位置和文件名,也就是说,如果mysql服务器成功启动后,就能在/usr/local /mysql/var.采用这一选项,通常会出错,建议不配置用默认的。默认会在/tmp/mysql.sock.
目录中看到mysql.sock文件。
如果编译时出现了以下错误:
checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
说明 curses/termcap 库没有安装
去下载一个ncurses-5.6.tar.gz,
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --prefix=/usr --with-shared --without-debug
make
make install clean
然后再重新编译Mysql进行安装。
1、
mysql的自启动我解决了,在/etc/rc.d/rc.local里加
/usr/local/mysql/bin/mysqld_safe -u mysql &
2、
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig –level 345 mysql on
/etc/init.d/mysql start
==================================================================================
安装 php5
tar -zxvf php-5.1.6.tar.gz
cd php-5.1.6
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs
--with-config-file-path=/etc --with-libxml-dir=/usr/local/libxml2
--with-zlib-dir=/usr/local/zlib --with-curl=/usr/local/curl
--with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg6
--with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-openssl --enable-gd-native-ttf --enable-mbstring --enable-ftp
--enable-bcmath --enable-sockets --enable-zip --enable-soap
--enable-calendar //切记要支持Zend Optimizer不可加 --enable-debug选项
make
make install
cp php.ini-dist /etc/php.ini
编译php时出现
./configure: /usr/local/apache2/bin/apxs: /replace/with/path/to/perl/interpreter:
bad interpreter: No such file or directory
这是找不到perl解释器的缘故。
修改/usr/local/apache2/bin/apxs文件中:
/replace/with/path/to/perl/interpreter
把他替换成perl所在的路径如/opt/ActivePerl-5.8/bin/perl,
(如果你下载的是active perl5.8的rpm,他默认安装路径是/opt/ActivePerl-5.8/bin/perl)
=============================================
整合apache2和php5
apache 配置文件及目录是:
/usr/local/apache2/conf/httpd.conf
apache 默认存放主页的位置是:
/usr/local/apache2/htdocs
以下是配置文件里面的信息:(有的地方要做修改)
ServerRoot "/usr/local/apache2"
这是指定apache程序所在的目录,比如日志文件、配置文件等目录。
DocumentRoot "/usr/local/apache2/htdocs"
这个是存放网页的目录
这一句应该和DocumentRoot的目录保持一致。
找到 DirectoryIndex index.html
改为 DirectoryIndex index.html index.html.var index.htm index.php
找到 AddType application/x-gzip .gz .tgz
加 AddType application/x-httpd-php .php (注意空格)
AddType application/x-httpd-php-source .phps
添加 AddDefaultCharset utf8 使apache默认支持utf8字符集
保存配置文件就重启apache 的守护进程。
/usr/local/apache2/bin/apachectl restart
下载源码包 make && make install 之后, apache 并不会自动往 init.d 里面添加自己的 httpd service。需要手工把 apache 安装目录的 bin/apachectl 拷贝一份到 /etc/init.d/httpd 。如果想让 httpd service 能够在不同的运行级别下都能自动启动,还需要 vi /etc/init.d/httpd ,在 #!/bin/sh 下面增加几行 chkconfig 需要的内容:
# chkconfig: 2345 70 30
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
关键是 chkconfig: 2345 70 30 这一行,第一个数字 2345 表示让 apache 在 2345 这四个级别都自动运行;第二个数字 70 表示进程启动的优先级;第三个数字 30 表示进程停止的优先级。修改保存之后执行 /sbin/chkconfig httpd reset ,chkconfig 就自动在各个级别的 rc*.d 中增加 httpd 的 link 。要查看 chkconfig 是否 reset 正确,通过命令 /sbin/chkconfig --list httpd 就可以查看当前 httpd service 被配置在哪几个运行级别自启动。
注意:
每次更改配置文件。要重启服务。
对存放网页的目录执行:命令chmod 755 目录名 或者 chmod -R 755 目录名
编辑php.ini文件,找到
;default_charset="iso-8859-1"
增加一行:default_charset="utf8"
以上步骤都执行完后。在/usr/local/apache2/htdocs/里编辑文件进行测试。
phpinfo.php
里面的内容:
phpinfo();
?>
在浏览器地址栏中输入:
http://localhost/phpinfo.php
出现php说明页面说明安装成功。
安装过程相当简单,网上很多这种文档,整理的也很详细,我就不多废话了。就具体就在fedora6下碰到的问题说明一下: 接下: ===========================================================================================
安装时的问题及解决方法
安装php5的过程中会自动在/usr/local/apache2/conf/httpd.conf里添加:
LoadModule php5_module modules/libphp5.so
重新启动apache报如下错误:
httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
解决办法:
chcon /usr/local/apache/modules/libphp5.so -t shlib_t
原因是Linux有一个SELinux保护模式引起的。
关闭SELINUX的方法:
vi /etc/selinux/config 将SELINUX=enforcing 改成SELINUX=disabled
保存,重起电脑即可.
FC5 中的SELinux 代表了用户,程序以及进程间相互交流的主要变化。
=============================================
安装phpMyAdmin2.8.1
unzip phpMyAdmin2.8.1.zip
cp -r phpMyAdmin2.8.1 /usr/local/apache2/htdocs
cd /usr/local/apache2/htdocs/phpMyAdmin2.8.1/libraries
cp config.default.php ../config.inc.php
gedit config.inc.php
找到$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method (config, http or cookie based)?一行(大概在71行)将值改为http 或 cookie,随自己喜欢
==================================================================================
安装Zend optimizer3.2.8
这可能是最简单也是最容易出问题的地方(我在此吃尽苦头)
tar -zxvf ZendOptimizer-3.2.8-linux-glibc21-i386.tar.gz
cd ZendOptimizer-3.2.8-linux-glibc21-i386
./install
安装完后重启apache,在phpinfo.php的欢迎页面第二个域你会看到:
---------------------------------------------------------------------------------------------------------------------------------------------------
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
Zend logo
执行 /usr/local/php5/bin/php -v 应该看到:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
否则就是安张出问题了。可能是编译apache画蛇添足添加了--with-mpm=worker 没有用默认的prefork模块
另一中可能就是编译php是加入了--enable-debug
zend optimizer 需要apache(perfork only) php(no debug Mod)这些在Zend optimizer User`Gurde上有说明需特别注意了
over
由于本人水平有限,遗漏 过错之处欢迎大家指正
让APACHE MYSQL 随系统启动:
编辑/etc/rc.local文件
# vi /etc/rc.local
在文件中写入
# 启动APACHE
/usr/local/apache2/bin/httpd -k start
# 启动MYSQL
/usr/local/mysql/bin/mysqld_safe --user=mysql &


没有评论:
发表评论