在Web服务器上设置文件权限 [英] setting file permissions on a web server

查看:202
本文介绍了在Web服务器上设置文件权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是读到你需要如何设置某些文件权限(例如,对于

cgi文件),但我从来都不清楚*你是怎么做的

这个。我知道你可以运行这条线


chmod 755 scriptname.py


但是*你在哪里运行这个?这是在您的个人系统上完成的,还是在服务器上?
?如果您使用的是Windows,该怎么办?如果它是在服务器上完成的,

你是怎么做到的?


到目前为止我想出的唯一方法怎么做这是将我的cgi

文件上传到我的服务器,然后在我的FTP程序中我右键单击文件

并改变其权限号,但这似乎是一个低效

这样做的方式,特别是每次都要这样做。


有没有办法将上面的行放在脚本中,所以

脚本会自动设置其权限吗?或者做某些编辑

允许你以预定的权限保存文件?


除了我的右键点击方法,我不知道怎么回事要做到这一点。

解决方案

John Salerno:

我总是读到你需要如何设置某些文件权限(对于
cgi文件,例如),但我从来都不清楚*你是怎么做的这个。我知道你可以运行这条线

chmod 755 scriptname.py

但*你在哪里运行这个?


这是一个Unix / Linux命令。你在服务器上的shell登录中运行它

(例如在Putty,SecureCRT或你正在使用的其他ssh客户端)。

有没有办法将上面的行放在脚本中,这样脚本会自动设置它的权限吗?




当然不是通过cgi在脚本本身,因为它需要某些

权限才能作为cgi脚本运行。但是你可以将

命令放在安装cgi脚本的安装脚本中。


-
$ b $bRenéPijlman


>我总是读到你需要如何设置某些文件权限(例如

cgi文件),但我从来都不清楚*你是怎么做的。我知道你可以运行这条线

chmod 755 scriptname.py

但*你在哪里运行这个?这是在您的个人系统上,还是在服务器上完成的?如果您使用的是Windows,该怎么办?如果它是在服务器上完成的,
你是怎么做到的?

我到目前为止唯一想到的方法是上传我的cgi
文件到我的服务器,然后在我的FTP程序中我右键单击文件
并以这种方式更改其权限号,但这似乎是一种低效的方式,特别是必须每个都这样做时间。

是否有办法将上面的行放在脚本中,以便脚本自动设置其权限?或者某些编辑是否允许您使用预定的权限保存文件?

除了我的右键单击方法,我不知道该怎么做。




我想这将是一个很好的起点:

http://www.linuxcommand.org/man_pages/chmod1.html


简而言之,chmod指的是本地文件,所以无论你在哪里运行它都会

引用该机器上的文件。你可以通过在

shell中输入它作为有权执行操作的用户来运行它,

可能意味着你必须是文件的所有者但是如果你是root用户

无论如何都可以做到。根据您的ftp,scp,http或用于传输文件的任何

方法,文件权限可能会或可能不会在转移过程中发生变化。如果权限保持不变,您可以在本地计算机上使用
chmod,然后转移,如果不是那么,那么您需要先转发
并在服务器上转移chmod。当你从windows机器传输文件

到* nix它再次取决于你选择如何设置权限的特定

方法。

无法将此权限信息放入文件

本身,但可以设置一些(大多数?)编辑器以保存文件

你选择的许可。


希望这会有所帮助。


Daniel Nogradi写道:

简而言之,chmod指的是本地文件,所以无论你在哪里运行它都会引用该机器上的文件。你可以通过在一个
shell中输入它作为具有执行操作权限的用户来运行它,这可能意味着你必须是文件的所有者,但如果你是root用户那么
无论如何都可以做到。根据您的ftp,scp,http或用于传输文件的任何方法,文件权限在传输过程中可能会也可能不会发生变化。如果权限保持不变,您可以在本地计算机上进行chmod,然后进行传输,如果不是,那么首先在服务器上进行传输和chmod。当您将文件从Windows机器传输到* nix时,它又取决于您选择如何设置权限的特定方法。




