WordPress:Changing File Permissions

来自站长百科
跳转至: 导航、​ 搜索

在电脑文件系统中,不同的文件和不同的目录有权限规定谁和什么东西可以编辑和阅读它们。这很重要因为WordPress也许需要有权限在你的wp-content上写文件以确保一些特别的功能。

下面是一个可能的权限方案。 所有的文件应该由你的用户账户拥有,而且可以由你写。任何需要来自WordPress写权限的文件,应该由网络服务器使用的用户账户集体拥有。

  • 根WordPress目录:所有的文件只有你的用户账户才可以使用。
    • .htaccess 之外,如果你想WordPress为你自动产生重写功能
  • /wp-admin/-WordPress 管理区域:所有的文件只有你的用户账户才可以写。
  • /wp-includes/ - WordPress应用逻辑的大部分:所有的文件只有你的用户账户才可以写。
  • /wp-images/ - WordPress 使用的图像文件:所有的文件只有你的用户账户才可以使用。
    • /wp-content/themes/ - 主题文件。如果你想使用内置的主题编辑器,所有的文件需要集合起来而且是可写的。如果你不想使用内置的编辑器,所有的文件只有你的用户账户才可以写。
    • /wp-content/plugins/ - 插件文件:所有的文件只有你的用户账户才可以使用。
    • /wp-content/下面的其它目录应该由任何需要它们的插件/主题记录。权限会有不同。
    • The WordPress数据库文件备份插件需要/wp-content/ 文件夹可写。在有些情况下,这可能需要上交755个权限或者更多,(例如有些主机上777个权限)。

在这个论坛 thread上也可以看看这方面的讨论.


使用一个FTP帐户

FTP程序(“客户端”)允许你为你的远程主机上的文件和目录设置权限. 这个功能通常称为chmod或者在程序菜单上设定权限. 在一个WordPress安装上,你也许想改变的两个文件是索引页和控制布局的css.下面是你怎样改变index.php-这个过程对于任何文件来说,都是相同的.In 在下面的屏幕截图中,看一下最后的一栏-那显示了权限.它看起来有些混乱,但现在仅仅看看字母的序列.
[[WordPress:Image:podz_filezilla_12.gif|center|thumb|400px|最初的权限] 点击”index.php”并且选择”文件权限”
一个屏幕会跳出来. [[WordPress:Image:podz_filezilla_13.gif|center|thumb|305px|改变文件权限]

不用担心选框.只要删除”数值”:输入你需要的数字-这个例子中是666.然后点击OK.
[[WordPress:Image:podz_filezilla_14.gif|center|thumb|400px|权限已经被更改了.] 现在你可以看到文件的权限已经被更改了.

打开隐藏文件

在默认情况下,大多的FTP客户端,包括FileZilla, 保存有隐藏的文件,这些文件从开始展示时,便以一个标点符号(.)开始.但是,在有些情况下,你可能要看看你的隐藏的文件,这样你就可以在那个文件上更改一下权限.比如,你可能要使你的.htaccess文件,控制permalinks的文件,可写.

在FileZilla上展示隐藏的文件,从顶层目录上选择”查看”,然后选择”显示隐藏文件”是必要的.展示文件的界面会刷新,任何以前隐藏的文件都会展现在你的面前 让FileZilla总是显示隐藏文件,-在编辑,设置,远程文件列表,选中总是显示隐藏文件框.

Using the Command Line

If you have shell/SSH access to your hosting account, you can use chmod to change file permissions. Before you start using chmod it would be recommended to read some tutorial like this and also the manual page to make sure you understand better what you can make with it.

You can make all the files in your wp-content directory writable in two steps:

  1. Go to your WordPress main directory, with a command like cd wordpress/
  2. Enter chmod -R 777 wp-content

What does this mean? chmod is a unix command that means "change mode" on a file. The -R flag means to apply the change to every file and directory inside of wp-content. 777 is the mode we are changing the directory to, it means that the directory is readable and writable by WordPress. Finally, we have the name of the directory we are going to modify, wp-content.


If you use Permalinks you should also change permissions of .htaccess to make sure that WordPress can update it when you change settings or add some new Page (which requires update of the file to work when Permalinks are enabled).

  1. Go to the main directory of WordPress
  2. Enter chmod 666 .htaccess

Note that Filezilla is a very good FTP client. You can download it from download.com


See also

WordPress:htaccess for subdirectories