位置: 编程技术 - 正文

freebsd6.2 nginx+php+mysql+zend系统优化防止ddos攻击

编辑:rootadmin

推荐整理分享freebsd6.2 nginx+php+mysql+zend系统优化防止ddos攻击,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

一、安装软件前的准备

系统的安装:插入freebsd6.2以上的光盘,最小化安装系统,同时安装好ports

二、手动安装nginx+php

1) 进入系统后,准备cvs更新:

1. cd /usr/ports/net/cvsup-without-gui

2. cp /usr/share/examples/cvsup/ports-supfile /etc/ports-supfile

3. # vi /etc/ports-supfile

将其中的#*default host=CHANGE_THIS.FreeBSD.org一行改为

*default host=cvsup4.FreeBSDchina.org

4. 更新ports

/usr/local/bin/cvsup -g -L 2 /etc/ports-supfile

2) 安装mysql

#cd /usr/ports/databases/mysql-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

3) 安装php

#cd /usr/ports/lang/php5

#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] PATHINFO Enable path-info-check support (CGI only)#make install clean

# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini ##cp php.ini配置文件

4) 安装php5-extensions

# cd /usr/ports/lang/php5-extensions/

#make config

Options for php5-extensions 1.1-------------------------------------------------[X] CURL CURL support

[X] FTP FTP support[X] GD [X] GETTEXT[X] MBSTRING multibyte string support

[X] MCRYPT Encryption support [X] MYSQL

[X] PCRE Perl Compatible Regular Expression support[ ] POSIX //去掉.[ ] SQLITE //去掉.

[X] ZIP ZIP support[X] ZLIB# make install clean

5) 安装Zend Optimizer

#cd /usr/ports/devel/ZendOptimizer/

#make #不要安装,只需要下载解包

#cd /usr/ports/devel/ZendOptimizer/work/ZendOptimizer-*

#./install-tty ##会出现一个文字的安装界面,只是最后一步,不要选择apache就可以了

#vi /usr/local/etc/php.ini #插入zend的路径,一般来说,上面的安装会自动加入下面的文字,假如没有,请手动添加。

[Zend]

zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.0

zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.0

zend_optimizer.version=3.3.0a

zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so

zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so

小提示:安装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还通用于大部分的环境

6) 安装nginx

#cd /usr/ports/www/nginx/

#make install

7) 安装lighttpd,为了得到fastcgi

# cd /usr/ports/www/lighttpd/

#make install

#rehash

8) 配置nginx

#user nobody删除前面的注释#,改成 user www

#log_format main '$remote_addr - $remote_user [$time_local] '

# '"$request" $status $body_bytes_sent '

# '"$http_referer" "$http_user_agent"';

log_format main '$remote_addr - $remote_user [$time_local] '

'"$request" $status $body_bytes_sent '

'"$http_referer" "$http_user_agent"';

##以上步骤,为了能够正常分析log的pv,hits,访问量,才设定的,默认的log格式,是无法准确分析出所需要的结果

location / { root /usr/local/www/nginx; index index.html index.htm;}在index.html前面添加一个index.phplocation / { root /data/web/www.jk.com/htdocs; index index.php index.html index.htm;}

#location ~ .php$ {# fastcgi_pass .0.0.1:;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script.name;# include fastcgi_params;#}将前面的#去掉,修改为location ~ .php$ { fastcgi_pass .0.0.1:; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/etc/nginx$fastcgi_script.name; include fastcgi_params;}##去掉注释,其实就是激活了nginx的fastcgi功能,也说明了nginx本身就已经准备用于fastcgi的环境中

9) 配置spawn-fcgi,就是一个启动fastcgi命令,使得nginx可以通过端口访问(纯粹个人理解-_-)

参数说明:****.0.0.1的端口,进程数为(如果服务器内存小于3GB,可以只开启个进程),用户为www

/usr/local/bin/spawn-fcgi -a .0.0.1 -p -u www -g www -C -f /usr/local/bin/php-cgi

) 这边请注意启动顺序,先启动fastcgi,再启动nginx

Nginx.conf由于经常需要修改,即经常需要重启nginx,因此这边写了一个启动脚本,请查看:

#!/usr/local/bin/bash

case $1 in

start)

/usr/local/sbin/nginx

;;

stop)

killall -9 nginx

;;

test)

nginx -t -c /usr/local/etc/nginx/nginx.conf

;;

restart)

ps auxww | grep nginx | grep master | awk '{print $2}' | xargs kill -HUP

;;

show)

ps -aux|grep nginx

;;

esac

保存为nginx.sh使用方法为:

nginx.sh start #启动nginx

nginx.sh stop #停止nginx

