解决wordpress不能上传图片的权限限制问题,亲测有效
正 文:
当你的wordpress遇到以下问题时: |
1、不能上传图片
2、不能自动安装主题、插件(需要FTP账户)
3、不能自动更新
4、其它任何需要wordpress写文件的问题
这些问题基本都是一个原因, 你的wordpress目录不属于当前的用户和组, 即web访问的用户没有权限操作wp的一切需要写权限的操作。 解决方法 :
首先需要你有root权限,SSH登录,进入到wp的安装目录:
cd /var/www/html/my_wp_blog
给予所有的写权限:
chmod 777 wp-content
接下来给你的博客的文章上传一张图片,WP会生成一个目录, 然后查看是哪个用户创建了文件夹。一般情况下,这个用户名叫“ apache”,也有不少人发现这个用户是“nobody”,就 飘易 本身遇到的问题,我在VPS上安装的是LNmp, 这个用户是“www”。
进入到wp的wp-content目录,查看该目录下所有文件/ 文件夹的权限,所属用户、用户组:
cd wp-content
ls -l
total 16
-rw-r–r– 1 root root 30 May 4 2007 index.php
drwxr-xr-x 3 root root 4096 Feb 10 19:31 plugins
drwxr-xr-x 5 root root 4096 Mar 23 03:04 themes
drwxrwxrwx 3 www www 4096 Mar 24 02:08 uploads
注意上传目录 uploads 是用户 www 创建的。
接下来把wp-content权限还原到 755::
cd ..
chmod 755 wp-content
下来就是实际修复的命令了, 改变wp所在文件夹的拥有者为刚找到的这个用户www:
cd ..
chown -R www:www my_wp_blog OK,问题解决了。下面是英文的原文: There are a wide variety of problem reports appearing on support forums related to Wordpress that all have one root cause and solution. Here are some common issue descriptions:
* Problems uploading images
* Problems installing themes, plugins
* Problems auto-upgrading Wordpress
* Anything else where Wordpress needs to write files
And here is a typical error message:
“To perform the requested action, connection information is required.” Or…
“Unable to create directory [. ..]. Is its parent directory writable by the server?” The problem is that Wordpress is executing in the context of your web server process, but the directories have write permissions based on the user context used to originally create the directories. Many of the suggested solutions on the web simply won’t work, while other solutions work but create security problems with your Wordpress installation. Here is the full solution that should work on all Linux systems, regardless of the specific environment. What we are going to do is give your web server ownership of the directories and files of your Wordpress install. This requires you to be knowledgeable and comfortable in your bash shell environment, which is probably reasonably true if you installed Wordpress yourself. First we will give everybody write access so that WP can write the content directories. Some solutions on the web stop at this step, but this leaves your files with no filesystem security. We are only doing this briefly in order to determine what user context is being used by the web server. Go to your Wordpress root directory:
# cd /var/www/html/my_wp_blog Give the world write access to the content directory:
# chmod 777 wp-content
Now log into Wordpress and upload a photo to a blog post, causing WP to create the new directories required. Then look on the server to see what user created the directories. This would commonly be apache, but also many people are reporting that this is the user “nobody” on their server. # cd wp-content
# ls -l
total 16
-rw-r–r– 1 root root 30 May 4 2007 index.php
drwxr-xr-x 3 root root 4096 Feb 10 19:31 plugins
drwxr-xr-x 5 root root 4096 Mar 23 03:04 themes
drwxrwxrwx 3 apache apache 4096 Mar 24 02:08 uploads
Notice that the uploads directory was created by user apache:apache. This is the information you needed. Go back down one dir level and set the permissions back to a secure level. # cd ..
# chmod 755 wp-content
Now for the actual fix. Recursively set the owner and group for your Wordpress installation to the user that created the uploads directory. # cd ..
# chown -R apache:apache my_wp_blog
You’re done. Wordpress now has access to the file system for photo and attachment uploads, automatic upgrades, and anything else needed by your plugins.
解决wordpress不能上传图片的权限限制问题,亲测有效相关推荐
- 解决pom文件第一行报错(unknown)-亲测有效
原文链接:https://blog.csdn.net/u010947534/article/details/93743582 问题: Eclipse导入maven项目时,或者新建一个springboo ...
- VMware中解决ubuntu不能连接网络问题。(亲测有效)
VMware中解决ubuntu不能连接网络问题.(亲测有效) 参考文章: (1)VMware中解决ubuntu不能连接网络问题.(亲测有效) (2)https://www.cnblogs.com/te ...
- 解决克隆虚拟机后无法上网问题(亲测有效)
解决克隆虚拟机后无法上网问题 克隆虚拟机后,所有的虚拟机都无法上网. 输入ifconfig命令,显示没有ip地址. 在网上找到的很多方法,大多是重新生成MAC,设置ip配置文件等. 重新打开网络服务多 ...
- Linux安装svn服务器和权限配置_亲测成功
Linux安装svn服务器和权限配置_亲测成功 SVN简介 SVN是Subversion的简称,是一个开放源代码的版本控制系统,通过采用分支管理系统的高效管理,简而言之就是用于多个人共同开发同一个项目 ...
- LAMP+WordPress部署(yum) 配置简单 轻松上手 亲测有效
目录 了解: 一)LAMP介绍 二)源码包和yum安装优劣 环境: 实现: 1.Mariadb 2.PHP 3.Apache 5.Wordpress发布业务 7.启动测试 报错集合: 了解: 一)LA ...
- 解决win2019安装.net3.5的问题,亲测可行(未成功启用报错,找不到源文件报错,统统解决。。)
先卖个关子 1.添加角色里面勾选 .net3.5 安装失败 2.各种百度找到的方法,下载NetFx3.cab,然后用命令安装,失败告终 (失败原因,未成功启动,然后又是未找到源文件) 搞的我各种头疼, ...
- 完美解决c# 连接oracle US7ASCII字符中文乱码 亲测
客户端:win10 64位 vs2017,服务器端linux oracle US7ASCII字符. 因单位数据编码不能改变,故测试了很多办法,真是找了很多解决,最终找到了比较可以的一个. 1.下载do ...
- MAC地址修改方法(解决teamviewer访问超时限制的问题)亲测可用(文后有惊喜)
个人笔记本windows8.1的系统(windows10应该也可以)各种操作,不能成功.最后通过注册表修改后成功的. (我笔记本一直连的是无线,现在看来不是无线和有线的问题) 解决teamviewer ...
- 解决win10系统CPU占用过高【亲测非常有效】
win10 系统的到来,让用户体验到了更好的视觉效果和完善的服务,但是鱼和熊掌不可兼得,这些良好的优点同时也带给电脑更多的负荷,CPU各种100%烫的要命,风扇呼呼的吹.所以我们不得不对win10进行 ...
最新文章
- python pandas 读写 csv 文件
- UA MATH567 高维统计III 随机矩阵4 欧氏空间上的集网与覆盖
- deepin--解决屏幕撕裂问题
- python中的for循环
- 【转】微服务实践(五):微服务的事件驱动数据管理
- mq多个消费者消费一个消息_一个普通消费者的米家产品使用感受
- S4 extension field的异步创建和后台作业
- [LeetCode]Distinct Subsequences,解题报告
- 异步复位设计中的亚稳态问题及其解决方案
- jni java c 变量对应_GitHub - jkangzhang/JNIDemo: JNI中Java和C的数据传递
- 【代码备份】ORACLE数据库表同步DBLINK
- 开源分布式数据库 TiKV 入选 CNCF 云原生项目!
- 发展大数据还有啥问题:数据孤岛、技术差距、人才短缺
- STM32H743IIT6+USB3300,USB_HS高速双向HID通讯开发
- css3实现奔跑的小人动画
- 共享文件夹没有权限访问
- 解决MAC上网速度慢的原因
- 64位 window 在notepad++中添加HexEditor工具
- 如何计算IT投资回报(ROI)
- R语言编写自定义函数计算分类模型评估指标:准确度、特异度、敏感度、PPV、NPV、数据数据为模型预测后的混淆矩阵、比较多个分类模型分类性能(逻辑回归、决策树、随机森林、支持向量机)