谢谢,但我仍然有点困惑。因为我正在运行Windows,所以我认为我不能在自己的计算机上运行chmod线。我的网络服务器

使用Unix,但是我可以访问服务器的命令行

吗?我不知道基本的网络托管有可能

计划(我现在正在使用1and1)。


我想我可以写一个脚本,它将所有

的权限设置为我的计算机上特定文件夹中的文件到755,但是有一个

Windows等效命令,chmod可以这样做吗?或者我不得不在服务器端执行此操作?


I always read about how you need to set certain file permissions (for
cgi files, for example), but it''s never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this? Is this done on your personal system, or on
the server? What if you are using Windows? If it''s done on the server,
how do you do it?

The only way I''ve figured out so far how to do this is to upload my cgi
files to my server, then within my FTP program I right-click the file
and change its permission number that way, but that seems an inefficient
way to do it, especially having to do it each time.

Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically? Or do certain editors
allow you to save files with a predetermined permission?

Aside from my right-clicking method, I don''t know how else to do it.

解决方案

John Salerno:

I always read about how you need to set certain file permissions (for
cgi files, for example), but it''s never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this?
This is a Unix/Linux command. You run it in a shell login on the server
(e.g. in Putty, SecureCRT, or some other ssh client you''re using).
Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically?



Not in the script itself via cgi of course, because it needs certain
permissions before it can be run as cgi script. But you could put the
command in an installation script that installs the cgi script.

--
René Pijlman


> I always read about how you need to set certain file permissions (for

cgi files, for example), but it''s never been clear to me *how* you do
this. I know you can run the line

chmod 755 scriptname.py

but *where* do you run this? Is this done on your personal system, or on
the server? What if you are using Windows? If it''s done on the server,
how do you do it?

The only way I''ve figured out so far how to do this is to upload my cgi
files to my server, then within my FTP program I right-click the file
and change its permission number that way, but that seems an inefficient
way to do it, especially having to do it each time.

Is there a way to put the above line within the script perhaps, so that
the script sets its permission automatically? Or do certain editors
allow you to save files with a predetermined permission?

Aside from my right-clicking method, I don''t know how else to do it.



I guess this would be a good starting point:

http://www.linuxcommand.org/man_pages/chmod1.html

In short, chmod refers to local files so wherever you run it it will
refer to files on that machine. You run it simply by typing it in a
shell as a user who has privilage to perform the operatation, which
can mean you have to be an owner of the file but if you are root you
can do it in any case. Depending on your ftp, scp, http or whatever
method you use to transfer files the file permissions may or may not
change during the transfer. If permissions are kept intact you can
chmod on your local machine and then transfer, if they are not then
you transfer first and chmod on the server. When you transfer files
from a windows machine to *nix it again depends on the particular
method you choose how the permissions will be set.

There is no way of putting this permission information into the file
itself but some (most?) editors can be set to save the file with a
permission of your choice.

Hope this helps.


Daniel Nogradi wrote:

In short, chmod refers to local files so wherever you run it it will
refer to files on that machine. You run it simply by typing it in a
shell as a user who has privilage to perform the operatation, which
can mean you have to be an owner of the file but if you are root you
can do it in any case. Depending on your ftp, scp, http or whatever
method you use to transfer files the file permissions may or may not
change during the transfer. If permissions are kept intact you can
chmod on your local machine and then transfer, if they are not then
you transfer first and chmod on the server. When you transfer files
from a windows machine to *nix it again depends on the particular
method you choose how the permissions will be set.



Thanks, but I''m still a little confused. Since I''m running Windows, I
assume that I can''t run the chmod line on my own computer. My web server
uses Unix, but is it possible for me to have access to a command line
for the server? I didn''t know that was possible for basic web hosting
plans (I''m using 1and1 right now).

I suppose I could write a script that would set the permissions of all
the files in a particular folder on my computer to 755, but is there a
Windows equivalent command for chmod to do this? Or am I stuck having to
do it on the server side?


这篇关于在Web服务器上设置文件权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