nginx.sh restart #重启nginx

freebsd6.2 nginx+php+mysql+zend系统优化防止ddos攻击

nginx.sh test #测试nginx.conf的准确性

) 安装phpMyAdmin

#cd /usr/ports/databases/phpmyadmin

#make install

#mv /usr/local/www/phpmyadmin /data/web/ www.jk.com/htdocs/

#cd /data/web/www.jk.com/htdocs/phpmyadmin

#vi config.inc.php ##这边要说明一下,freebsd默认安装的phpmyadmin,里面配置文件有问题,需要手动修改,请修改成如下内容:

<?php

/* $Id: config.sample.inc.php -- ::Z nijel $ */

// vim: expandtab sw=4 ts=4 sts=4:

/**

* phpMyAdmin sample configuration, you can use it as base for

* manual configuration. For easier setup you can use scripts/setup.php

*

* All directives are explained in Documentation.html and on phpMyAdmin

* wiki < */

/*

* This is needed for cookie based authentication to encrypt password in

* cookie

*/

$cfg['blowfish_secret'] = 'asdf:LKJ'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

/*

* Servers configuration

*/

$i = 0;

/*

* First server

*/

$i++;

/* Authentication type */

$cfg['Servers'][$i]['auth_type'] = 'cookie';

/* Server parameters */

$cfg['Servers'][$i]['host'] = 'localhost';

$cfg['Servers'][$i]['connect_type'] = 'tcp';

$cfg['Servers'][$i]['compress'] = false;

/* Select mysqli if your server has it */

$cfg['Servers'][$i]['extension'] = 'mysql';

/* User for advanced features */

// $cfg['Servers'][$i]['controluser'] = 'pam';

// $cfg['Servers'][$i]['controlpass'] = 'pampasswd';

/* Advanced phpMyAdmin features */

// $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';

// $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';

// $cfg['Servers'][$i]['relation'] = 'pma_relation';

// $cfg['Servers'][$i]['table_info'] = 'pma_table_info';

// $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';

// $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';

// $cfg['Servers'][$i]['column_info'] = 'pma_column_info';

// $cfg['Servers'][$i]['history'] = 'pma_history';

// $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';

/*

* End of servers configuration

*/

/*

* Directories for saving/loading files from server

*/

$cfg['UploadDir'] = '';

$cfg['SaveDir'] = '';

?>

以上只是一个配置文件,当你打开Phpmyadmin的时候,会提示你输入用户名密码,然后登陆数据库,相对比较安全的

三、系统优化+防止ddos

1) 这个话题有点大,我相信我做的只是其中很小的一部分,同时很多人也会问我,是不是要编译内核,这边的回答是不需要编译任何内核,只需要copy文件,然后重启一下服务器就可以了。

2) 加载文件修改

# vi /boot/loader.conf #加入如下文本

kern.dfldsiz="" # Set the initial data size limit

kern.maxdsiz="" # Set the max data size

kern.ipc.nmbclusters="0" # Set the number of mbuf clusters

kern.ipc.nsfbufs="" # Set the number of sendfile(2) bufs

##解释:

a. 第一,第二行主要是为了突破1G内存设置的

b. 第三行其实是bsd的一个bug,当系统并发达到一个数量级的时候,系统会crash,这个是非常糟糕的事情,所幸更改了这个参数后,在高并发的时候,基本可以没有类似情况,当然非常bt的情况,还得进一步想办法

c. 第四行是读取的文件数,如果你下载的文件比较大,且比较多,加大这个参数,是非常爽的

3) Sysctl修改

#vi /etc/rc.local

sysctl kern.ipc.maxsockets= ##增加并发的socket,对于ddos很有用

sysctl kern.ipc.somaxconn= ##打开文件数

sysctl net.inet.tcp.msl= ##timeout时间

4) 通过上述的简单优化,会给你带来意外的惊喜,如果有兴趣的兄弟,可以尝试一下看看,绝无副作用。

四、其他

1) 加速ports安装

#vi /etc/make.conf ##加入如下

MASTER_SITE_OVERRIDE?= Freebsd颜色显示

secureCRT设置:仿真:终端->linux>勾选ANSI颜色-->确定

#vi /etc/csh.cshrc ##加入如下

setenv LSCOLORS ExGxFxdxCxegedabagExEx

setenv CLICOLOR yes

#cd /usr/ports/edit/vim;make install

#echo "syntax on">/root/.vimrc

#echo "alias vi vim" >>/root/.cshrc

##颜色主要是靠vim来显示的,因此需要安装vim,然后把vi alias成vim就可以了

3) Other。。。。。。。。更新中

