Chinaunix首页 | 论坛 | 博客
  • 博客访问: 59230
  • 博文数量: 11
  • 博客积分: 687
  • 博客等级: 上士
  • 技术积分: 190
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-10 10:56
文章分类
文章存档

2011年(1)

2010年(10)

分类: 系统运维

2010-03-01 13:38:20

Freebsd6.2+Apache+Mysql+PHP(F.A.M.P)环境搭建
                                                                         

实践环境:Freebsd6.2
----------------------------------------------------------------------------------------------------------------------------
必用组件:
mysql-5.0.45.tar.gz
php-5.2.4.tar.bz2
httpd-2.2.4.tar.tar
gd-2.0.33.tar.gz
freetype-2.2.1.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.2.12.tar.gz
libxml2-2.6.26.tar.gz
zlib-1.2.3.tar.gz
ZendOptimizer-3.3.0a-freebsd6.0-i386.tgz
可选组件:
mysql-gui-tools-5.0.zip
phpMyAdmin-2.11.1-all-languages.tar.gz
注意组件安装顺序~!
----------------------------------------------------------------------------------------------------------------------------
(一)安装Mysql
pw groupadd mysql
pw useradd mysql -g mysql
./configure \
--prefix=/usr/local/mysql \
--with-charset=gbk \
--with-extra-charsets=all
make
make install
cp support-files/my-medium.cnf  /etc/my.cnf
cp /usr/local/mysql/share/mysql/mysql.server   /usr/local/etc/rc.d/mysqld
chmod 755 /usr/local/etc/rc.d/mysqld
初始化数据库:
cd /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chown -R mysql var/.
chown -R mysql var/mysql/.
chgrp -R mysql .
/usr/local/etc/rc.d/mysqld start
设定mysql密码:
/usr/local/mysql/bin/mysqladmin -u root password '123456'
----------------------------------------------------------------------------------------------------------------------------
(二)安装Apache
./configure --prefix=/usr/local/apache
make
make install
/usr/local/apache/bin/apachectl start
如果Apache启动报如下错:
apache Failed to enable the ‘httpready’ Accept Filter
[warn] (2)No such file or directory: Failed to enable the ‘httpready’ Accept Filter
则按以下的方法解决:
在/boot/loader.conf与/etc/loader.conf里添加accf_http_load="yes"
然后reboot一下就可以解决了
这是因为Apache无法开启FreeBSD下accept filter 的机制,FreeBSD 系统还提供了http filter,会自动过滤掉不完整的HTTP请求。解决方法:
kldload accf_http
并将以下加入到/boot/defaults/loader.conf中,以便下次启动自动装载模块
accf_data_load="YES"
accf_http_load="YES"
----------------------------------------------------------------------------------------------------------------------------
(三)安装gd及其组件
1)安装jpegsrc
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man1
mkdir -p /usr/local/jpeg6/man/man1
mkdir -p /usr/local/man/man1
./configure --prefix=/usr/local/jpeg6 --enable-shared
make
make install
2)安装zlib
./configure --prefix=/usr/local/zlib
make
make install
3)安装libpng
mv scripts/makefile.linux ./makefile
make
make install
4)安装freetype
vi configure
把GNUMAKE=make改成GNUMAKE=gmake
(如果没安装gmake的话请放入freebsd第二张光盘在configure/packages/"CD/DVD"/devel里安装gmake)
./configure --prefix=/usr/local/freetype
gmake
gmake install
5)安装libxml2
首先查看系统中是否已经安装了libxml2,如果已经安装了libxml2便观察一下已安装版本是否与即将的版本一样,如果比即将安装的版本低则需要重新安装:
pkg_info | grep libxml2
./configure --prefix=/usr/local/libxml2
make
make install
6)安装gd
./configure --prefix=/usr/local/gd --with-png=/usr/local --with-freetype=/usr/local --with-jpeg=/usr/local --with-libxml2=/usr/local/include
make
make install
如果直接采用以上装的话会出现Error code 1之类错误,所以建议用ports安装gd库
cd /usr/ports/graphic/gd
make install
----------------------------------------------------------------------------------------------------------------------------
(四)安装PHP
./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-libxml-dir=/usr/local/include \
--with-zlib-dir=/usr/local \
--with-png-dir=/usr/local \
--enable-mbstring=all \
--with-freetype-dir=/usr/local
--with-jpeg-dir=/usr/local
--with-gd=/usr/local
--with-config-file-path=/usr/local/php/etc
make
make test
make install
cp php.ini-dist /usr/local/php/etc/php.ini
----------------------------------------------------------------------------------------------------------------------------
(五)相关设置:
1)修改Apache配置文件以解析PHP文件
vi /usr/local/apache/conf/httpd.conf
添加:
     AddType application/x-httpd-php .php .phtml
     AddType application/x-httpd-php-source .phps
#ServerName 把这一行的#去掉,ServerName后面改成自己的地址
在index.htm后面添加index.php作为默认页面
将"/usr/local/apache/htdocs"改为你的网页存放路径
加入出错重定向
ErrorDocument 404
ErrorDocument 402
ErrorDocument 403
ErrorDocument 500
保存httpd.conf并启动Apache
/usr/local/apache/bin/apachectl start
2)编辑Discuz目录里的config.inc.php
$dbhost = 'localhost';   // 数据库服务器 (一般只需修改这里)
$dbuser = 'username';   // 数据库用户名 (一般只需修改这里)
$dbpw = '';    // 数据库密码   (一般只需修改这里)
$dbname = 'discuz';   // 数据库名     (一般只需修改这里)
$dbreport = 0;           // send db error report? 1=yes
             // 是否发送数据库错误报告? 0=否, 1=是
$pconnect = 0;    // 数据库持久连接 0=关闭, 1=打开

将以下目录权限设置成777:
./templates
./templates/default
./templates/default/*.*
./attachments
./customavatars
./forumdata
./forumdata/cache
./forumdata/templates
./forumdata/threadcaches
./forumdata/logs
3)修改Phpmyadmin配置文件:config.inc.php
找到以下选项:
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['blowfish_secret'] = 'chameleon';(其中的"chameleon"自定义)
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';(mysql主机地址)
$cfg['Servers'][$i]['controluser'] = 'pmausr';(用户)
$cfg['Servers'][$i]['controlpass'] = 'pmapass';(密码)
----------------------------------------------------------------------------------------------------------------------------
(六)测试相关页面及连通性
1)编辑一个phpinfo.php页面,内容如下:
phpinfo();
?>
输入IP看是否能打开PHPINFO页面
2)编辑一个测试Mysql连通性的页面,内容如下:
$link=mysql_connect('localhost','mysql','486277');
if(!$link) echo "失败!";
else echo "成功!";
mysql_close();
?>
保存为一个PHP页面并用浏览器打开测试Mysql数据库连通性
----------------------------------------------------------------------------------------------------------------------------
(七)安装ZendOptimizer加速PHP
./install.sh
由于ZendOptimizer-3.3.0a需要用到zend 3.0.2里的dialog文件,我已经重新将他们打包到一起了。
cd ZendOptimizer-3.3.0a-freebsd6.0-i386
./install.sh
----------------------------------------------------------------------------------------------------------------------------
(八)安装论坛
请在浏览器中运行 install.php,即访问 http://您的域名/论坛目录/install.php,然后按页面提示操作来做即可,这样论坛就安装好了。
阅读(1369) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~