且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WordPress的上传文件大小

更新时间:2023-11-25 10:57:34

我不确定您使用的是哪种操作系统或使用的PHP版本.我使用PHP-FPM从Amazon Web Services运行Ubuntu 12.04实例.但是,说明应该基本上与您相同.在第3项中,保存php.ini文件的目录可能略有不同.

I'm not sure what operating system you are using or what version of PHP you are using. I run an Ubuntu 12.04 instance from Amazon Web Services using PHP-FPM. But, the instructions should be basically the same for you. The directory where your php.ini file is saved may be slightly different in item 3. Go hunt for it.

  1. 通过SSH登录到服务器.
  2. 将用户更改为root:sudo /bin/bash
  3. 编辑php.ini文件:nano /etc/php5/fpm/php.ini
  4. 找到显示upload_max_filesize = 2M的行.在nano中,您可以通过按Ctrl W进行搜索.
  5. 更改为所需的文件大小无论键入什么内容,末尾都必须有M(兆字节)或G(千兆字节)(例如upload_max_filesize = 200M=1G).
  1. Log in to your server via SSH.
  2. Change user to root: sudo /bin/bash
  3. Edit the php.ini file: nano /etc/php5/fpm/php.ini
  4. Find the line that says upload_max_filesize = 2M . In nano, you can search by typing Ctrl W.
  5. Change to whatever file size you want Whatever you type must have an M (megabytes) or G (gigabytes) at the end (e.g. upload_max_filesize = 200M or =1G).

目标是您需要的最低数量,并请记住,PHP在其他地方有另一个设置,用于设置超时之前等待的时间.您可以设置2G的上传限制,但是如果您的超时时间是30秒,那么除非您可以在30秒内上传2G,否则您仍然会失败.通常,要低一点.

Aim for the lowest number that you NEED, and keep in mind that PHP has another setting elsewhere that sets how long it will wait before a timeout. You can set a 2G upload limit, but if your timeout is 30 seconds you're still going to fail unless you can upload 2G in 30 seconds. As a general rule, aim low.

  1. 输入Ctrl X退出,保存文件更改.
  2. 通过键入service php5-fpm restart
  3. 重新启动PHP
  1. Type Ctrl X to exit, save your file changes.
  2. Restart PHP by typing service php5-fpm restart