Linux 服务器上托管的文件需要哪些文件权限?
我有一个网络服务器并在其上安装了 WordPress。我想了解保护我的网站所需的文件权限。 (上次 XSS 发生在我的网站上时,他们在我的所有 index.php 文件和其他一些文件中写入内容。我不知道他们是如何做到这一点的。)
最佳文件权限是什么?
I have a web server and installed wordpress on it. I would like to know about the files permissions which are required to secure my site. (last time XSS happed on my site, they wrote inside my all index.php files and some other files. I don't know how they did this.)
What are the best file permissions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该脚本必须至少具有所有者读取和执行权限。这里脚本设置为755(只有脚本所有者拥有读、写和执行权限;其他用户和组只有读和执行权限)。
请注意,您将文件的所有者设置为 apache 用户(通常是 apache 或 www-data 或类似的用户)。
The script must at least have owner read and execute permission. Here the scripts are set to 755 (only the owner of the script has read, write, and execute privileges; other users and groups only have read and execute permissions).
Be aware that you set the owner of the files to the apache user (usually apache or www-data or something like that).
Web 服务器用户可读,任何人都不可写。当然,确切的细节取决于您正在做什么,但请从那里开始。如果可以的话,尽量留在那里。
Readable by the web server user, unwriteable by anyone. Of course, the exact details depend on what you're doing, but start there. And try to stay there if you can.
我认为将您链接到我认为在保护 Wordpress 时很方便的博客文章可能会更容易。它包含的内容超出了您感兴趣的内容,但仍然非常方便。
http://www.smashingmagazine.com/2010/ 07/01/10-useful-wordpress-security-tweaks/
3、5 和 7 您会感兴趣。
与您的配置文件直接相关,您可以使用 shell 命令来保护它,如下所示:
I think it's probably easier to link you to a blog post I find handy when securing Wordpress. It has more than what you are interested in but very handy nontheless.
http://www.smashingmagazine.com/2010/07/01/10-useful-wordpress-security-tweaks/
3, 5 and 7 will be of interest to you.
In direct relation to your config file, you could secure it using a shell command as follows:
如果您的环境允许,基本文件为 400,目录为 500。这意味着只读。
如果您想启用上传,则应为其设置适当的写入权限,600。
一些托管提供商在共享用户(例如“apache”)上运行其所有网站,但对于 FTP,则使用“youruser”。在这种情况下,文件需要 440,目录需要 550。
任何可写目录或文件都可能降低安装的安全性,但您必须平衡可用性和安全性。
If your environment allows it, 400 for basic files and 500 for directories. That means read-only.
If you want to enable uploading, you should put the appropriate write permissions on it, 600.
Some hosting providers run all their websites on a shared user, say 'apache', but with FTP uses 'youruser'. In that case, you'll need 440 for files and 550 for directories.
Any writeable directory or file could make your installation less secure, but you'll have to balance usability and security.
在 shell 中输入:
chown apache:apache filename
或
chown root:root filename ,
这取决于您的超级管理员用户名是什么
:
chmod 0755 filename
In shell type :
chown apache:apache filename
or
chown root:root filename ,
it depends what is your superadmin username
after :
chmod 0755 filename