FreeBSD下NGINX 1.8+PHP5.6 +PERL 5.20 +Mysql 5.6+FTP 环境搭建与优化1

FreeBSDNGINX 1.8+PHP5.6 +PERL 5.20 +Mysql 5.6FTP 环境搭建与优化

FreeBSDNGINX 1.8+PHP5.6 +PERL 5.20 +Mysql 5.6FTP
环境搭建与优化

为什么选择FreeBSD做为os,这里不再讲,具体可以看这里《Free
BSD,Linux之比较》

附件提供了已做了优化后的配置文件,下载直接可以使用。

#安装perl 支持

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

cd /usr/ports/lang/perl5.20 && make config

#安装完以后发现新版本的5.20perl改变了目录,这里做个链接。

ln -s /usr/local/bin/perl /usr/bin/perl

#安装perl支持组件(perl on nginx

cd /usr/ports/databases/rrdtool && make install clean
cd /usr/ports/databases/p5-DBD-mysql && make install clean
cd /usr/ports/devel/p5-File-Tail && make install clean
cd /usr/ports/devel/p5-Time-HiRes && make install clean
cd /usr/ports/graphics/p5-GD && make install clean
cd /usr/ports/sysutils/p5-Unix-Syslog && make install clean
cd /usr/ports/www/p5-LWP-UserAgent-WithCache && make install clean
cd /usr/ports/dns/p5-Net-DNS && make install clean
cd /usr/ports/security/p5-Digest-HMAC && make install clean
cd /usr/ports/security/p5-Digest-MD5 && make install clean
cd /usr/ports/security/p5-Digest-Perl-MD5 && make install clean
cd /usr/ports/security/p5-Digest-SHA1 && make install clean
cd /usr/ports/net-mgmt/p5-Net-IP && make install clean
cd /usr/ports/lang/p5-ExtUtils-F77 && make install clean
cd /usr/ports/www/p5-FCGI && make install clean
cd /usr/ports/www/p5-FCGI-ProcManager && make install clean
--------------------------------------

#安装nginx(组件根据自已需要勾选)

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

cd /usr/ports/www/nginx && make config

#安装php 5.6 on nginx(组件根据自已需要勾选)

cd /usr/ports/lang/php56 && make config

#安装php 5.6的扩展库(组件根据自已需要勾选)

cd /usr/ports/lang/php56-extensions && make config

#安装php常用的支持库

cd /usr/ports/databases/php5-redis && make install clean
cd /usr/ports/databases/pecl-memcache && make install clean
cd /usr/ports/graphics/ImageMagick && make install clean
cd /usr/ports/graphics/pecl-imagick && make install clean
cd /usr/ports/graphics/php-magickwand && make install clean

#安装常用的缓存及数据服务

cd /usr/ports/databases/redis && make install clean
cd /usr/ports/databases/memcached && make install clean
cd /usr/ports/www/xcache && make install clean
cd /usr/ports/databases/mysql56-client && make install clean
--------------------------------------

#将服务加入开机启动项

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

vi /etc/rc.conf

#############################
sendmail_enable=”NO”
sendmail_submit_enable=”NO”
sendmail_outbound_enable=”NO”
sendmail_msp_queue_enable=”NO”
############################
mysql_enable=”YES”
memcached_enable=”YES”
redis_enable=”YES”
############################
php_fpm_enable=”YES”
perl_fcgi_enable=”YES”
nginx_enable=”YES”
############################
pureftpd_enable=”YES”

#先启动redismemcached服务,这两个无需配置,默认即可。

/usr/local/etc/rc.d/redis restart
/usr/local/etc/rc.d/memcached restart
--------------------------------------

#配置nginx
--------------------------------------

#下载配置脚本:附件 nginx-config.zip
#解压后获取文件(vhosts_paramsnginx.confmime.typesfastcgi_paramsdomain.com

目录结构

nginx /


—— vhosts_params
—— nginx.conf
—— mime.types
—— fastcgi_params
——……..
——vhosts
——domain.com
——……

#将 vhosts_paramsnginx.confmime.typesfastcgi_params 文件移动到如下目录

mv vhosts_params /usr/local/etc/nginx/
mv fastcgi_params /usr/local/etc/nginx/
mv nginx.conf /usr/local/etc/nginx/
mv mime.types /usr/local/etc/nginx/

#然后进入nginx下建立 vhosts 目录

vhosts目录以后放置
虚拟站点的配置文件

cd /usr/local/etc/nginx/
mkdir vhosts

#将 domain.com 移动到 /usr/local/etc/nginx/vhosts/ 目下

mv domain.com /usr/local/etc/nginx/vhosts/

#有关domain.com 的配置说明

server
{
listen 80;
#server_name _; #
这个是所有域名均可访问

server_name abc.domain.com; #
这个是指定域名访问

index index.html index.htm index.php index.cgi;
root /usr/local/www/abc.domain.com; #
网站文件的目录位置

include vhosts_params;
}

#有关 vhosts_params文件的说明

vhosts_params 文件是我建立的一个配置文件,主要方便后面做多个虚拟主机时可以快速的引用。

location ~* ^.+.gzjs$ { #支持对jscss等脚本的压缩

add_header Content-Encoding gzip;
gzip off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { #将图片文件本地缓存30

expires 30d;
}

location ~ .*\.(js|css)?$ { #将js css文件本地缓存30

expires 1h;
}

location ~ \.php$ { php-fcgi的配置,支持php文件

gzip off;
fastcgi_pass unix:/var/run/php-fcgi.sock;
fastcgi_index index.php;
include fastcgi_params;
# fastcgi_cache ngx_fcgi_cache;
# fastcgi_cache_key $scheme$request_method$host$request_uri;
}

location ~ .*\.(pl|cgi)?$ { perl-fcgi的配置,支持cgi pl文件

gzip off;
fastcgi_pass unix:/var/tmp/perl-fcgi.sock;
fastcgi_index index.cgi;
include fastcgi_params;
# fastcgi_cache ngx_fcgi_cache;
# fastcgi_cache_key $scheme$request_method$host$request_uri;
}

location ~ ^/nginxstatus/ { #打开nginxstatus状态显示

stub_status on;
}

error_page 404 = /404/; #定义404错误的信息

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

#配置nginx支持
php

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

#下载配置脚本:附件
php-config.zip
#替换原有的配置文件

mv php-fpm.conf /usr/local/etc/
mv php.ini /usr/local/etc/

#启动nginxphp-fpm
/usr/local/etc/rc.d/php-fpm restart
/usr/local/etc/rc.d/nginx restart

vi /usr/local/www/domain.com/phptest.php

#访问查看php情况:http://domain.com/phptest.php

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

#配置xcache php
缓存

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

#
下载配置脚本:附件 xcache.ini.zip
#
修改xcache.ini里的管理帐号密码

xcache.admin.user = “admin”
xcache.admin.pass = “11a885b207496d7460635c274ffa9da0″

#生成mud5加密密码在这里

#
http://xcache.lighttpd.net/demo/cacher/mkpassword.php

#xcache.ini放到php扩展目录下,php启动时会自动加载

mv xcache.ini /usr/local/etc/php/

#生成Xcache缓存文件

touch /var/tmp/xcache
chmod 777 /var/tmp/xcache

以下文章点击率最高

Loading…


发表评论

电子邮件地址不会被公开。 必填项已用*标注