ubuntuvsftpd:ubuntu LAMP配置例子+VSFTPD虚拟用户管理网站WebSite



1、更新

apt-get update

2、安装必须

apt-get php5

apt-get apache2 mysql-server mysql-client php5-mysql php5-curl php5-gd libapache2-mod-php5 php5-mysql

3、/etc/apache2/httdpd.conf 添加:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps 字串6

4、ln -s /etc/apache2/mods-available/php5.* /etc/apache2//mods-enabled 字串5

5、apt-get apache2-mpm-prefork

6、/etc/init.d/apache2 restart

网站WebSite管理(VSFTPD):

、安装所需软件Software包
apt-get vsftpd mysql-server mysql-client libpam-mysql
libpam-mysql 这个包可以让PAM读取MySQL数据来验证用户信息其它软件Software包就不用解译了吧!

2、设置FTP用户权限和家目录
在操作第步骤完后系统会自动创建系统用户名:ftp这个用户就是vsftpd默认匿名用户没有其它权限在我工作环境下这个用户名家目录是/home/ftpRH系统ftp家目录是/var/ftp呵呵这都是无关紧要可以自由设置!你也可以自定义ftp匿名用户并作相关修改下载教程中用户ftp也应修改成你自定义用户名
默认/home/ftp权限并不是用户ftp我们要修改下
#mkdir /home/ftp/temp
#chown -R ftp.nogroup /home/ftp

3、配置MySQL数据库
说起mysql我也惭愧我对数据库是点也不懂!直以来我把数据库就简单理解为个庞大信息仓库即原是信息就不得不想起安全吧!mysql默认状态下是很不安全我这里就只能简单设置下口令至于mysql优化请大家去阅读mysql手册吧!
#mysqladmin -u root -p password 123456 修改mysqlroot密码次修改root密码是空所以不用输入旧密码
连接数据库:
#mysql -h 127.1 -u root -p 使用root用户连入本机mysql服务器
Enter password: 输入root用户密码注意:不是系统根用户哦
mysql> 连入成功!如果没有出现这个提示符则是上面两个步骤没有正确
mysql>create databases vsftpd; 建立库名记住在mysql环境下命令结束必须有“;”如果忘记了输入“;”也不怕忘记了输入“;”则是换行在mysql里面命令是可以分成几行执行你再输入“;”起同样作用
mysql>show databases; 查看库名是否建立如果没有则重新执行上
mysql>use vsftpd; 打开库vsftpd以下操作就会针对vsftpd库
mysql>create table users (name varchar(20) not null,password varchar(20) not null,primary key (name)) type=myisam; 创建名为users表名其中设置了两个键name和password这里比较难理解解释吧!varchar(20) not null设置键长度为20且不能为空primary key(name)设置表主键(主键是不能赋相同ftp用户名不能相同)type=myisam设置表类型(MyISAM 全新 2进制可移植表处理器)这个是默认可以省略
mysql>show tables; 查看表是否建立成功没有请退到上
mysql>insert o users values('admin','admin'); 建设虚拟用户admin密码为admin
mysql>insert o users values('download','download');
mysql>insert o users values('upload','upload');
mysql>insert o users values('web','web');
mysql>select * from users; 验证结果如果看不到刚才建立虚拟用户那么请退到上
MySQL数据建好了但是我们不能直接用root用户吧要给它建立个用户供pam使用
mysql>grant select _disibledevent=>


grant 命令
select _disibledevent=> account required pam_mysql.so user=vsftpd passwd=vsftpd host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=0
解释下:
user=vsftpd 刚才添加mysql用户名
passwd=vsftpd 刚才添加用户名密码
host=localhost mysql服务器名我是做在本机所以……
db=vsftpd 和这个对应create databases vsftpd是存储用户名mysql库名
table=users 存储用户名mysql库中表名
usercolumn=name 和mysql对应
passwdcolumn=password 和mysql对应
crypt=0 加密方式0表示明文1表示unix方式加密2表示mysql中password加密,3表示md5加密不过我都只有做成明文才成功了,1、2、3思路方法都不行! 知道朋友告诉下哦!



