转自:http://hi.baidu.com/jxlao/blog/item/6effaceab9d3063e2cf534f7.html

#cd /usr/ports/www/apache22
#make isntall clean
[X]选择Mysql
[O]去掉IPV6

配置Apache22:
1、备份配置文件:
#cp /usr/local/etc/apache/httpd.conf /us/local/etc/apache/httpd.conf.back
2、修改/etc/rc.conf
vi /etc/rc.conf
apache22_enable=”YES”
3、修改httpd.conf
vi /usr/local/etc/apache/httpd.conf

105行处:
LoadModule php5_module libexec/apache22/libphp5.so
156行处:
DocumentRoot “/usr/local/www/apache22/data”
216行处:
<IfModule dir_module>
    DirectoryIndex index.php index.html index.txt
</IfModule>
359行处:
    AddType application/x-httpd-php.php
    AddType application/x-httpd-php-source.phps

启动apache22

# apachectl start # 出现错误信息
No such file or directory: Failed to enable the ‘httpready’ Accept Filter
# vi /boot/loader.conf # 让开机时预先读取
修改内容accf_http_load=”yes”
# apachectl restart # 重启apache
=============================================
安装mysql
#cd /usr/ports/databases/mysql51-client/
#make install clean
#cd /usr/ports/databases/mysql51-server/
#make WITH_CHARSET=utf8 WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes

WITHOUT_INNODB=yes install clean
重启FreeBSD
#ee /etc/rc.conf
添加以下内容并保存:
mysql_enable=”YES”

# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf # 修改 my.cnf

[mysqld]
default-character-set = utf8
[client]
default-character-set = utf8
# /usr/local/etc/rc.d/mysql-server start # 启动 mysql
#mysql -u root
#mysql>set password for root@localhost=password(‘newpassword’) ;
# mysql -p # 测试mysql
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 5.1.55-log FreeBSD port: mysql-server-5.1.55
mysql>

==========================================================

PHP安装

1.安装PHP5
#whereis php5
#cd /usr/ports/lang/php5/
#make install clean
重启FreeBSD

2. 安装PHP扩展
# cd /usr/ports/lang/php5-extensions
# make install clean
需要配置 make config install clean
选择安装需要的扩展模块,如:

————————————————-
[X] DBASE dBase library support
[X] DOM DOM support
[X] FILEINFO fileinfo support
[X] FILEPRO filePro support
[X] FTP FTP support
[X] GD GD library support
[X] MBSTRING multibyte string support
[X] MYSQL MySQL database support
[X] OPENSSL OpenSSL support
[0] PDF PDFlib support (implies GD)
[X] PDO PHP Data Objects Interface (PDO)
[X] POSIX POSIX-like functions
[X] SESSION session support
[X] SIMPLEXML simplexml support
[X] SOAP SOAP support
[X] SOCKETS sockets support
[X] XML XML support
[X] XMLREADER XMLReader support
[X] XMLRPC XMLRPC-EPI support
[X] XMLWRITER XMLWriter support
[X] XSL XSL support (Implies DOM)
[X] ZIP ZIP support
[X] ZLIB ZLIB support

3.安装ZendOptimizer
#cd /usr/ports/devel/ZendOptimizer/ && make install clean
#cp /usr/local/etc/php.ini-dist php.ini
#vi /usr/local/etc/php.ini
在文件末端增加以下项:
[Zend]
zend_optimizer.optimization_level=15
zend_extension_manager.optimizer=”/usr/local/lib/php/20060613/Optimizer”
zend_extension_manager.optimizer_ts=”/usr/local/lib/php/20060613/Optimizer_TS”
zend_extension=”/usr/local/lib/php/20060613/ZendExtensionManager.so”
zend_extension_ts=”/usr/local/lib/php/20060613/ZendExtensionManager_TS.so”

=====================
!!!!!!!!!!喜欢Ctrl+c Ctrl+v的朋友一定注意此处了!!!注意全角半角…

# vi /usr/local/www/apache22/data/index.php # 编辑一個 phpinfo
<?php
phpinfo();
?>

4.重启FreeBSD, 在浏览器上键入http://127.0.0.1 或 http://localhost/ 或者http://服务器IP/ 来测试安装和设置是否成功.