Freebsd7.0+Apache2.2+MySQL5+PHP5安装配置

番茄系统家园 · 2022-10-09 01:01:46

一、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请求。
:
kldload accf_http
修改/boot/defaults/loader.conf中,以便下次启动自动装载模块
accf_http_load="YES"
在浏览器是输入http://serverip
出现 "It works!" 表明apache安装成功
二、MySQL
下载MySQL源码包

ls

httpd-2.2.8.tar.gz      mysql-5.0.51.tar.gz
解压缩

tar zxvf   mysql-5.0.51.tar.gz

cd mysql-5.0.51

配置

./configure --prefix=/usr/local/mysql

编译

make

编译时间可能需要较长时间,请耐心等待。

make install

创建MySQL组

pw groupadd mysql

创建MySQL用户

pw useradd mysql -g mysql -d /usr/local/mysql/ -m mysql

修改MySQL用户密码

passwd mysql

建立用户后我们就初始化表 (注意:必须先执行本步骤后才能进行以下步骤)

./scripts/mysql_install_db --user=mysql        #初试化表并且规定用mysql用户来访问

初始化表以后就开始给mysql和root用户设定访问权限, 我们先到mysql的目录:

cd /usr/local/mysql

然后权限

chown -R root .                #设定root能访问/usr/local/mysql

chown -R mysql var             #设定mysql用户能访问/usr/local/mysql/var ,里面存的是mysql的数据库文件

chown -R mysql var/.           #设定mysql用户能访问/usr/local/mysql/var下的所有文件

chown -R mysql var/mysql/.     #设定mysql用户能访问/usr/local/mysql/var/mysql下的所有文件

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=


tar zxvf libiconv-1.10.tar.gz

cd libiconv-1.10

./configure

make

make install

注意:我开始的时候的 libiconv-1.11结果完成后,重起启动时出现问题(用户就是登录不去,不是是的bug还是软件的兼容性不好,后来用单用户进入,删除了/usr/local/下的libiconv相关文件才得以登录,从出现这个问题到这个问题花了我半天的时间,大家一定要记住这个教训)
完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
本已经编译了perl 后来一想反正是要ports,就再ports一下这个perl吧
就这样又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

    DirectoryIndex index.php index.html

至此,配置结束!
在/usr/local/apache/htdocs中新建一个页面info.php
phpinfo();
?>
在浏览器中中输入http://serverip/info.php
看一下输出,看看是否是自己想要的结果
配置完成!

免责声明: 凡标注转载/编译字样内容并非本站原创,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如果你觉得本文好,欢迎推荐给朋友阅读;本文链接: https://m.nndssk.com/xtwt/206024v5tePE.html
猜你喜欢
最新应用
热门应用