当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > Freebsd7.0 Apache2.2+MySQL5+PHP5安装和配置方法

Unix/Linux
linux查看内存的大小
在linux下写的代码,用的是utf-8,结果拿到XP下运行的时候,所有的中文都成乱码
linux su和sudo命令的区别
linux cron 下的定时执行工具使用技巧
linux 查找进程及终止进程操作的相关命令
redhat linux 安装 gcc编译器
Linux Mplayer播放各种格式的电影
一起回顾一下linux常用命令
Linux 网站项目发布要做哪些配置
linux SSH配合SecureCRT的密匙完美使用方法
GD 编译出错解决方法
Facebook Open Platform编译FAQ
Linux 系统硬盘 优化
linux 挂载详解
linux crontab定时命令
Linux 系统中确保访问三级域名畅通的方法
Linux 特权帐号VS普通帐号
确保Linux系统安全的前提条件 漏洞防护
Linux 监视系统资源使用率
Red Hat Linux上使用BIND建立DNS服务器

Unix/Linux 中的 Freebsd7.0 Apache2.2+MySQL5+PHP5安装和配置方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-15   浏览: 186 ::
收藏到网摘: n/a

 一、安装apache2.2.8

  首先去http://www.apache.org网站上下载apache2.2.8源码包

  解压缩

  #tar zxvf httpd-2.2.8.tar.gz

  得到 httpd-2.2.8文件夹

  #cd httpd-2.2.8

  配置

  #./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite

  编译

  #make

  安装

  #make install

  安装完成

  测试一下安装效果

  #cd /usr/local/apache

  #cd bin

  # ./apachectl start

  httpd: apr_sockaddr_info_get() failed for

  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

  [Thu Apr 03 09:37:41 2008] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter

  出现上述提示

  #vi /usr/local/apache/conf/httpd.conf

  修改SeverName一项即可解决(1)错误提示

  产生(2)的原因是:FreeBSD 系统还提供了http filter,会自动过滤掉不完整的HTTP请求。

 一、安装apache2.2.8

  首先去http://www.apache.org网站上下载apache2.2.8源码包

  解压缩

  #tar zxvf httpd-2.2.8.tar.gz

  得到 httpd-2.2.8文件夹

  #cd httpd-2.2.8

  配置

  #./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite

  编译

  #make

  安装

  #make install

  安装完成

  测试一下安装效果

  #cd /usr/local/apache

  #cd bin

  # ./apachectl start

  httpd: apr_sockaddr_info_get() failed for

  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

  [Thu Apr 03 09:37:41 2008] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter

  出现上述提示

  #vi /usr/local/apache/conf/httpd.conf

  修改SeverName一项即可解决(1)错误提示

  产生(2)的原因是:FreeBSD 系统还提供了http filter,会自动过滤掉不完整的HTTP请求。

                                                                     

 # chgrp -R mysql .         #设定mysql组能够访问/usr/local/mysql

  设置完成后,基本上就装好了,好了, 我们运行一下我们的mysql:

  # /usr/local/mysql/bin/mysqld_safe --user=mysql &

  出现如下提示:

  # /usr/local/mysql/bin/mysqld_safe --user=mysql &

  [2] 7022

  # Starting mysqld daemon with databases from /usr/local/mysql/var

  # ps -ef

  ps: Process environment requires procfs(5)

  PID TT STAT   TIME COMMAND

  1040 v0 Is+  0:00.00 /usr/libexec/getty Pc ttyv0

  723 v1 Is+  0:00.00 /usr/libexec/getty Pc ttyv1

  724 v2 Is+  0:00.00 /usr/libexec/getty Pc ttyv2

  725 v3 Is+  0:00.00 /usr/libexec/getty Pc ttyv3

  726 v4 Is+  0:00.00 /usr/libexec/getty Pc ttyv4

  727 v5 Is+  0:00.00 /usr/libexec/getty Pc ttyv5

  728 v6 Is+  0:00.00 /usr/libexec/getty Pc ttyv6

  729 v7 Is+  0:00.00 /usr/libexec/getty Pc ttyv7

  7022 p0 S   0:00.01 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql

  7038 p0 R+  0:00.00 ps -ef

  上述信息表明MySQL安装成功

  为了每次系统重启后都能运行mysql,可以写一个脚本放到 /etc/rc.d目录下,用来运行mysql,我们写一个脚本mysql_start.sh

  #! /bin/sh

  /usr/local/mysql/bin/mysqld_safe&

  然后保存到/etc/rc.d目录下,那么以后reboot系统后都能启动mysql了.

  MySQL的安装是最顺利的一个

  三、安装PHP

  去http://www.php.net网站上去下载php-5.2.5的源码包

