1. 程式人生 > 其它 >ubuntu nginx ftp 配置圖片伺服器

ubuntu nginx ftp 配置圖片伺服器

1. nginx的安裝

apt-get install nginx

2. 檢視nginx的執行狀態

3. nginx的配置

server {
listen 81;
server_name localhost;//配置對映名稱
location /img/ {
alias /home/test/;
#root /home/test/;
autoindex on;//開啟索引
}
}
alias 表示 /img/對映到test

root是直接定位到tes

4. ftp 安裝與配置

apt-get install vsftpd

修改或者新增重要配置

anonymous_enable=YES
anon_root=/home/hett/share//匿名訪問的目錄
no_anon_password=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
userlist_file=/etc/vsftpd.user_list//建立的使用者列表
userlist_enable=YES
userlist_deny=NO
local_root=/home/hett/share //ftp的主目錄

# 使用者白名單

chroot_local_user=YES

chroot_list_file=/etc/vsftpd.chroot_list

5. 新增ftp使用者

sudo useradd -d /home/hett/share -m hettftp
sudo passwd hettftp

nano /etc/vsftpd.user_list/

6.重啟ftp和nginx

7. 訪問

在這個過程中遇到了403的問題,首先排查使用者

使用者是否對檔案有訪問的許可權。

其次,設定ftp中的目錄訪問許可權。一定要注意是每個都設定遞迴。且是755不是777

chmod -R 755 /home/
chmod -R 755 /home/hett/
chmod -R 755 /home/hett/share/

最後,注意 root與alias區別