Q:Wordpress或WooCommerce上传图片问题

wordpress安装成功,但上传图片时候收到类似这样的提示:

The server cannot process the image. This can happen if the server is busy or does not have enough resources to complete the task. Uploading a smaller image may help. Suggested maximum size is 2560 pixels.
Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page.

很多种原因都可能造成这个故障。下面一个一个设置进行排查:

  • 准备上传的文件是read-only可能会造成文件上传问题
    目标文件图标点击右键/properties/Permissions进行查看,解决方法:鼠标右键或 terminal里用chmod扩展其permission

  • wordpress文件夹系统权限不足
    比如你的网站公网IP是123.45.16.666
    那么在http://123.45.16.666/wp-admin/site-health.php?tab=debug 网页 或者 点击wordpress左侧工具栏Tools/Site Health
    然后查看 Info/Filesystem Permissions

理想上的设置应该是

Shows whether WordPress is able to write to the directories it needs access to
The main WordPress directoryWritable
The wp-content directoryWritable
The uploads directoryWritable
The plugins directoryWritable
The themes directoryWritable

如果发现你的设置是not writable之类的,需要将其变成Writable。

开启方法:

进入ECS terminal 相关文件夹
cd /usr/share/nginx/html/wordpress

用指令ls -al查看权限

(下面FTP服务创建的Linux用户名是wpadmin,详见阿里云ECS建站如何安装FTP 操作者需根据自己系统带入替换)
文件上传不顺利,权限收紧的配置很可能类似下面这样
drwxr-xr-x 5 wpadmin wpadmin 67 Jan 5 17:24 wp-content
扩展了权限,那么会显示类似这样
drwxrwxrwx 5 wpdmin wpadmin 67 Jan 5 17:24 wp-content

解决方法:直接在阿里云ECS的terminal里修改wordpress文件夹的访问权限
注意!!! 不要在ftp terminal里面修改文件夹权限,有可能会虚假修改成功

cd /usr/share/nginx/html/wordpress

chmod -R 777 wp-content
也可使用chmod -R 755 wp-content会更加安全,但有可能解决不了本例的wordpress读写权限问题

重启nginx
systemctl restart nginx

个别情况下,你可能需要在阿里云面板重启ECS才能让你的配置完全更新。

Q:wordpressFTP链接和创建文件夹失败的解决方法:

cd /usr/share/nginx/html/wordpress
nano wp-config.php

#进入编辑模式,光标移到到文件末尾 在文件最后添加如下三句代码
define("FS_METHOD", "direct");
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);

Q:需要上传大于2M的文件,如何设置
(下面的方法都可一试,注意注意注意设置后一定重启ECS实例,否则配置不会更新!!!)

    • 编辑php.ini文件,
搜索:memory_limit、post_max_size、upload_max_filesize、max_execution_time、max_input_time

调整后为:

memory_limit=128M
post_max_size=12M
upload_max_filesize=10M//这样就改为可以传10M以下的文件了
max_execution_time=60
max_input_time=60



来源:https://www.zhihu.com/question/525046064/answer/2530224338

也可以试试下面AB两种方法:

    • A:打开
      nano /etc/nginx/nginx.conf
      在最后加一句
      client_max_body_size 100m;
    • B:WordPress安装目录下的wp-config-sample.php文件复制一份,起名叫做wp-config.php文件,并将原来的wp-config-sample.php文件作为备份。

cd /usr/share/nginx/html/wordpress

  • 编辑wp-config.php文件。
    nano wp-config.php

下面这句话粘贴进去
define(‘WP_MEMORY_LIMIT’, ‘256M’);

Q: Linux系统内对应的网络进程不存在。

解决方法: ECS terminal里面直接
systemctl restart NetworkManager

参考
https://help.aliyun.com/zh/ecs/the-linux-network-process-does-not-exist

Q: /boot/grub2/grub.cfg链接文件丢失
解决方法: ECS terminal里面直接
grub2-mkconfig -o /boot/grub2/grub.cfg

参考资料
https://blog.csdn.net/qq_26129413/article/details/120136942

Q:wordpress上传但不能正确显示图片

A: 在网址根目录下的找到wp-config.php文件,然后在require_once(ABSPATH.‘wp-settings.php’);之前添加上下面这句代码:
define(“CONCATENATE_SCRIPTS”,false);

Centos系统那么这个文件位置在:
nano /usr/share/nginx/html/wordpress/wp-config.php

WordPress官方针对这个问题的回答:
The problem may not be specific to your site.There is a bug in WordPress 3.5 with javascript which you might be experiencing others have resolved this by adding define(‘CONCATENATE_SCRIPTS’,false);in my wp-config.php file just before require_once(ABSPATH.‘wp-settings.php’);

参考
https://cloud.tencent.com/developer/article/2318506?areaId=106001

  • 16
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值