freebsd ports安装 nginx+php+mysql+fastcgi配置记录
第一次安装,借鉴了网上很多安装教程,现在把自己的安装步骤记录下来以供日后分析使用:开始准备工作,freebsd系统有ports包,所有使用程序都将通过此包安装:第一步我是先安装mysql 数据库:#cd /usr/ports/database/mysql51-server#make install clean然后等待自动编译安装过程安装完成,配置并启动mysql:#cd /usr/local/bin#mysql_install_db ?–user=mysql#mysql_saft & ? // 启动mysql#mysqladmin -uroot password ‘密码’ ? ? ?//设置mysql密码把mysql加入开机自启动一般有两种方法,#ee /etc/rc.conf加上一行: mysql_enable=”YES”不过我喜欢直接添加mysql-server.sh脚本到 /usr/local/etc/rc.d/#cp??/usr/local/chare/mysql/mysql.server /usr/local/etc/rc.d/mysql-server.shOK, reboot 系统看看, mysql安装成功
第二布安装php:#cd /usr/ports/lang/php5#make config??配置安装文件选上?fastcgi#make install clean又是漫长的自编译安装过程。完成切换:#cd /usr/local/etc#cp php.ini-dist php.ini ? ?//复制php.ini配置文件然后安装php5-extensions#cd /usr/ports/lang/php5-extensions#make config ? ? //选中mysql的驱动#make install clean编译安装完成,然后再安装ZendOptimizer#cd /usr/ports/devel/ZendOptimizer#make install clean编译安装完成,到此php算是安装完成第三布 开始安装 nginx#whereis nginxnginx: /usr/ports/www/nginx#cd /usr/ports/www/nginx#make install clean编译安装到完成然后获得spawn-fcgi 的支持要得到spawn-fcgi就要安装lighttpd#whereis lighttpd#cd /usr/ports/www/lighttpd#make install clean安装到现在正式完成。接下来配置nginx.conf#ee /usr/local/etc/nginx/nginx.conf?//配置
?
找到如下内容#user nobody;改成user www; #去掉前面#号—————-找到如下内容location / {root ? /usr/local/www/nginx;index index.html index.htm;}?
#!/bin/sh# Shell Script to start / stop PHP FastCGI using lighttpd – spawn-fcgi binary file.# ————————————————————————-# Copyright (c) 2006 nixCraft project <http://cyberciti.biz/fb/># This script is licensed under GNU GPL version 2.0 or above# ————————————————————————-# This script is part of nixCraft shell script collection (NSSC)# Visit http://bash.cyberciti.biz/ for more information.# ————————————————————————-PROVIDES=php-cgiLIGHTTPD_FCGI=/usr/local/bin/spawn-fcgiSERVER_IP=127.0.0.1SERVER_PORT=9000SERVER_USER=wwwSERVER_GROUP=wwwPHP_CGI=/usr/local/bin/php-cgiPGREP=/bin/pgrepKILLALL=/usr/bin/killall### No editing below ####cmd=$1pcgi_start(){echo “Starting $PROVIDES…”$LIGHTTPD_FCGI -a $SERVER_IP -p $SERVER_PORT -u $SERVER_USER -g $SERVER_GROUP -f $PHP_CGI}pcgi_stop(){echo “Killing $PROVIDES…”$KILLALL $PROVIDES}pcgi_restart(){pcgi_stoppcgi_start}pcgi_status(){$PGREP $PROVIDES > /dev/null[ $? -eq 0 ?] && echo “$PROVIDES running” || echo “$PROVIDES NOT running”}pcgi_help(){echo “Usage: $0 {start|stop|restart|status}”}case ${cmd} in[Ss][Tt][Aa][Rr][Tt]) pcgi_start;;[Ss][Tt][Oo][Pp]) pcgi_stop;;[Rr][Ee][Ss][Tt][Aa][Rr][Tt]) pcgi_restart;;[Ss][Tt][Aa][Tt][Uu][Ss]) pcgi_status 0;;*) ? ? ?pcgi_help ;;esac