<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></title> 
<link>http://www.bizeway.net/index.php</link> 
<description><![CDATA[网务通 - 网务公司发展之路]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[BIWEB开源PHP WMS系统创始人ArthurXF肖飞的blog]]></copyright>
<item>
<link>http://www.bizeway.net/read.php?</link>
<title><![CDATA[跟着ArthurXF学FreeBSD49——freebsd7.2 +nginx+php+mysql+zend+ phpmyadmin+系统优化+防止ddos +傻瓜式ports安装法]]></title> 
<author>ArthurXF &lt;arthurxf@gmail.com&gt;</author>
<category><![CDATA[FreeBSD]]></category>
<pubDate>Mon, 04 May 2009 11:32:25 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?</guid> 
<description>
<![CDATA[ 
	一、安装软件前的准备<br/>系统的安装：插入freebsd7.2以上的光盘，最小化安装系统，同时安装好ports<br/>二、手动安装nginx+php<br/>1) &nbsp; &nbsp; &nbsp; &nbsp;进入系统后，准备cvs更新：<br/>1. &nbsp; &nbsp; &nbsp; &nbsp; cd /usr/ports/net/cvsup-without-gui<br/>2. &nbsp; &nbsp; &nbsp; &nbsp; cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile<br/>3. &nbsp; &nbsp; &nbsp; &nbsp; # vi /etc/ports-supfile<br/>将其中的#*default host=CHANGE_THIS.FreeBSD.org一行改为<br/>*default host=cvsup.cn.freebsd.org<br/>4. &nbsp; &nbsp; &nbsp; &nbsp; 更新ports<br/> &nbsp; &nbsp;/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile<br/>2) &nbsp; &nbsp; &nbsp; &nbsp;安装mysql<br/>#cd /usr/ports/databases/mysql51-server<br/>#vi Makefile<br/>把--localstatedir=/var/db/mysql 改成--localstatedir=/usr/local/db/mysql后保存退出。这步主要是因为/var目录缺省分配的空间比较小。我们直接指定到一个大空间去存储mysql数据。<br/>#make WITH_CHARSET=utf8 WITH_COLLATION=utf8_general_ci WITH_XCHARSET=all WITH_PROC_SCOPE_PTH=yes BUILD_OPTIMIZED=yes BUILD_STATIC=yes SKIP_DNS_CHECK=yes WITHOUT_INNODB=yes install clean<br/>#cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf &nbsp; ##mysql的优化参数，也可以手动修改<br/># mysql_install_db --user=mysql &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##初始化mysql<br/>#/usr/local/bin/mysqld_safe & &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##启动mysql<br/>#/usr/local/bin/mysqladmin -u root password 'newpass' &nbsp; &nbsp;##修改root密码，newpass是你需要改的密码<br/>关闭mysql可以使用mysqladmin -uroot -p shutdown<br/>3) &nbsp; &nbsp; &nbsp; &nbsp;安装php<br/>#cd /usr/ports/lang/php5<br/>#make config &nbsp; &nbsp;##配置编译参数<br/>[X] CLI &nbsp; &nbsp; &nbsp; &nbsp;Build CLI version<br/>[X] CGI &nbsp; &nbsp; &nbsp; &nbsp;Build CGI version<br/>[ ] APACHE &nbsp; &nbsp; Build Apache module<br/>[ ] DEBUG &nbsp; &nbsp; &nbsp;Enable debug<br/>[X]] SUHOSIN Enable Suhosin protection system<br/>[X] MULTIBYTE Enable zend multibyte support<br/>[ ] IPV6 &nbsp; &nbsp; &nbsp; Enable ipv6 support<br/>[ ] REDIRECT &nbsp; Enable force-cgi-redirect support (CGI only)<br/>[ ] DISCARD &nbsp; &nbsp;Enable discard-path support (CGI only)<br/>[X] FASTCGI &nbsp; &nbsp;Enable fastcgi support (CGI only)<br/>[X] PATHINFO &nbsp; Enable path-info-check support (CGI only)<br/>#make install clean<br/># cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini &nbsp; ##cp php.ini配置文件<br/>4) &nbsp; &nbsp; &nbsp; &nbsp;安装php5-extensions<br/># cd /usr/ports/lang/php5-extensions/<br/>#make config<br/>Options for php5-extensions 1.1<br/>-------------------------------------------------<br/>[X] CURL &nbsp; &nbsp; &nbsp; &nbsp;CURL support<br/>[X] FTP &nbsp; &nbsp; &nbsp; &nbsp;FTP support<br/>[X] GD &nbsp; &nbsp; &nbsp; &nbsp;<br/>[X] GETTEXT<br/>[X] MBSTRING multibyte string support<br/>[X] MCRYPT &nbsp; &nbsp; &nbsp;Encryption support &nbsp;<br/>[X] MYSQL<br/>[X] PCRE &nbsp; &nbsp; &nbsp; &nbsp;Perl Compatible Regular Expression support<br/>[ ] POSIX //去掉.<br/>[ ] SQLITE //去掉.<br/>[X] ZIP &nbsp; &nbsp; &nbsp; &nbsp; ZIP support<br/>[X] ZLIB<br/># make install clean<br/>5) &nbsp; &nbsp; &nbsp; &nbsp;安装Zend Optimizer<br/>#cd /usr/ports/devel/ZendOptimizer/<br/>#make &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #不要安装，只需要下载解包<br/>#cd /usr/ports/devel/ZendOptimizer/work/ZendOptimizer-*<br/>#./install-tty &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ##会出现一个文字的安装界面，只是最后一步，不要选择apache就可以了<br/>#vi /usr/local/etc/php.ini &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#插入zend的路径，一般来说，上面的安装会自动加入下面的文字，假如没有，请手动添加。<br/><br/>[Zend]<br/>zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0<br/>zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0<br/>zend_optimizer.version=3.3.0a<br/>zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so<br/>zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so<br/><br/>小提示：安装zend，在freebsd下面，目前只有支持到php5.1.x，对于php5.2.x还不能支持，因为zend还没有为php5.2.x开发版本，在网上查了好多关于解决此类的问题，但得到的结果是，zend可以顺利安装，phpinfo也显示zend正常了，但程序无法调用，即zend没有工作，也就是目前无法解决，我想只有等到zend php5.2.x的版本后，才可以解决此问题，也希望哪位已经解决此类问题的兄弟，share一下你的经验。假如你非要使用zend，那就请你将php降到5.1.x，或者你不当心已经升级了ports，那建议你可以安装php4.x，毕竟目前php4.x还通用于大部分的环境<br/>6) &nbsp; &nbsp; &nbsp; &nbsp;安装nginx<br/>#cd /usr/ports/www/nginx/<br/>#make install<br/>7) &nbsp; &nbsp; &nbsp; &nbsp;安装lighttpd，为了得到fastcgi<br/># cd /usr/ports/www/lighttpd/<br/>#make install<br/>#rehash<br/>8) &nbsp; &nbsp; &nbsp; &nbsp;配置nginx<br/>vi /usr/local/etc/nginx/nginx.conf<br/>#user &nbsp; nobody<br/>删除前面的注释#，改成 user &nbsp; www<br/>#log_format &nbsp;main &nbsp;'$remote_addr - $remote_user [$time_local] '<br/># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$request" $status $body_bytes_sent '<br/># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$http_referer" "$http_user_agent"';<br/>log_format &nbsp;main &nbsp;'$remote_addr - $remote_user [$time_local] '<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$request" $status $body_bytes_sent '<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'"$http_referer" "$http_user_agent"';<br/>##以上步骤，为了能够正常分析log的pv，hits，访问量，才设定的，默认的log格式，是无法准确分析出所需要的结果<br/><br/>location / {<br/> &nbsp; &nbsp;root &nbsp; &nbsp;/usr/local/www/nginx;<br/> &nbsp; &nbsp;index &nbsp; &nbsp;index.html index.htm;<br/>}<br/>在index.html前面添加一个index.php<br/>location / {<br/> &nbsp; &nbsp;root &nbsp; &nbsp;/data/web/www.jk0086.com/htdocs;<br/> &nbsp; &nbsp;index &nbsp; &nbsp;index.php index.html index.htm;<br/>}<br/>#location ~ &#92;.php$ {<br/># &nbsp; &nbsp;fastcgi_pass &nbsp; &nbsp;127.0.0.1:9000;<br/># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fastcgi_index &nbsp; index.php;<br/># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fastcgi_param &nbsp; &nbsp; SCRIPT_FILENAME &nbsp; &nbsp; /scripts$fastcgi_script.name;<br/># &nbsp; &nbsp;include &nbsp; &nbsp; &nbsp;fastcgi_params;<br/>#}<br/>将前面的#去掉，修改为<br/>location ~ &#92;.php$ {<br/> &nbsp; &nbsp;fastcgi_pass &nbsp; &nbsp;127.0.0.1:9000;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fastcgi_index &nbsp; index.php;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fastcgi_param &nbsp; &nbsp; SCRIPT_FILENAME &nbsp; &nbsp; /usr/local/etc/nginx$fastcgi_script.name;<br/> &nbsp; &nbsp;include &nbsp; &nbsp; &nbsp;fastcgi_params;<br/>}<br/>##去掉注释，其实就是激活了nginx的fastcgi功能，也说明了nginx本身就已经准备用于fastcgi的环境中<br/><br/>9) &nbsp; &nbsp; &nbsp; &nbsp;配置spawn-fcgi，就是一个启动fastcgi命令，使得nginx可以通过9000端口访问（纯粹个人理解-_-）<br/>参数说明：监听127.0.0.1的9000端口，进程数为64（如果服务器内存小于3GB，可以只开启25个进程），用户为www<br/>/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -C 64 -f /usr/local/bin/php-cgi<br/>10) &nbsp; &nbsp; 这边请注意启动顺序，先启动fastcgi，再启动nginx<br/>Nginx.conf由于经常需要修改，即经常需要重启nginx，因此这边写了一个启动脚本，请查看：<br/>#!/usr/local/bin/bash<br/>case $1 in<br/>start)<br/> &nbsp; &nbsp; &nbsp; &nbsp;/usr/local/sbin/nginx<br/>;;<br/>stop)<br/> &nbsp; &nbsp; &nbsp; &nbsp;killall -9 nginx<br/>;;<br/>test)<br/> &nbsp; &nbsp; &nbsp; &nbsp;nginx -t -c /usr/local/etc/nginx/nginx.conf<br/>;;<br/>restart)<br/> &nbsp; &nbsp; &nbsp; &nbsp;ps auxww &#124; grep nginx &#124; grep master &#124; awk '{print $2}' &#124; xargs kill -HUP<br/>;;<br/>show)<br/> &nbsp; &nbsp; &nbsp; &nbsp;ps -aux&#124;grep nginx<br/>;;<br/>esac<br/>保存为nginx.sh使用方法为：<br/>nginx.sh start &nbsp; #启动nginx<br/>nginx.sh stop &nbsp; #停止nginx<br/>nginx.sh restart #重启nginx<br/>nginx.sh test &nbsp; #测试nginx.conf的准确性<br/>11) &nbsp; &nbsp; 安装phpMyAdmin<br/>#cd /usr/ports/databases/phpmyadmin<br/>#make install<br/>#mv /usr/local/www/phpmyadmin /data/web/ www.jk0086.com/htdocs/<br/>#cd /data/web/www.jk0086.com/htdocs/phpmyadmin<br/>#vi config.inc.php &nbsp; ##这边要说明一下，freebsd默认安装的phpmyadmin，里面配置文件有问题，需要手动修改，请修改成如下内容：<br/><br/><br/><br/>/* $Id: config.sample.inc.php 9689 2006-11-10 20:05:49Z nijel $ */<br/><br/>// vim: expandtab sw=4 ts=4 sts=4:<br/><br/><br/><br/>/**<br/><br/>* phpMyAdmin sample configuration, you can use it as base for<br/><br/>* manual configuration. For easier setup you can use scripts/setup.php<br/><br/>*<br/><br/>* All directives are explained in Documentation.html and on phpMyAdmin<br/><br/>* wiki .<br/><br/>*/<br/><br/><br/><br/>/*<br/><br/>* This is needed for cookie based authentication to encrypt password in<br/><br/>* cookie<br/><br/>*/<br/><br/>$cfg['blowfish_secret'] = 'asdf:LKJ'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */<br/><br/><br/><br/>/*<br/><br/>* Servers configuration<br/><br/>*/<br/><br/>$i = 0;<br/><br/><br/><br/>/*<br/><br/>* First server<br/><br/>*/<br/><br/>$i++;<br/><br/>/* Authentication type */<br/><br/>$cfg['Servers'][$i]['auth_type'] = 'cookie';<br/><br/>/* Server parameters */<br/><br/>$cfg['Servers'][$i]['host'] = 'localhost';<br/><br/>$cfg['Servers'][$i]['connect_type'] = 'tcp';<br/><br/>$cfg['Servers'][$i]['compress'] = false;<br/><br/>/* Select mysqli if your server has it */<br/><br/>$cfg['Servers'][$i]['extension'] = 'mysql';<br/><br/>/* User for advanced features */<br/><br/>// $cfg['Servers'][$i]['controluser'] = 'pam';<br/><br/>// $cfg['Servers'][$i]['controlpass'] = 'pampasswd';<br/><br/>/* Advanced phpMyAdmin features */<br/><br/>// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';<br/><br/>// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';<br/><br/>// $cfg['Servers'][$i]['relation'] = 'pma_relation';<br/><br/>// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';<br/><br/>// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';<br/><br/>// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';<br/><br/>// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';<br/><br/>// $cfg['Servers'][$i]['history'] = 'pma_history';<br/><br/>// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';<br/><br/><br/><br/>/*<br/><br/>* End of servers configuration<br/><br/>*/<br/><br/><br/><br/>/*<br/><br/>* Directories for saving/loading files from server<br/><br/>*/<br/><br/>$cfg['UploadDir'] = '';<br/><br/>$cfg['SaveDir'] = '';<br/><br/><br/><br/>?><br/><br/><br/>以上只是一个配置文件，当你打开Phpmyadmin的时候，会提示你输入用户名密码，然后登陆数据库，相对比较安全的<br/><br/><br/>三、系统优化+防止ddos<br/>1) &nbsp; &nbsp; &nbsp; &nbsp;这个话题有点大，我相信我做的只是其中很小的一部分，同时很多人也会问我，是不是要编译内核，这边的回答是不需要编译任何内核，只需要copy文件，然后重启一下服务器就可以了。<br/>2) &nbsp; &nbsp; &nbsp; &nbsp;加载文件修改<br/># vi /boot/loader.conf &nbsp; &nbsp;#加入如下文本<br/>kern.dfldsiz="2147483648" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Set the initial data size limit<br/>kern.maxdsiz="2147483648" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Set the max data size<br/>kern.ipc.nmbclusters="0" &nbsp; &nbsp; &nbsp; &nbsp;# Set the number of mbuf clusters<br/>kern.ipc.nsfbufs="66560" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Set the number of sendfile(2) bufs<br/>##解释：<br/>a． &nbsp;第一，第二行主要是为了突破1G内存设置的<br/>b． &nbsp;第三行其实是bsd的一个bug，当系统并发达到一个数量级的时候，系统会crash，这个是非常糟糕的事情，所幸更改了这个参数后，在高并发的时候，基本可以没有类似情况，当然非常bt的情况，还得进一步想办法<br/>c． &nbsp;第四行是读取的文件数，如果你下载的文件比较大，且比较多，加大这个参数，是非常爽的<br/><br/>3) &nbsp; &nbsp; &nbsp; &nbsp;Sysctl修改<br/>#vi /etc/rc.local<br/>sysctl kern.ipc.maxsockets=100000 &nbsp; &nbsp;##增加并发的socket，对于ddos很有用<br/>sysctl kern.ipc.somaxconn=65535 &nbsp; &nbsp; ##打开文件数<br/>sysctl net.inet.tcp.msl=2500 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;##timeout时间<br/><br/><br/>4) &nbsp; &nbsp; &nbsp; &nbsp;通过上述的简单优化，会给你带来意外的惊喜，如果有兴趣的兄弟，可以尝试一下看看，绝无副作用。<br/><br/>四、其他<br/>1) &nbsp; &nbsp; &nbsp; &nbsp;加速ports安装<br/>#vi /etc/make.conf &nbsp; &nbsp; ##加入如下<br/>MASTER_SITE_OVERRIDE?=http://ports.hshh.org/${DIST_SUBDIR}/<br/>MASTER_SITE_OVERRIDE?=http://ports.cn.freebsd.org/${DIST_SUBDIR}/<br/><br/>2) &nbsp; &nbsp; &nbsp; &nbsp;Freebsd颜色显示<br/>secureCRT设置:仿真:终端->linux>勾选ANSI颜色-->确定<br/>#vi /etc/csh.cshrc &nbsp; &nbsp;##加入如下<br/>setenv LSCOLORS ExGxFxdxCxegedabagExEx <br/>setenv CLICOLOR yes<br/>#cd /usr/ports/edit/vim;make install<br/>#echo "syntax on">/root/.vimrc<br/>#echo "alias vi &nbsp; &nbsp; &nbsp; &nbsp;vim" >>/root/.cshrc<br/>##颜色主要是靠vim来显示的，因此需要安装vim，然后把vi alias成vim就可以了<br/>3) &nbsp; &nbsp; &nbsp; &nbsp;Other。。。。。。。。更新中<br/>Tags - <a href="tag.php?tag=freebsd" rel="tag">freebsd</a> , <a href="tag.php?tag=nginx" rel="tag">nginx</a>
]]>
</description>
</item><item>
<link>http://www.bizeway.net/read.php?&amp;guid=0#topreply</link>
<title><![CDATA[[评论] 跟着ArthurXF学FreeBSD49——freebsd7.2 +nginx+php+mysql+zend+ phpmyadmin+系统优化+防止ddos +傻瓜式ports安装法]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.bizeway.net/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>