Category Archives: Linux

给awstats增加城市信息显示

这个需要以前配置过GeoIP,我写过配置的说明,不多说了
 
下载MaxMind’s GeoLiteCity database

www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gzip -d GeoLiteCity.dat.gz
大约25M

复制GeoLiteCity.dat到/usr/local/share/GeoIP/下,然后修改awstats.yoursitenam.conf中的

LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat

使用wget和cron自动备份网站

对于一个静态网站,在没有负载均衡的情况下。如果主机出现问题,就会影响到正常访问。而如果同时没有及时备份,会导致网站直接停止服务或只能使用以前的存档来临时提供服务。
 
所以,使用wget同步网站,同时使用cron来定时运行。可以作为一种简单的解决方法。
执行:

#crontab -e

在其中增加

8 8,13,19 * * * cd /web/bak/;wget -m -nH -np -r -p -k http://www.sxyin.com;chown -R 33.33 /web/bak/

上面的这行意思,就是在每天的8点、13点、19点的8分定时同步网站。wget的参数以前介绍过,不多说了。
 
上面这种方法只适应于静态网站。同时还有一点,wget对javascript中包含的图片似乎不能正确地下载,往往会忽略结果。所以第一次还是手动同步一次,并补全需要的文件把

proftpd权限设置

proftpd默认用户可以使用系统非root组的用户登录,登陆后都在自己的/home目录中。
同时匿名用户不能登陆。而要对权限进行进一步的设置,需要在proftpd.conf里面进行定制。
在默认的conf中,有如下的例子
# <Anonymous ~ftp>
#   User    ftp
#   Group    nogroup
#   # We want clients to be able to login with "anonymous" as well as "ftp"
#   UserAlias   anonymous ftp
#   # Cosmetic changes, all files belongs to ftp user
#   DirFakeUser on ftp
#   DirFakeGroup on ftp
#
#   RequireValidShell  off
#
#   # Limit the maximum number of anonymous logins
#   MaxClients   10
#
#   # We want ‘welcome.msg’ displayed at login, and ‘.message’ displayed
#   # in each newly chdired directory.
#   DisplayLogin   welcome.msg
#   DisplayFirstChdir  .message
#
#   # Limit WRITE everywhere in the anonymous chroot
#   <Directory *>
#     <Limit WRITE>
#       DenyAll
#     </Limit>
#   </Directory>
#
#   # Uncomment this if you’re brave.
#   # <Directory incoming>
#   #   # Umask 022 is a good standard umask to prevent new files and dirs
#   #   # (second parm) from being group and world writable.
#   #   Umask    022  022
#   #            <Limit READ WRITE>
#   #            DenyAll
#   #            </Limit>
#   #            <Limit STOR>
#   #            AllowAll
#   #            </Limit>
#   # </Directory>
#
# </Anonymous>

Continue reading

proftpd配置笔记

以前使用vsftpd+mysql来做ftp。但vsftpd的配置比较弱,对虚拟用户的权限控制,只能通过系统对目录的权限控制来进行。所以现在打算使用proftpd来配置虚拟用户。
 
这几天参考了n多的教程。但大部分是基于redhat的,基于debian的配置很少很少。只能是一边研究一边写了。
 
1、安装
在debian下,安装proftpd非常简单,使用

apt-get install proftpd

但需要注意的是,使用命令

apt-cache search proftpd*

会有如下的结果

proftpd-doc – Versatile, virtual-hosting FTP daemon (Documentation)
proftpd-ldap – Versatile, virtual-hosting FTP daemon (with LDAP support)
proftpd-mysql – Versatile, virtual-hosting FTP daemon (with SQL support)
proftpd-pgsql – Versatile, virtual-hosting FTP daemon (with SQL support)

说明debian下面的proftpd根据所支持的模块,deb包的名称也不一样。如安装mysql支持,直接安装proftpd-mysql。这点和redhat不同,不需要在安装过程中安装各种模块了

Continue reading

关于locale的设定,为什么要设定locale

关于locale的设定
 
locale是国际化与本土化过程中的一个非常重要的概念,个人认为,对于中文用户来说,通常会涉及到的国际化或者本土化,大致包含三个方面:看中文,写中文,与window中文系统的兼容和通信。从实际经验上看来,locale的设定与看中文关系不大,但是与写中文,及window分区的挂载方式有很密切的关系。本人认为就像一个纯英文的Windows能够浏览中文,日文或者意大利文网页一样,你不需要设定locale就可以看中文。那么,为什么要设定locale呢?什么时候会用到locale呢?

Continue reading

apache限制ip连接数

首先,执行
#apt-get install libapache-mod-limitipconn
然后nano /etc/apache/httpd.conf
先找到这一行
#ExtendedStatus On
查看是否被注释了,如果是的话,去掉注释
再查找这个字符串mod_limitipconn.so
如果没找到任何记录,就在任何位置添加以下一行
LoadModule limitipconn_module modules/mod_limitipconn.so
然后就可以做限制了
对全局进行限制的话,就直接加入

 <IfModule mod_limitipconn.c>
  <Location />
   MaxConnPerIP 3            #每ip最多3个连接
   NoIPLimit image/*         #对图片不限制
  </Location>
 </IfModule>
如果你只想设置某个虚拟主机的连接限制,就把上面的那段放入
<VirtualHost>
</VirtualHost>
之中
如果只想限制某个目录的文件就可以这样
 
  <Location /mp3>
MaxConnPerIP 1  #限制1个连接
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
OnlyIPLimit audio/mpeg video  #只限制audio/mpeg video文件,如MP3呀WMA呀这种文件后缀名
    </Location>