[架设教程]freebsd ports安装php+fpm+mysql+nginx【最新】

作者:笨小孩 发布于:2013-5-22 9:36 分类:环境架设

系统版本:FreeBSD8.3 amd64

Php版本:5.2

Mysql版本:5.1

Nginx版本:默认

一、安装软件前的准备:

系统的安装:让机房最小化安装freebsd系统。开启ssh。

 

二、安装、更新ports

# portsnap fetch
//
假如您是首次运行 Portsnap, 则需要将快照释放到 /usr/ports
# portsnap extract
//
如果您已经有装好的 /usr/ports 而您只想更新,则应执行下面的命令:
# portsnap update


三、 安装mysql

#cd /usr/ports/databases/mysql51-server

#make WITH_CHARSET=gbk WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean

#cp /usr/local/share/mysql/my-large.cnf /usr/local/etc/my.cnf   //mysql的优化参数,也可以手动修改

#rehash

# mysql_install_db --user=mysql          //初始化mysql

#/usr/local/bin/mysqld_safe &            //启动mysql

#/usr/local/bin/mysqladmin -u root password 'newpass'  

 //设置root密码,newpass是你需要设置的密码

关闭mysql可以使用mysqladmin -uroot -p shutdown

mysqladmin -uroot -p password '新密码'    回车后输入旧密码

 mysql -uroot -p  #登陆mysql monitor.

四、 安装php

# cd /usr/ports/lang/php52 //装的是5.2版本,后装php5-extensions的时候对应的要cd /usr/ports/lang/php52-extensions

#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] FPM      Build FPM version //php5.2 FPM依赖FASTCGI

[X] PATHINFO  Enable path-info-check support (CGI only)

#make install clean

# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

 

五、 安装php52-extensions

#cd /usr/ports/lang/php52-extensions //5.2版本的php必须对应装5.2版本的扩展

#make config

Options for php5-extensions 1.1

-------------------------------------------------

[X] CURL       CURL support

[ ] FTP       FTP support//不需要

[X] GD       e in

[X] GETTEXT

[X] MBSTRING multibyte string support

[X] MCRYPT     Encryption support 

[X] MYSQL

[X] MYSQLi

[ ] PCRE        Perl Compatible Regular Expression support

[ ] POSIX //去掉.

[ ] SQLITE //去掉.

[X] ZIP        ZIP support

[X] ZLIB

# make install clean

不同以前版本,安装完php52-extensions发现很多扩展并没有安装,手动挨个去安装吧,包括:mysqlmysqligdmbstingcurl,其中,安装gd扩展耗时较长,下载依赖类库较多,多次弹出选择框。

# cd /usr/ports/databases/php52-mysql

# make install clean

# cd /usr/ports/databases/php52-mysqli

# make install clean

# cd /usr/ports/graphics/php52-gd

# make install clean

# cd  /usr/ports/converters/php52-mbstring

# make install clean

# cd  /usr/ports/ftp/php52-curl

# make install clean



 通过上图中配置信息得知,php.ini所在位置较以前有变化,且php加载扩展的配置已单独拿出放到extensions.ini中,一行一个扩展,扩展so文件所在目录也可得出。

六、    安装Zend Optimizer

Ports源更改更新方式后,没找到安装zend办法,求解。


七、       安装nginx

#cd /usr/ports/www/nginx/

#make install

 

配置nginx

index.html前面添加一个index.php

 

location / {

    root   /usr/local/www/nginx; #虚拟目录名

index   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$ {

    root   /usr/local/www/nginx; #虚拟目录名

    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;

}

八、添加开机自启动:

/etc/rc.conf中加入下面三行内容:

mysql_enable="YES"

nginx_enable="YES"

php_fpm_enable="YES"

 

//手动

/usr/local/etc/rc.d/nginx start|stop|restart

/usr/local/etc/rc.d/php-fpm start|stop|restart

/usr/local/etc/rc.d/mysql-server start|stop|restart

标签: MySQL php freebsd ports Nginx portsnap

发表评论:

手机版 | 
Copyright © 2012 lamp46.com All Right Reserved. sitemap