5、配置vsftpd这里很重要请大家参考vsftpd手册我这里只简单实现
#vim /etc/vsftpd.conf
#接受匿名用户
anonymous_enable=YES
#匿名用户login时不询问口令
no_anon_password=YES
#匿名用户主目录
anon_root=(none)
#接受本地用户
local_enable=YES
#本地用户主目录
local_root=(none)
#如果匿名用户需要密码,那么使用banned_email_file里面电子邮件地址用户不能登录
deny_email_enable=YES
#仅在没有pam验证版本时有用,是否检查用户有个有效shell来登录
check_shell=YES
#若启用此选项,userlist_deny选项才被启动
userlist_enable=YES
#若为YES,则userlist_file中用户将不能登录,为NO则只有userlist_file用户能登录
userlist_deny=NO
#如果和chroot_local_user起开启,那么用户锁定目录来自/etc/passwd每个用户指定目录(这个不是非常清晰,非常哪位熟悉指点下)
passwd_chroot_enable=NO
#定义匿名登入使用者名称默认值为ftp
ftp_username=FTP
#################用户权限控制###############
#能上传(全局控制).
write_enable=YES
#本地用户上传文件umask
local_umask=022
#上传文件权限配合umask使用
#file_open_mode=0666
#匿名用户能上传
anon_upload_enable=NO
#匿名用户能建目录
anon_mkdir_write_enable=NO
匿名用户其他写权利(更改权限?)
anon_other_write_enable=NO
如果设为YES匿名登入者会被允许下载可阅读档案默认值为YES
anon_world_readable_only=YES
#如果开启,那么所有非匿名登陆用户名都会被转换成guest_username指定用户名
#guest_enable=NO
所有匿名上传文件所属用户将会被更改成chown_username
chown_uploads=YES
匿名上传文件所属用户名
chown_username=lightwiter
#如果启动这项功能则所有列在chroot_list_file的中使用者不能更改根目录
chroot_list_enable=YES
#允许使用"async ABOR"命令,般不用,容易出问题
async_abor_enable=YES
管控是否可用ASCII 模式上传默认值为NO
ascii_upload_enable=YES
#管控是否可用ASCII 模式下载默认值为NO
ascii_download_enable=YES
#这个选项必须指定个空数据夹且所有登入者都不能有写入权限当vsftpd 不必file system 权限时就会将使用者限制在此数据夹中默认值为/usr/share/empty
secure_chroot_dir=/usr/share/empty


