阿里云 CentOS7.2 配置FTP+Node.js环境
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云 CentOS7.2 配置FTP+Node.js环境相关的知识,希望对你有一定的参考价值。
本人小白,写下这篇博客意在记录踩过的坑,大神请绕道~
准备工作
安装自己喜欢的连接软件(一般是putty或者xshell),本人选择的是xshell,软件如图 :
通过软件中的ssh连接连接上已经购买的服务器,具体账号密码可在阿里云的控制台设置 。
在控制台选择主机系统为CentOS7.2,连接上了之后首先先将服务器更新至最新版本。
1 yum -y update
接着安装编译源代码的开发工具 。
1 yum -y groupinstall "Development Tools"
FTP的安装
1.安装vsftpd的服务器和客户端
1 sudo yum install ftp vsftpd
2.安装一个加密工具
1 sudo yum install libdb-utils.x86_64
【大坑提醒】
不知道是我的个人情况还是通病,在使用VIM时会报
-bash: vim: command not found.
但是VI命令使用正常,遇到这种情况一般是VIM相关组件没有安装完成,可以通过命令查看
1 # rpm -qa |grep vim
VIM命令可用时返回为
1 vim-minimal-7.0.109-6.el5 2 vim-common-7.0.109-7.2.el5 3 vim-enhanced-7.0.109-7.2.el5
以上三条缺一不可,如果有空缺可用代码重新安装
1 yum -y install vim*
VIM的使用
进入编辑模式 a
进入命令行模式 esc
直接退出 :q
保存退出 :wq
vsftpd的配置
创建vsftp的登录用户和主目录
1 sudo useradd -d /home/myftp -s /sbin/nologin myftp(myftp是ftp的登录用户,替换成你自己的用户)
进入修改相对应用户的密码
1 passwd myftp
创建出vsftpd虚拟用户
1 sudo touch /etc/vsftpd/vftpuser.txt
文件里为
1 用户1 2 用户1密码 3 用户2 4 用户2密码 5 ......
1 sudo db_load -T -t hash -f /etc/vsftpd/vftpuser.txt /etc/vsftpd/vftpuser.db
添加vsftpd的虚拟用户的验证
1 sudo vim /etc/pam.d/vsftpd
替换其中account和auth
1 session optional pam_keyinit.so force revoke 2 #auth required pam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed 3 #auth required pam_shells.so 4 #auth include password-auth 5 #account include password-auth 6 auth required pam_userdb.so db=/etc/vsftpd/vftpuser 7 account required pam_userdb.so db=/etc/vsftpd/vftpuser 8 session required pam_loginuid.so 9 session include password-auth
修改vsftpd的配置文件
1 sudo vim /etc/vsftpd/vsftpd.conf
以下为删除了注释的配置好的版本
1 # 是否运行匿名登录(NO) 2 anonymous_enable=NO 3 # 是否允许本地用户登录 4 local_enable=YES 5 # 允许ftp的任何写方式 6 write_enable=YES 7 # 文件创建只有的权限是755=(777-022) 8 local_umask=022 9 # 是否允许匿名用户上传文件 10 #anon_upload_enable=YES 11 # 是否允许匿名用户创建文件或者删除文件 12 #anon_mkdir_write_enable=YES 13 # 用户进入目录信息提示 14 dirmessage_enable=YES 15 # 是否允许vsftp的日志 16 xferlog_enable=YES 17 # Make sure PORT transfer connections originate from port 20 (ftp-data). 18 connect_from_port_20=YES 19 # 20 #chown_uploads=YES 21 #chown_username=whoever 22 # 日志文件的路径 23 xferlog_file=/var/log/xferlog 24 # 日志文件的格式 25 xferlog_std_format=YES 26 # 27 #idle_session_timeout=600 28 # 29 #data_connection_timeout=120 30 # 31 # It is recommended that you define on your system a unique user which the 32 # ftp server can use as a totally isolated and unprivileged user. 33 #nopriv_user=ftpsecure 34 # 35 # Enable this and the server will recognise asynchronous ABOR requests. Not 36 # recommended for security (the code is non-trivial). Not enabling it, 37 # however, may confuse older FTP clients. 38 #async_abor_enable=YES 39 # 40 # By default the server will pretend to allow ASCII mode but in fact ignore 41 # the request. Turn on the below options to have the server actually do ASCII 42 # mangling on files when in ASCII mode. 43 # Beware that on some FTP servers, ASCII support allows a denial of service 44 # attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd 45 # predicted this attack and has always been safe, reporting the size of the 46 # raw file. 47 # ASCII mangling is a horrible feature of the protocol. 48 #ascii_upload_enable=YES 49 #ascii_download_enable=YES 50 # 51 # You may fully customise the login banner string: 52 #ftpd_banner=Welcome to blah FTP service. 53 # 54 # You may specify a file of disallowed anonymous e-mail addresses. Apparently 55 # useful for combatting certain DoS attacks. 56 #deny_email_enable=YES 57 # (default follows) 58 #banned_email_file=/etc/vsftpd/banned_emails 59 # 60 # You may specify an explicit list of local users to chroot() to their home 61 # directory. If chroot_local_user is YES, then this list becomes a list of 62 # users to NOT chroot(). 63 # (Warning! chroot‘ing can be very dangerous. If using chroot, make sure that 64 # the user does not have write access to the top level directory within the 65 # chroot) 66 chroot_local_user=YES 67 chroot_list_enable=YES 68 # (default follows) 69 #chroot_list_file=/etc/vsftpd/chroot_list 70 # 71 # You may activate the "-R" option to the builtin ls. This is disabled by 72 # default to avoid remote users being able to cause excessive I/O on large 73 # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume 74 # the presence of the "-R" option, so there is a strong case for enabling it. 75 #ls_recurse_enable=YES 76 # 77 # When "listen" directive is enabled, vsftpd runs in standalone mode and 78 # listens on IPv4 sockets. This directive cannot be used in conjunction 79 # with the listen_ipv6 directive. 80 # 只监听ipv4的地址 81 listen=YES 82 # 83 # This directive enables listening on IPv6 sockets. By default, listening 84 # on the IPv6 "any" address (::) will accept connections from both IPv6 85 # and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6 86 # sockets. If you want that (perhaps because you want to listen on specific 87 # addresses) then you must run two copies of vsftpd with two configuration 88 # files. 89 # Make sure, that one of the listen options is commented !! 90 #listen_ipv6=YES 91 92 pam_service_name=vsftpd 93 userlist_enable=YES 94 tcp_wrappers=YES 95 # 下面是自己添加的 96 anon_root=/home/pageftp/open 97 virtual_use_local_privs=YES 98 guest_enable=YES 99 guest_username=pageftp 100 # 虚拟用户的配置文件(可以对每一个虚拟用户进行单独的权限配置) 101 user_config_dir=/etc/vsftpd/vconf/ 102 chroot_local_user=YES 103 allow_writeable_chroot=YES
配置虚拟用户的权限
1 sudo mkdir /etc/vsftpd/vconf/ 2 touch 用户1 用户2 …… 3 vim 用户1
配置结果如下
1 cmds_allowed=ABOR,ACCT,APPE,CWD,CDUP,DELE,HELP,LIST,MODE,MDTM,MKD,NOOP,NLST,PASS,PASV,PORT,PWD,QUIT,REIN,RETR,RMD,RNFR,RNTO,SITE,SIZE 2 ,STOR,STAT,STOU,STRU,SYST,TYPE,USER 3 write_enable=yes 4 download_enable=yes 5 anon_upload_enable=yes 6 anon_mkdir_write_enable=yes 7 anon_other_write_enable=yes 8 anon_world_readable_only=no
最后启动vsftpd服务
1 sudo systemctl enable vsftpd 2 sudo service vsftpd start
使用刚设置的用户名和密码通过FTP连接观察,本人选用软件FlashFXP。
配置参考地址:http://blog.csdn.net/m47838704/article/details/51636379
Node.js环境安装
使用最新源码安装,资源从Node.js网站获取,地址为http://nodejs.org/download
1 wget http://nodejs.org/dist/v6.5.0/node-v6.5.0.tar.gz (版本号可根据实际需求自行替换)
解压源文件并进入相应文件夹
1 tar zxf node-v6.5.0.tar.gz 2 cd node-v6.5.0
执行编译预处理
1 ./configure
编译源代码
1 make
放置至系统路径
1 make install
成功安装
以上是关于阿里云 CentOS7.2 配置FTP+Node.js环境的主要内容,如果未能解决你的问题,请参考以下文章
转自 阿里云技术文档的 centos + PHP 环境 搭建
服务器部署前端&node 项目(包括阿里云服务器nginx 以及 mongoDB 的配置)