[英]FTP transfer with resulting files visible to web server?
My task is to create a folder on a web server and upload a set of images to the new folder. 我的任务是在Web服务器上创建一个文件夹,并将一组图像上传到新文件夹。 The resulting images should then be visible to anyone with access to the web server.
然后,所有访问Web服务器的人都应该可以看到生成的图像。 The server is a dedicated Linux AWS instance.
该服务器是专用的Linux AWS实例。
I have the basic folder creation and file transfer working using C# and FtpWebRequest
. 我具有使用C#和
FtpWebRequest
进行基本文件夹创建和文件传输的功能。 The FTP server is set to have its local root at /var/www/job_folder
and folders and files are correctly created within that root folder. FTP服务器设置为具有
/var/www/job_folder
本地根目录,并且在该根目录文件夹中正确创建了文件夹和文件。 I have created a special user for the purpose of uploading files. 我已经创建了一个特殊的用户来上传文件。
The created folder and files, however, have minimal permissions. 但是,创建的文件夹和文件具有最小权限。 The newly created folder is
drwx-----
while the files within the folder are -rw------
. 新创建的文件夹为
drwx-----
而文件夹中的文件为-rw------
。 When I attempt to view these images in a web browser I receive 403 Forbidden
. 当我尝试在网络浏览器中查看这些图像时,收到
403 Forbidden
。
How can I change my program or alter my folder or user setup such that the folder and files I ftp to the server are immediately visible on the web? 如何更改程序或更改文件夹或用户设置,以使我ftp到服务器的文件夹和文件在网络上立即可见? I have unrestricted access to the server.
我可以不受限制地访问服务器。
You could set the SETGUID
bit on the containing directory and also set the directory's group to that of the web server - that way any files created in there will inherit the group of the web server rather than the group of the creator. 您可以在包含目录中设置
SETGUID
位,也可以将目录的组设置为Web服务器的组-这样,在其中创建的任何文件都将继承Web服务器的组而不是创建者的组。
I mean this: 我的意思是:
mkdir somedirectory # create that puppy
chgrp <apache's group> # set its group to that of apache
chmod g+s somedirectory # force all files subsequently created there to belong to apache's group
Alternatively, you could do a chmod
in FTP
after you PUT
the files: 或者,你可以做一个
chmod
在FTP
你以后PUT
文件:
ftp someserver
PUT freddyfrog # upload that puppy
CHMOD 666 freddyfrog # let everyone see it (and overwrite it - try 444 if overwriting not wanted)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.