###################超时设置##################
#空闲连接超时
idle_session_timeout=600
#数据传输超时
data_connection_timeout=120
#PAVS请求超时
ACCEPT_TIMEOUT=60
#PROT模式连接超时
connect_timeout=60
################服务器功能选项###############
#开启日记功能
xferlog_enable=YES
#使用标准格式
xferlog_std_format=YES
#当xferlog_std_format关闭且本选项开启时,记录所有ftp请求和回复,当调试比较有用.
#log_ftp_protocol=NO
#允许使用pasv模式
pasv_enable=YES
#关闭安全检查,小心呀.
#pasv_promiscuous+NO
#允许使用port模式
#port_enable=YES
#关闭安全检查
#prot_promiscuous
#开启tcp_wrappers支持
tcp_wrappers=YES
#定义PAM 所使用名称预设为vsftpd
pam_service_name=vsftpd
#当服务器运行于最底层时使用用户名
nopriv_user=nobody
#使vsftpd在pasv命令回复时跳转到指定IP地址.(服务器联接跳转?)
pasv_address=(none)
#################服务器性能选项##############
#是否能使用ls -R命令以防止浪费大量服务器资源
#ls_recurse_enable=YES
#是否使用单进程模式
#one_process_model
#绑定到listen_port指定端口,既然都绑定了也就是每时都开着,就是那个什么standalone模式
listen=YES
#当使用者登入后使用ls -al 的类指令查询该档案管理权时预设会出现拥有者UID而不是该档案拥有者名称若是希望出现拥有者名称则将此功能开启
text_userdb_names=NO
#显示目录清单时是用本地时间还是GMT时间,能通过mdtm命令来达到相同效果
use_localtime=NO
#测试平台优化
#use_sendfile=YES
################信息类设置################
#login时显示欢迎信息.如果设置了banner_file则此设置无效
ftpd_banner=欢迎来到** FTP 网站WebSite.
#允许为目录设置显示信息,显示每个目录下面message_file文件内容
dirmessage_enable=YES
#显示会话状态信息,关!
#proctitle_enable=YES
############## 文件定义 ##################
#定义不能更改用户主目录文件
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list
#定义限制/允许用户登录文件
userlist_file=/etc/vsftpd/vsftpd.user_list
#定义登录信息文件位置
banner_file=/etc/vsftpd/banner
#禁止使用匿名用户登陆时作为密码电子邮件地址
banned_email_file=/etc/vsftpd.banned_emails
#日志文件位置
xferlog_file=/var/log/vsftpd.log
#目录信息文件
message_file=.message
############## 目录定义 #################
#定义用户设置文件目录
user_config_dir=/etc/vsftpd/userconf
#定义本地用户登陆根目录,注意定义根目录能是相对路径也能是绝对路径.相对路径是针对用户家目录来说.
local_root=webdisk #此项设置每个用户登陆后其根目录为/home/username/webdisk
#匿名用户登陆后根目录
anon_root=/var/ftp
#############用户连接选项#################
#可接受最大client数目
max_clients=100
#每个ip最大client数目
max_per_ip=5
#使用标准20端口来连接ftp
connect_from_port_20=YES
#绑定到某个IP,其他IP不能访问
listen_address=192.168.0.2
#绑定到某个端口
#listen_port=2121
#数据传输端口
#ftp_data_port=2020
#pasv连接模式时能使用port 范围上界0 表示任意默认值为0
pasv_max_port=0
#pasv连接模式时能使用port 范围下界0 表示任意默认值为0
pasv_min_port=0
##############数据传输选项#################
#匿名用户传输比率(b/s)
anon_max_rate=51200
#本地用户传输比率(b/s)


local_max_rate=5120000


附录:我自己设置vsftpd.conf

# Example config file /etc/vsftpd.conf
#
# The default compiled in tings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen _disibledevent=> #
# Allow anonymous FTP? (Beware - allowed by default you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# your users expect that (022 is used by most other ftpd's)
local_umask=011
#
# Uncomment this to allow the anonymous FTP user to upload files. This _disibledevent=> #
# Uncomment this you want the anonymous FTP user to be able to create
# directories.
anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go o a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a dferent user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes you like. The default is shown
# below.
#xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
#xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you _disibledevent=> #
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn _disibledevent=>


# Beware that _disibledevent=> #ascii_download_enable=YES
#
# You may fully customise the login banner :
#ftpd_banner=Welcome to blah FTP service.
#
# You may specy a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
chroot_local_user=YES
#
# You may specy an explicit list of local users to chroot to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot.
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O _disibledevent=> #
#
# Debian customization
#
# Some of vsftpd's tings don't fit the Debian filesystem layout by
# default. These tings are more Debian-friendly.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd
#
# This is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option species the location of the RSA certicate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
guest_enable=YES #允许虚拟用户
guest_username=ftp #把虚拟用户映射成本地用户
user_config_dir=/etc/vsftpd/vsftpd_user_conf #虚拟用户权限设置目录

设置文件范例如下文件名就是虚拟用户名字

local_root=/var/www #网站WebSite目录
anon_world_readable_only=NO
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
virtual_use_local_privs=YES
chmod_enable=YES
local_umask=011 #umask


6、启动服务
#/etc/init.d/vsftpd stop
#etc/init.d/mysql stop
#etc/init.d/mysql start
#etc/init.d/vsftpd start


Tags:  ubuntu安装lamp ubuntulamp ubuntuvsftpd安装 ubuntuvsftpd

延伸阅读

最新评论

发表评论