安装

yum install -y vsftpd

安全配置

vi /etc/vsftpd/vsftpd.conf
#add
listen_port= XXXX
anonymous_enable=NO
local_enable=NO
chroot_local_user=YES
chroot_list_enable=NO

日志配置

xferlog_enable=YES
xferlog_std_format=YES 
xferlog_file=/var/log/xferlog   
dual_log_enable=YES 
vsftpd_log_file=/var/log/vsftpd.log  

添加虚拟用户

vi /etc/vsftpd/user_list.txt
#add
roooooooter
random_passwd
#生成认证文件
db_load -T -t hash -f /etc/vsftpd/user_list.txt /etc/vsftpd/user.db
#删除明文
rm -f vi /etc/vsftpd/user_list.txt
#编辑vsftpd的PAM认证文件
#删除其他行,加入下面两行
#pam_userdb.so 为认证库文件 db即上文user.db
vi /etc/pam.d/vsftpd
auth required pam_userdb.so db=/etc/vsftpd/user
account required pam_userdb.so db=/etc/vsftpd/user
#设定FTP用户映射(注意权限)
useradd –d /home/xxx –s /sbin/nologin xxx
chmod 700 /home/xxx
#开启虚拟用户
vi /etc/vsftpd/vsftpd.conf
#开启虚拟用户
guest_enable=YES
#FTP虚拟用户对应的系统用户
guest_username=xxx
#PAM认证文件
pam_service_name=user
#虚拟用户配置文件
user_config_dir=/etc/vsftpd/vsftpd_user_conf

配置虚拟用户

mkdir -p /etc/vsftpd/vsftpd_user_conf
#xxx为虚拟用户名
vi /etc/vsftpd/vsftpd_user_conf/xxx
#设置权限
local_root=/home/xxx
write_enable=YES #开放markwang的写权限
anon_world_readable_only=NO #开放markwang的下载权限
anon_upload_enable=YES #开放markwang的上传权限
anon_mkdir_write_enable=YES #开放markwang创建目录的权限
anon_other_write_enable=YES #开放markwang删除和重命名的权限

部分配置说明

virtual_use_local_privs

当virtual_use_local_privs=YES时,虚拟用户和本地用户有相同的权限;
当virtual_use_local_privs=NO时,虚拟用户和匿名用户有相同的权限,默认是NO。
 
当virtual_use_local_privs=YES,write_enable=YES时,虚拟用户具有写权限(上传、下载、删除、重命名)。
 
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=YES,
anon_upload_enable=YES时,虚拟用户不能浏览目录,只能上传文件,无其他权限。
 
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO,
anon_upload_enable=NO时,虚拟用户只能下载文件,无其他权限。
 
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO,
anon_upload_enable=YES时,虚拟用户只能上传和下载文件,无其他权限。
 
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO,
anon_mkdir_write_enable=YES时,虚拟用户只能下载文件和创建文件夹,无其他权限。
 
当virtual_use_local_privs=NO,write_enable=YES,anon_world_readable_only=NO,
anon_other_write_enable=YES时,虚拟用户只能下载、删除和重命名文件,无其他权限。

其他

