我这里用的是FreeBSD的操作系统的.用curl 命令查看文件头 为了安全起见,我们需要将FreeBSD字样及其它信息隐藏起来.操作如下: 在httpd.conf文件里添加以下两行 ServerTokens Prod ServerSignature Off 重启apache即可.
Browsing the archives for the apache tag
有朋友问起,如何隐藏 HTTP header 中发送包含在 Server 信息里面的 Apache 和 PHP 版本号(譬如我们可以到 Firefox 的附加工具里面找 Live HTTP Headers;还可以用curl -I IPaddress|http://域名 ) 下面是做法: Apache: 打开 httpd.conf,在文件最后加入以下代码: #Hidden I can with apache version number ServerTokens ProductOnly ServerSignature Off PHP: 隐藏 PHP 版本就是隐藏类似于 "X-Powered-By: PHP/5.1.2-1+b1" 这个,开启 php.ini,加入: expose_php = Off 设置了expose_php=Off后,用phpinfo查看的时候,页面上原来正常显示的图片会消失隐藏的. 相关:http://blog.haohtml.com/archives/10761
统计apache日志中每日访问IP中访问量最大的100个IP地址 cat access.log |awk ‘{print $1}’|sort|uniq -c|sort -nr|head -100 > 37res.txt 来源:http://flychen.com/2011/06/statistics-apache-log-in-to-access-the-ip-to-access-the-daily-amount-of-up-to-100-ip
表示开启了索引模式(也就是目录浏览) Options Indexes indexOptions FancyIndexing ScanHTMLTitles NameWidth=128 DescriptionWidth=256 HTMLTable VersionSort FoldersFirst 可用参数,含义如下: #ScanHTMLTitles:搜索HTML标题 #NameWidth:文件命显示字节数 #DescriptionWidth:描述显示字节数 #HTMLTable:允许HTML格式 #FoldersFirst:目录优先 SuppressLastModified 在目录中禁止显示最近的修改时间 #索引排除语法 IndexIgnore header.html footer.html header.html footer.html 这两个文件不会在索引(目录浏览)中出现。 #索引头部嵌入文件 HeaderName /data/index/header.html #索引底部嵌入文件 ReadmeName /data/index/footer.html ReadmeName: 指定该目录列表的footer模板,指定一个html文件后,Apache会在目录列表的底部加载这个网页。(注意:文件路径是相对于列表目录的根而言的,并不是相对于系统根或者网站根。)
一台web服务器,上面有好几个虚拟主机,近日装上Squid 2.6进行WEB加速,Squid 和Apache均在同一台服务器上面,效果非常明显 主机配置为: CPU: 至强2.8G 内存: 1GB RAM 下载: wget http://www.squid-cache.org/Versions/v2/2.6/squid-2.6.STABLE6.tar.bz2 tar jxvf squid-2.6.STABLE6.tar.bz2 ./configure –prefix=/usr/local/squid --with-maxfd=65536 这个--with-maxfd参数是增大squid文件描述符到65536 安装完毕后开始配置/usr/local/squid/etc/squid.conf CODE: visible_hostname www.yoursite.com http_port xx.xx.xx.xx:80 vhost vport #xx.xx.xx.xx为这台服务器的IP地址
1.emerg 紧急 - 系统无法使用。 "Child cannot open lock file. Exiting" 2.alert 必须立即采取措施。 "getpwuid: couldn’t determine user name from uid" 3.crit 致命情况。 "socket: Failed to get a socket, exiting child" 4.error 错误情况。 "Premature end of script headers" 5.warn 警告情况。 "child process 1234 did not exit, sending another SIGHUP" 6.notice 一般重要情况。 "httpd: caught SIGBUS, attempting to dump [...]
所谓Apache出现CPU高占用率就是指Apache在一段时间内持续占用很高的CPU使用率,甚至达到CPU100%,这个时候造成网站无法访问。解决的方法就是仔细观察Apache的日志文件,查阅错误的信息。 我个人试了一下启用了 EnableSendfile Off 暂时解决了, 下面我们针对几种错误信息进行分析并给出解决的方法: 1. Apache与WinSock v2相冲突 Apache官方提供的手册中提到,在Windows系统下Apache2.x为了提高性能而使用了Microsoft WinSock v2 API,但是一些常见的防火墙软件会破坏他的正确性,从而使得Apache出现死循环操作造成CPU100%。 其错误提示如下所示: [error] (730038)An operation was attempted on something that is not a socket.: winnt_accept: AcceptEx failed. Attempting to recover. [error] (OS 10038) : Child 3356: Encountered too many errors accepting client connections. Possible causes: dynamic address renewal, or incompatible VPN or firewall [...]
国内网站盗链成风,最倒霉的就是咱们这种使用付费主机有流量限制的个人了。没办法,只得加上了一个简单的反盗链(Anti-Leech)措施。我的服务器是 Apache,处理防盗链比较简单,解决之后,于是写下这篇笔记。 一、 使用 rewrite 技术实现 Apache 防盗链 Apache 防盗链的第一种实现方法,可以用 rewrite 实现。首先要确认 Apache 的 rewrite module 可用:能够控制 Apache httpd.conf 文件的,打开 httpd.conf,确保有这么一行配置: LoadModule rewrite_module modules/mod_rewrite.so 然后在找到自己网站对应的 配置的地方,加入下列代码: ServerName haohtml.com # 防盗链配置 RewriteEngine On RewriteCond %{HTTP_REFERER} !^http://haohtml.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://haohtml.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.haohtml.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.haohtml.com$ [NC] RewriteRule .*\.(gif|jpg|swf)$ http://www.haohtml.com/about/nolink.png [R,NC] 防盗链配置的说明: 1. 红色部分: [...]
最近发现论坛的流量大涨,查后发现很多地方在调用论坛的图片,造成无用的流量,加大了服务器的负载,决定给CU论坛加上了防盗链图片功能 SetEnvIfNoCase Referer "chinaunix.net" local_ref=1 Order Allow,Deny Allow from env=local_ref 外部网站调用论坛的图片会跳转到另一张图: ErrorDocument 403 http://www.chinaunix.net/error.gif 下边转贴一篇老外写的文章,有时间再翻译 Preventing Image 'Theft'
1、PHPIniDir “D:\PHP5″ 这样不用每次都把php.ini拷贝到C:\Windows下 2、set Path=D:\PHP5;D:\PHP5\ext;%Path% 这样不用每次把那些dll拷贝到C:\Windows\system32下