setenv PACKAGEROOT “ftp://ftp.freebsdchina.org”
setenv PACKAGEROOT “ftp://ftp.cn.freebsd.org”
pkg_add -r cvsup-without-gui
rehash
首先在安装所有软件之前新系统ports,方法如上一贴
然后 再进行下面的工作
1)安装mysql
#cd /usr/ports/databases/mysql51-server
#make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes SKIP_DNS_CHECK=yes BUILD_OPTIMIZED=yes install clean //(utf8我选择了这个,情况自己定)
#cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
#rehash
!!!—–WITH_CHARSET=uft8(我选择了这个,情况自己定,可以使用gbk)
# mysql_install_db –user=mysql ##初始化mysql
#/usr/local/bin/mysqld_safe & ##启动mysql
#/usr/local/bin/mysqladmin -u root password ‘pass’ ##修改root密码,newpass是你需要改的密码
#/usr/local/bin/mysqladmin -u root password ‘mypassword’
2)安装php
# cd /usr/ports/lang/php5
# make config
[X] CLI Build CLI version
[X] CGI Build CGI version
[ ] APACHE Build Apache module //不安装这个
[ ] DEBUG Enable debug
[X]] SUHOSIN Enable Suhosin protection system
[X] MULTIBYTE Enable zend multibyte support
[ ] IPV6 Enable ipv6 support
[ ] REDIRECT Enable force-cgi-redirect support (CGI only)
[ ] DISCARD Enable discard-path support (CGI only)
[X] FASTCGI Enable fastcgi support (CGI only)
[X] PATHINFO Enable path-info-check support (CGI only)
# make install clean
#cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini
3)安装php5-extensions
# cd /usr/ports/lang/php5-extensions/
# make config
Options for php5-extensions 1.0
————————————————-
[X] FTP FTP support
[X] GD
[X] GETTEXT
[X] MBSTRING
[X] MYSQL
[ ] POSIX //去掉.
[ ] SQLITE //去掉.
[X] ZLIB
# make install clean
#rehash
4)安装Zend Optimizer
#cd /usr/ports/devel/ZendOptimizer/
方法一:
#make #不要安装,只需要下载解包
#cd /usr/ports/devel/ZendOptimizer/work/ZendOptimizer-*
#./install-tty ##会出现一个文字的安装界面,只是最后一步,不要选择apache就可以了
#vi /usr/local/etc/php.ini #插入zend的路径,一般来说,上面的安装会自动加入下面的文字。
[Zend]
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0
zend_optimizer.version=3.3.0a
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
方法二:
也可以用make install clean命令安装,则在php.ini文件里需要加上下面的代码:
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”
5)安装nginx
#cd /usr/ports/www/nginx/
#make install clean
#rehash
6)安装lighttpd
#cd /usr/ports/www/lighttpd/
#make install clean
#rehash
nginx+mysql开机后自动运行
#cat>>/etc/rc.conf
mysql_enable=”YES”
nginx_enable=”YES”
#
7)配置nginx
编辑nginx配置文件/usr/local/etc/nginx.conf
/usr/local/etc/nginx/nginx.conf
#user nobody
删除前面的注释#,改成 user www
location / {
root /usr/local/www/nginx;
index index.html index.htm;
}
在index.html前面添加一个index.php
location / {
root /usr/local/www/nginx;
index index.php index.html index.htm;
}
#location ~ \.php$ {
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script.name;
# include fastcgi_params;
#}
将前面的#去掉,修改为
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}
#为了使SCRIPT_FILENAME 有效,更改php.ini里面的cgi.fix_pathinfo=1;
这个地方非常重要,如果红色部分/usr/local/www/nginx不配置的话,如果执行php文件,就会出现No input file specified 错误提示。这个在网上查了半天才找到解决办法。切记切记!!
8)配置spawn-fcgi启动
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -f /usr/local/bin/php-cgi
参数说明:
-f 指定调用FastCGI的进程的执行程序位置,根据系统上所装的PHP的情况具体设置
-a 绑定到地址addr
-p 绑定到端口port
-s 绑定到unix socket的路径path
-C 指定产生的FastCGI的进程数,默认为5(仅用于PHP)
-P 指定产生的进程的PID文件路径
-u和-g FastCGI使用什么身份(-u 用户 -g 用户组)运行,Ubuntu下可以使用www-data,其他的根据情况配置,如nobody、apache等
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -f /usr/local/bin/php-cgi
或直接让它设置成开机服务启动:
#vi/etc/rc.local
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 25(进程数) -f /usr/local/bin/php-cgi
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 25 -f /usr/local/bin/php-cgi
这样spawn-fcgi就能开机自启动了
9)启动Nginx服务
#nginx
完成了,测试了phpinfo()
FreeBSD下nginx+fast-cgi+mysql+zend的实现
http://blog.sina.com.cn/s/blog_53c0ede50100gd3q.html