anonymous_enable=YES            允许匿名登录local_enable=YES                  允许本地用户登录 
write_enable=YES                      开放本地用户写权限 
local_umask=022                        设置本地用户生成文件的掩码为022 
#anon_upload_enable=YES          此项设置允许匿名用户上传文件 
#anon_mkdir_write_enable=YES  开启匿名用户的写和创建目录的权限 
dirmessage_enable=YES            当切换到目录时,显示该目录下的.message隐藏文件的内容 
xferlog_enable=YES                    激活上传和下载日志 
connect_from_port_20=YES        启用FTP数据端口的连接请求 
#chown_uploads=YES                是否具有上传权限.  用户由chown_username参数指定。 
#chown_username=whoever        指定拥有上传文件权限的用户。此参数与chown_uploads联用。 
#xferlog_file=/var/log/vsftpd.log 
xferlog_std_format=YES              使用标准的ftpd xferlog日志格式 
#idle_session_timeout=600          此设置将在用户会话空闲10分钟后被中断 
#data_connection_timeout=120    将在数据连接空闲2分钟后被中断 
#ascii_upload_enable=YES        启用上传的ASCII传输方式 
#ascii_download_enable=YES    启用下载的ASCII传输方式 
#ftpd_banner=Welcome to blah FTP service 设置用户连接服务器后显示消息 
#deny_email_enable=NO  此参数默认值为NO。当值为YES时,拒绝使用banned_email_file参数指定文件中所列出的e-mail地址用户登录。 
#banned_email_file=/etc/vsftpd.banned_emails 指定包含拒绝的e-mail地址的文件. 
#chroot_list_enable=YES    设置本地用户登录后不能切换到自家目录以外的别的目录 
#chroot_list_file=/etc/vsftpd.chroot_list 
#ls_recurse_enable=YES 
pam_service_name=vsftpd 设置PAM认证服务的配置文件名称,该文件存放在/etc/pam.d/ 
userlist_enable=YES    此项配置/etc/vsftpd.user_list中指定的用户也不能访问服务器,若添加userlist_deny=No,则仅仅/etc /vsftpd.user_list文件中的用户可以访问,其他用户都不可以访问服务器。如过 userlist_enable=NO,userlist_deny=YES,则指定使文件/etc/vsftpd.user_list中指定的用户不可以访问服务器,其他本地用户可以访问服务器。 
listen=YES              指明VSFTPD以独立运行方式启动 
tcp_wrappers=YES        在VSFTPD中使用TCP_Wrappers远程访问控制机制,默认值为YES

参考

http://www.cnblogs.com/welkinwalker/archive/2010/04/14/1711880.html http://yuanbin.blog.51cto.com/363003/129071

我的歌单:http://music.163.com/#/user/home?id=17531384 试听地址:Of Monsters And Men - Dirty Paws

这首歌是白日梦想家的一段插曲,MV也很出色。这个乐队的歌曾经被APPLE作为广告曲。

Of Monsters And Men - Dirty Paws

歌词讲了一个有趣的故事,让人脑洞大开啊,真想和他们最后一起LALALA。

Jumping up and down the floor, my head is an animal. And once there was an animal, it had a son that mowed the lawn. The son was an ok guy, he had a pet dragonfly The dragonfly it ran away but it came back with a story to say. Her dirty paws and furry coat, she ran down the forest slope. The forest of talking trees, they used to sing about the birds and the bees. The bees had declared a war, the sky wasn’t big enough for them all. The birds, they got help from below, from Dirty Paws and the creatures of snow. And for a while things were cold, they were scared down in their holes. The forest that once was green was colored black by those killing machines. But she and her furry friends took down the queen bee and her men. And that’s how the story goes, the story of the beast with those four dirty paws.

歌词翻译:

在地板上上窜下跳 我的脑袋里有一只野兽 从前有一个野兽 他有一个修草坪的儿子 他儿子还算不错 养有一个宠物蜻蜓 蜻蜓飞向远方不知所踪 回来时为大家带来了一个故事 她有一双脏爪子和一件皮衣 她从森林的山坡向下跑 森林里的树会说话 他们以前歌颂森林里的鸟儿和蜜蜂 突然蜜蜂和鸟儿势不两立 因为天空太小容不下对方 鸟儿们得到了地面上的帮助 他们是脏爪子和冰雪生物 过了一会儿所有东西开始变得很冷 他们都被吓到所以躲避到了自己的家里 曾经的绿色的海洋 如今被那些杀戮机器所淹没 脏爪子和她的长毛伙伴们 最终将蜂后和他的士兵还是被打败了 故事就讲到这里 一个四脚野兽们的故事。