解压缩

  #tar zxvf php-5.2.5.tar.gz

  #cd php-5.2.5

  配置

  # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql

  出现如下错误提示:

  Sorry, I cannot run apxs. Possible reasons follow:

  1. Perl is not installed

  2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs

  3. Apache was not built using --enable-so (the apxs usage page is displayed)

  The output of /usr/local/apache/bin/apxs follows:

  ./configure: /usr/local/apache/bin/apxs: not found

  configure: error: Aborting

  表明没有安装perl

  下载perl进行安装(去http://www.perl.com下载最新版本,我从别的网站下载了个5.8版本make时死活过不去)

  #tar xzvf perl-5.10.0.tar.gz

  #sh Configure -de

  #make

  #make test

  #make install

  安装完perl后还是提示上述错误,

  我就去apche的源程序中又来了一次下面的动作

  配置

  #./configure --prefix=/usr/local/apache --enable-so --enable-module=rewrite

  编译

  #make

  安装

  #make install

  后重新configure php时出现如下错误:

  configure: error: xml2-config not found. Please check your libxml2 installation.

  安装libxml2

  #tar zxvf libxml2-2.6.31.tar.gz

  #cd libxm2-2.6.31

  #./configure

  #make

  #make install

  安装libxml2后,重新configure php 出现如个错误提示:

                                                                     

 configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

  #tar zxvf libiconv-1.10.tar.gz

  #cd libiconv-1.10

  #./configure

  #make

  #make install

  安装完libxml2后重新configure php

  这样再configure php时结果还提示错误,具体的信息忘记记下来了,大体的意思是说没有找到iconv和libiconv请reinstall iconv,这时候已经是晚上10点多了,我怒了,决定试一下ports安装iconv和libiconv.(这下子我是实在没有耐心了)

  #whereis iconv

  根据提示到相应的目录下iconvpath指相应的目录(当时系统提示的信息具体是什么我记不清了)

  #cd iconvpath

  然后开始安装

  #make install clean

  执行上述命令时出/usr/ports/distfiles下没有找到文件,然后出现一个连接到ftp下载的信息,没办法我这个机器不能上外面,我只能用另一台机器上那个ftp上下载软件然后再放到/usr/ports/distfiles这里,重新make install clean 结果又提示缺少什么软件,我就这样一个一个的下载下来放到/usr/ports/distfiles里面

  按照上述的方式又安装了libiconv

  就这样又ports安装了perl一次.

  这一切准备完毕

  再重新开始的信息configure PHP

  这一次没问题了

 configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

  #tar zxvf libiconv-1.10.tar.gz

  #cd libiconv-1.10

  #./configure

  #make

  #make install

  安装完libxml2后重新configure php

  这样再configure php时结果还提示错误,具体的信息忘记记下来了,大体的意思是说没有找到iconv和libiconv请reinstall iconv,这时候已经是晚上10点多了,我怒了,决定试一下ports安装iconv和libiconv.(这下子我是实在没有耐心了)

  #whereis iconv

  根据提示到相应的目录下iconvpath指相应的目录(当时系统提示的信息具体是什么我记不清了)

  #cd iconvpath

  然后开始安装

  #make install clean

  执行上述命令时出/usr/ports/distfiles下没有找到文件,然后出现一个连接到ftp下载的信息,没办法我这个机器不能上外面,我只能用另一台机器上那个ftp上下载软件然后再放到/usr/ports/distfiles这里,重新make install clean 结果又提示缺少什么软件,我就这样一个一个的下载下来放到/usr/ports/distfiles里面

  按照上述的方式又安装了libiconv

  就这样又ports安装了perl一次.

  这一切准备完毕

  再重新开始的信息configure PHP

  这一次没问题了

 configure: error: Please specify the install prefix of iconv with --with-iconv=<DIR>

  #tar zxvf libiconv-1.10.tar.gz

  #cd libiconv-1.10

  #./configure

  #make

  #make install

  安装完libxml2后重新configure php

  这样再configure php时结果还提示错误,具体的信息忘记记下来了,大体的意思是说没有找到iconv和libiconv请reinstall iconv,这时候已经是晚上10点多了,我怒了,决定试一下ports安装iconv和libiconv.(这下子我是实在没有耐心了)

  #whereis iconv

  根据提示到相应的目录下iconvpath指相应的目录(当时系统提示的信息具体是什么我记不清了)

  #cd iconvpath

  然后开始安装

  #make install clean

  执行上述命令时出/usr/ports/distfiles下没有找到文件,然后出现一个连接到ftp下载的信息,没办法我这个机器不能上外面,我只能用另一台机器上那个ftp上下载软件然后再放到/usr/ports/distfiles这里,重新make install clean 结果又提示缺少什么软件,我就这样一个一个的下载下来放到/usr/ports/distfiles里面

  按照上述的方式又安装了libiconv

  就这样又ports安装了perl一次.

  这一切准备完毕

  再重新开始的信息configure PHP

  这一次没问题了

过几分钟后出现如下提示:

  +--------------------------------------------------------------------+

  | License:                                      |

  | This software is subject to the PHP License, available in this  |

  | distribution in the file LICENSE. By continuing this installation |

  | process, you are bound by the terms of this license agreement.  |

  | If you d#loadModule php4_module modules/libphp4.so not agree with the terms of this license, you must abort |

  | the installation process at this point.                  |

  +--------------------------------------------------------------------+

  Thank you for using PHP.

  这次终于没有错误了

  继续一口气做完吧

  编译php

  #make

  #make test

  #make install

  #cp php.ini-dist /usr/local/php/lib/php.ini

  上述这几步就是有些耗时间,不过再也没有出现这样的那样的错误,这一点让我很欣慰.

  安装完成

  接下来的事情就简单了

  四、整合apache和php

  为了让Apache能够直接解析php,我们还要进行一些配置

  首先进入apache的配置文件目录:

  # cd /usr/local/apache/conf

  # vi httpd.conf

  在httpd.conf文件中,添加

  AddType application/x-httpd-php .php

  AddType application/x-httpd-php-source .phps

  应该将以上两句添加在其他AddType之后。

  确保文件中有以下一句话,没有就自己添加在所有LoadModule之后。

  LoadModule php5_module modules/libphp5.so

  若存在loadModule php4_module modules/libphp4.so请将此句注释掉因为我们安装的是php5

  在下面中添加index.php

  <IfModule dir_module>

  DirectoryIndex index.php index.html

  </IfModule>

  至此,配置结束!

  在/usr/local/apache/htdocs中新建一个页面info.php

  <?php

  phpinfo();

  ?>

  在浏览器中中输入http://serverip/info.php

  看一下输出,看看是否是自己想要的结果

  配置完成!