php Codeigniter - 设置目录和文件权限(chmod 设置)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17628180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:12:02  来源:igfitidea点击:

Codeigniter - setting up directories and files permissions (chmod settings)

phpcodeigniterpermissionschmod

提问by itsme

Since i don't think i got right permissions all over my application folders and files is there anyway to check the right permissions allover them?

因为我认为我没有在我的应用程序文件夹和文件中获得正确的权限,所以无论如何要检查它们的正确权限吗?

I mean, does anyone knows/has a standard/tutorial/link to follow for Codeigniter to set chmodpermissions?

我的意思是,有没有人知道/有一个标准/教程/链接可以遵循 Codeigniter 来设置chmod权限?

thanks, any help appriaciated!

谢谢,任何帮助appriaciated!

NB: when i say allover i mean from the root to all files the application & system folders contains

注意:当我说 allover 时,我的意思是从根目录到应用程序和系统文件夹包含的所有文件

Also to specify little bit, i think i got problems with permissions, cause i passed my application through different OS and for example macosx setted different permissions on directories than windows etc... so it's sort of a hell actually

还要说明一点,我想我在权限方面遇到了问题,因为我通过不同的操作系统传递了我的应用程序,例如 macosx 在目录上设置了与 windows 等不同的权限......所以实际上它有点像地狱

This is my app schema:

这是我的应用程序架构:

/project
   /application
   /system
   /css
   /img
   /vendor
   index.php
   .htaccess

回答by Tim Post's Sock Ape

You want to:

你想要:

chmod -R 0644 application system index.php

Assuming that CI is installed in the web root, with the application/and system/directories residing therein, which is the default setup.

假设 CI 安装在 Web 根目录中,其中application/system/目录驻留在其中,这是默认设置。

What I typically do is put the application/and system/directories outsideof the web root when I use Codeigniter, at which point you need to edit your index.phpfile to reflect that:

当我使用 Codeigniter 时,我通常做的是将application/system/目录放在网络根目录之外,此时您需要编辑index.php文件以反映:

$system_path = '../system';
$application_folder = '../application';

Note, you'd be adding the ../(and also need to move those directories one level down) but I digress. The permissions for each directoryshould be 0755 and for each .phpfile 0644, wherever you end up putting them. This includes any vendor, 3rdparty, sparks, etc, and any custom asset locations.

请注意,您将添加../(并且还需要将这些目录向下移动一级),但我离题了。每个目录的权限应该是 0755,每个.php文件的权限应该是0644,无论你最终把它们放在哪里。这包括任何供应商、3rdparty、sparks 等,以及任何自定义资产位置。

If using a templating engine of some sort, goodsetups will work with 0755 folder permissions at the location where the engine writes its output and intermediate output if applicable. If you find that breaking, find a host that supports suexec so that you don't have to make those locations 777 (or world writeable).

如果使用某种模板引擎,良好的设置将在引擎写入其输出和中间输出(如果适用)的位置使用 0755 文件夹权限。如果您发现这有问题,请找到支持 suexec 的主机,这样您就不必将这些位置设置为 777(或全局可写)。

This is most easily done using a terminal (SSH), but should also be easily possible with whatever file manager thingadongdong your host provides.

使用终端 (SSH) 最容易做到这一点,但也应该可以使用主机提供的任何文件管理器 thingadongdong 轻松实现。

回答by Reyhaneh Trb

change the permission of your codeigniter folder with this command:

使用以下命令更改 codeigniter 文件夹的权限:

$ sudo chmod -R 755 /var/www/html/Codeigniter_folder_name