我的歌单:http://music.163.com/#/user/home?id=17531384 试听地址:http://music.163.com/#/share/17531384/24934611

有些时候不想说话,比如这会儿。

Olivia Broadfield - Say

歌词:

There is something I should say There is something I should tell you There is nothing in my way But I have to get it out of me Can we stay here just a little bit longer please Can you say things just to offer me some release No one ever sees the highs No one ever gets the best of me No one sees me through your eyes They are always second guessing me Can we stay here just a little bit longer please Can you say things just to offer me some release Can we stay here just a little bit longer please Can you say things just to offer me some release

有一些话我必须说 有些事情我想对你说 我没有什么不顺的 但是我必须把它说出来 我们能不能在这里多呆一会儿 你可以说一些宽慰我的话吗 没人见过最高的处 没人得到过最好的我 没人想你那样看着我

翻译的不好啊。。。

老高在一个新环境中装DEDECMS的时候发现后台验证码无法显示。直接搜索一下这个错误,有人说session错误,有的说权限错误等等,这不胡扯么!只能看源代码了,定位到文件/include/vdimgck.php。出错的函数是imagettftext(),由于织梦使用了@将错误隐去,导致这次莫名的错误。将@去掉,错误立马出现:

Fatal error: Call to undefined function imagettftext()

现在我们就明确了,出现错误的原因是PHP编译时没有加上FreeType

解决办法:

首先编译安装FreeType,以2.4.0为例:

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2
tar -jxf freetype-2.4.0.tar.bz2
cd reetype-2.4.0
# 安装到/usr/local/freetype
./configure --prefix=/usr/local/freetype
make && make install

下面我们重新编译PHP,加上参数--with-freetype-dir=/usr/local/freetype

./configure \
... \
... \
--with-freetype-dir=/usr/local/freetype

编译完成重启php

kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

再GD库中找到FreeType Support说明安装成功!

需要注意的是,如果服务器freetype的版本是1.*,那么你可能需要改变编译参数为--with-ttf[=DIR],以下转自ChinaUnix论坛:

字库 配置开关 FreeType 1.x 要激活 FreeType 1.x 的支持,加上 --with-ttf[=DIR]。
FreeType 2 要激活 FreeType 2 的支持,加上 --with-freetype-dir=DIR。
T1lib 要激活 T1lib(Type 1 字体),加上 --with-t1lib[=DIR]。
本地 TrueType 字符串函数 要激活本地 TrueType 字符串函数的支持,加上 --enable-gd-native-ttf。

参考:

http://bbs.chinaunix.net/thread-610205-1-1.html

钩子概念对初学者来说可能比较抽象难懂,但是只要掌握了他的工作方式,那么自己动手写一个钩子机制也不难。

Hook这个词很有意思,以下引用自某网络词典:

Hook用作名词时意思是“钩”,转化为动词时可表示把某物弯成钩形,也可表示用弯曲的东西把某物体钩住,引申可表示为“吊”“挂”等。

作为一个程序猿,老高对钩子的解释是,他就是一个触发机制,把你的软件功能想象成一个陷阱,放到##系统流程##可能经过的路上,如果陷阱被系统踩到,就会执行你的程序,当你挂载的钩子执行完后,系统会根据你的程序的结果继续运行。

老高最早接触Hook的编程思想是源于windows,当时打dota很入迷,突然想研究一下改键的原理,于是发现了系统钩子这一说法。

改键的原理,简单地说来就是拦截系统按下键盘时的默认动作,如果需要把小键盘的7映射到Q上,就在拦截时做一个判断,如果的键码是小键盘7,就改为Q的键码,最后发送给系统修改后的键码,即完成了改键操作。

钩子机制的使用在很多系统上都有体现,如windows、wordpress、thinkphp等,由钩子实现的功能在wordpress中叫做插件,在TP中叫做行为。

阅读剩余部分