php WordPress 本地主机 ftp
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13120226/
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
Wordpress localhost ftp
提问by Can Rau
I have wordpress running on my localhost on mac Lion.
我在 mac Lion 上的本地主机上运行 wordpress。
Everytime I try to install or delete plugins it asks me for hostname, ftp username and ftp password.
每次我尝试安装或删除插件时,它都会要求我输入主机名、ftp 用户名和 ftp 密码。
I configured my localhost to 127.0.0.1, but I have never configured the ftp username and password for my localhost. How can I get which user and password it's by default?
我将我的 localhost 配置为 127.0.0.1,但是我从来没有为我的 localhost 配置过 ftp 用户名和密码。如何获取默认情况下的用户和密码?
I have tried almost every user and pass I have on mysql, my osx admin, etc. with no results.
我已经尝试了几乎所有用户,并通过了 mysql、我的 osx 管理员等,但没有结果。
Any ideas?
有任何想法吗?
采纳答案by Matt Gibson
In my experience, WordPress can be a bit fussy about permissions and ownership when it comes to self-update without FTP, so using FTP to localhost is a perfectly valid tactic, I'd say. But as others have said, just ensuring that everything from your WordPress root directory on downwards is writable by the PHP process, and owned by the same user, may well be enough to avoid the need for FTP.
根据我的经验,在没有 FTP 的情况下进行自我更新时,WordPress 可能对权限和所有权有点挑剔,所以我会说,使用 FTP 到 localhost 是一种非常有效的策略。但正如其他人所说,只要确保从 WordPress 根目录向下的所有内容都可以由 PHP 进程写入,并由同一用户拥有,就足以避免对 FTP 的需求。
If you do want to use FTP, are you sure you've enabled the FTP server? If so, you should just use a user who has permission to get to the directory via FTP (you can test with the command-line ftp tool.) As my sites are set up in my personal Sitesdirectory, I just use my normal username and password (e.g. for /Users/matt/Sites/whateverI log in as matt.)
如果您确实想使用 FTP,您确定您已启用 FTP 服务器吗?如果是这样,您应该只使用有权通过 FTP 访问该目录的用户(您可以使用命令行 ftp 工具进行测试。)由于我的站点是在我的个人Sites目录中设置的,所以我只使用我的普通用户名和密码(例如,/Users/matt/Sites/whatever我以matt.身份登录)
Other things to check: What happens if you try ftp localhoston the command line? Can you log in there?
其他需要检查的事项:如果您尝试ftp localhost使用命令行会发生什么?你能在那里登录吗?
回答by Can Rau
Updateas mentioned by Chaudhry Waqas in comments it might be sufficient to just add define('FS_METHOD', 'direct');to wp-config.php, so please try this first as it's safer not to change access rights if not necessary
更新由乔杜里Waqas在评论中提到它可能足以只需添加define('FS_METHOD', 'direct');到wp-config.php,所以请首先尝试这是它的安全不改变访问权限,如果没有必要的
WARNING:only do this on your local computer, it's a huge security risk on a public installation!
I haven't tried it but as mentioned by @misterfancypants comment, changing those settings only for
wp-content/plugins/should be sufficient
updatedto incorporate this info
警告:只能在您的本地计算机上执行此操作,这对公共安装存在巨大的安全风险!
我还没有尝试过,但正如@misterfancypants 评论所述,仅更改这些设置
wp-content/plugins/应该足以
更新以包含此信息
This one worked for me
这个对我有用
$ cd /Users/<username>/Sites
# (wordpress = name of the directory, change as needed)
$ sudo chown -R :_www wordpress
$ sudo chmod -R g+w wordpress
and then add following in wp-config.php
然后在 wp-config.php 中添加以下内容
define('FS_METHOD', 'direct');
found on http://soderlind.no/running-wordpress-locally-on-mac-os-x-lion/#crayon-533a956214a8e343167867
在http://soderlind.no/running-wordpress-locally-on-mac-os-x-lion/#crayon-533a956214a8e343167867 上找到
Cheers Can
干杯罐头
回答by kuldipem
I fixed it by:
我通过以下方式修复它:
cd /var/www
sudo chown -R www-data:www-data wordpress
Updated on 03-05-2019
更新于 03-05-2019
cd /var/www
sudo chown -R www-data:www-data [YOUR_WORDPRESS_PROJECT_DIR]
回答by Thamaraiselvam
Actually, problem is that WordPress create a temp file to check the file permissions
实际上,问题是 WordPress 创建了一个临时文件来检查文件权限
and it comparethat temp file's ownerwith its a core file's owner(refer fileowner()) both should match. in most of the case, it does not match on localhosthence we extracted wp files in different user access and PHP has its own user group.
它比较的是临时文件的所有者与它的一个核心文件的所有者(参见fileowner() ) 都应该匹配。在大多数情况下,它与本地主机不匹配,因此我们以不同的用户访问权限提取 wp 文件,并且 PHP 有自己的用户组。
So there are 2 ways to solve this problem.
所以有2种方法可以解决这个问题。
Way 1:
方式一:
cd wordpress
sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
and following
和以下
define( 'FS_METHOD', 'direct' );
in wp-config.php
在 wp-config.php
This does not check any fileownersjust uses the direct file system
这不检查任何文件所有者只是使用直接文件系统
way 2
方式二
set
放
sudo chown -R www-data:www-data wordpress
sudo chown -R www-data:www-data wordpress
This sets the both WordPress into www-datause so actually the temp file(which created by WordPress) also comes inside this user, So both fileowners is same so problem solves
这将两个 WordPress 都设置为www-data使用,因此实际上临时文件(由 WordPress 创建)也进入该用户内部,因此两个文件所有者都是相同的,因此问题解决了
More info refer : https://developer.wordpress.org/reference/functions/get_filesystem_method/
更多信息参考:https: //developer.wordpress.org/reference/functions/get_filesystem_method/
回答by Vinod VT
Add this in your config.phpfile,
将此添加到您的config.php文件中,
define('FS_METHOD','direct');

