分类存档: freebsd

freebsd上搭建nginx+php(fpm)+mysql环境

以前我写的一篇文章,现在转到这里。
基于freebsd8.2系统。
1、开放ssh:

vi /etc/inetd.conf

去掉ssh前的#
允许root登录:

vi /etc/ssh/sshd_config
PermitRootLogin yes

重启ssh:

service sshd restart

2、安装多线程下载工具更新

cd /usr/ports/ftp/axel
make install clean

然后:

vi /etc/make.conf

添加如下代码

FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes
MASTER_SITE_BACKUP?=http://mirrors.163.com/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?=${MASTER_SITE_BACKUP}

注:最后两行是使用163的源
3、下载更新:

#portsnap fetch extract

4、安装nginx

cd /usr/ports/www/nginx
make install clean

设置开机启动:

echo nginx_enable="YES" >> /etc/rc.conf

5、安装php5、fpm

cd /usr/ports/lang/php5

选择支持 fastCGi和php-fpm

make config
make install clean
cd /usr/ports/lang/php5-extensions/
make config
make install clean

设置fpm开机启动

echo php_fpm_enable="YES" >> /etc/rc.conf

6、php.ini

cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini
vi /usr/local/etc/php.ini

修改

;date.timezone =

date.timezone = 'Asia/Shanghai'

7、安装mysql

cd /usr/ports/databases/mysql51-server
make install clean

设置mysql开机启动:

echo mysql_enable=”YES” >> /etc/rc.conf

添加root密码:

mysqladmin -u root password yourpassword

8、安装eaccelertor

cd /usr/ports/www/eaccelerator
make install clean
vi /usr/local/etc/php/extensions.ini

添加

extension=eaccelerator.so

安装Memcache扩展

cd /usr/ports/databases/pecl-memcache
make install clean

freebsd升级已安装的ports

1、更新ports Collection

portsnap fetch update

2、查询哪些ports需要升级:

pkg_version -v -L=

3、升级ports:

cd /var/db/pkg/
pkg_delete gmake-{version}
cd /usr/ports/
make search name=gmake
cd /usr/ports/devel/gmake/
make install clean