FreeBSD5.2.1上建立功能完整的邮件服务器(POSTFIX) 1.更新ports#cvsup-gL2-hcvsup.freebsdchina.org/usr/share/examples/cvsup/ports-supfile2.安装openssl+apache服务器#cd/usr/ports/security/openssl#makeinstall#makeclean#cd/usr/ports/www/apache2#mak

FreeBSD学习经验 1、进入单用户模式BOOT:/kernel-s就进了单用户了,然后/sbin/mount-rw/把/设置成可写然后vipw把root口令置空2、开机自动fsck硬盘fsck_y_enable=YES3、FreeBSD弹出光驱cdco

FREEBSD系统优化精华 1、优化内核mkdir/usr/kerncp/usr/src/sys/i/conf/GENERIC/usr/kern/proxyln-s/usr/kern/proxy/usr/src/sys/i/conf/proxycd/sys/i/confeeproxyoptionsIPFILTER#ipfiltersupportoptionsIPFILTER_LOG#ip

标签: freebsd6.2 nginx+php+mysql+zend系统优化防止ddos攻击

本文链接地址:https://www.jiuchutong.com/biancheng/353954.html 转载请保留说明!

上一篇:Freebsd7.0 Apache2.2+MySQL5+PHP5安装和配置方法

下一篇:FreeBSD5.2.1上建立功能完整的邮件服务器(POSTFIX)(freebsd怎么安装)

  • 居民个税和非居民个税哪个高
  • 实收资本印花税是营业账簿吗
  • 年应税销售额是利润表中的营业收入吗
  • 二手房交易需缴纳的费用
  • 开业费用属于什么费用
  • 银行打出的明细清单怎么看不懂
  • 公司员工的车外地的停车费怎么做分录
  • 高速过路费抵扣增值税
  • 小规模纳税人开具1%增值税专用发票可以抵扣吗
  • 公司注销固定资产交什么税
  • 分期付款的车怎么做分录
  • 社会团体非限定性净资产
  • 购买汽车可以开普通发票吗
  • 季度所得税申报可以弥补以前年度亏损吗
  • 其他应付款挂多少有风险
  • 商业承兑汇票需要银行审核吗
  • 盘盈现金计入当期损益
  • 小型微利企业收入超过300
  • 苹果mac电脑下刻字怎么弄
  • 记账凭证不见了怎么办
  • 购货款先到支付后付款
  • 代垫运费增值税怎么算
  • 为庆祝中秋而摆放的东西
  • 存货包括其他业务成本吗
  • 向银行借入长期借款200000元,存入银行
  • vue2 vue-router 不显示页面问题
  • 笑脸热气球 (© Leonsbox/Getty Images Plus)
  • 简单谈谈php中的安全性
  • 用smart原则改写年底前完善客户资料
  • uni-app原理
  • pytorch训练模型计算f1
  • 交通运输发票票样
  • 社保台账显示未托收
  • 劳务派遣小规模开票几个点
  • 公司食堂的费用分录
  • cms采集网站
  • 房产税的纳税义务人
  • 公立医院事业单位工作人员招聘实践考核自我评价
  • 小规模纳税人增值税申报表怎么填
  • 公司向个人租赁房屋办公要交税吗?
  • 建筑工程审计流程
  • 发票冲红原件需要拿回来吗
  • 只有销售才能使你成功的名言
  • 项目前期的研发费用
  • 可供出售金融资产属于什么科目
  • 电子记录表怎么填写
  • 哪些发票可以提供发票
  • 所得税会计凭证包括哪些
  • 酒店营业额成本比例
  • 现金投资属于什么会计科目
  • 汽车属于固定资产吗?如何计提折旧
  • 管理会计在企业中的地位如何?为什么
  • 微信开发中工具
  • mysql集群原理详解
  • win10最新预览版下载
  • 高危补丁该不该修补
  • linux怎么修改
  • Ubuntu Eclipse MyEclipse 添加GBK支持 不乱码
  • linux邮件设置方法
  • 华硕电脑升级win11
  • windows tcp
  • win8开机界面
  • linux中docker
  • win7系统屏幕保护设置禁用如何开启
  • git怎么备份
  • 批处理程序
  • jquery设置鼠标样式
  • nodejs xhr
  • js动态给table添加行
  • 在javascript中
  • shell中setenv
  • 电子税务局税务数字证书登录
  • 资源税选矿和原油的区别
  • 安徽省工商总局
  • 内蒙古物业费收取标准2020
  • 广东省行业税负率表
  • 消费税申报流程图
  • 供热企业税收优惠政策执行情况
  • 青海省地方税务局领导名单
  • 运输企业定额发票是什么
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设