vsftpd 安裝
這里有最簡潔的安裝步驟
理想流程
[root@itdragon ~]# useradd ftpuser
[root@itdragon ~]# passwd ftpuser
Changing password for user ftpuser.
New password:
BAD PASSWORD: it is too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@itdragon ~]# yum -y install vsftpd
[root@itdragon ~]# ifconfig
第一步:添加ftp用戶
第二步:設置ftp用戶密碼
第三步:安裝vsftpd
第四步:查看ip地址
第五步:本地使用免費的FileZilla 鏈接虛擬機
遇到的問題
連接失敗
狀態: 正在等待重試...
狀態: 正在連接 192.168.0.11:21...
錯誤: 20 秒后無活動,連接超時
錯誤: 無法連接到服務器
不用灰心,安裝本來就不是順風順水的,每個人會根據自己的環境出現不同的問題。下面是我的解決方法
首先,要確定兩邊能 pind 通,虛擬機選擇的是橋接模式,能正常 ping 通。
然后,百度
網上有很多五花八門的解決方法,主要是針對三個方面的
這里我會貼出幾個網址,因為我按照網站上面的做法沒有連接成功,最后是關閉了防火牆才解決的。我對這塊比較薄弱,就不誤人子弟了。貼出來是為了以后方便以后修改。
第一個操作是關閉匿名,開啟被動模式
第二個操作是開啟防火牆的21端口
第三個操作是修改selinux,開啟外網可訪問
[root@itdragon ~]# vim /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
pasv_min_port=30000
pasv_max_port=31000
[root@itdragon ~]# service vsftpd restart
[root@itdragon ~]# vim /etc/sysconfig/iptables
-A INPUT -p tcp -m multiport --dport 20,21 -m state --state NEW -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp --dport 30000:31000 -j ACCEPT
[root@itdragon ~]# service iptables restart
[root@itdragon ~]# getsebool -a | grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_fusefs --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off
tftp_use_cifs --> off
tftp_use_nfs --> off
[root@itdragon ~]# setsebool -P allow_ftpd_full_access on
[root@itdragon ~]# setsebool -P ftp_home_dir on
參考博客:
http://blog.csdn.net/jiftlixu/article/details/54344050
https://jingyan.baidu.com/article/ea24bc3984a3b2da63b33154.html
遺憾的是,我按照上面的方法,沒有連接成功,最后一刀切,直接關閉了防火牆。
臨時關閉防火牆不過癮,直接永久關閉防火牆
[root@itdragon modprobe.d]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@itdragon modprobe.d]# chkconfig iptables off
上傳失敗
在nginx 安裝目錄下創建了一個images文件夾,通過FileZilla上傳圖片提示錯誤
響應:553 Could not create file.
錯誤: 嚴重文件傳輸錯誤
解決方法如下
[root@itdragon html]# mkdir images
[root@itdragon html]# chmod -R 777 images
[root@itdragon html]# ll
total 12
-rw-r--r--. 1 root root 537 Nov 18 10:53 50x.html
drwxrwxrwx. 2 root root 4096 Nov 18 10:55 images
-rw-r--r--. 1 root root 612 Nov 18 10:53 index.html
[root@itdragon html]# vim /etc/vsftpd/vsftpd.conf
local_root=/var/ftp
[root@itdragon html]# service vsftpd restart
參考博客:http://blog.chinaunix.net/uid-20680669-id-3142726.html
注意點
- 網絡要能ping通
- 防火牆的問題要處理好
- 不能創建文件問題
最后,感謝大家閱讀。有什么建議請賜教!!!
Nginx服務器 和 FTP服務器 都准備好了,下一章就是用Nginx+FTP搭建圖片服務器,實現圖片的上傳和批量上傳。
