本文介绍了在Ubuntu php.ini中对upload_max_filesize的更改将不会生效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了两天,以将通过php上传文件的最大文件大小从默认的2M增加到10M.我将phpinfo引用的php.ini文件更改为无效.

I have been trying for two days to increase the max filesize for file uploads via php to 10M from the default 2M. I change the php.ini file that is referenced by phpinfo to no avail.

我看到了几篇文章,指出php.ini文件的109行周围有语法错误,但是我不知道语法错误是什么或如何纠正.用户指出,由于配置文件中的此错误之后,upload_max_filesize被忽略.请帮忙.

I saw a few articles stating that there is a syntax error around line 109 of the php.ini file, but I don't know what the syntax error is or how to correct it. users stated that because the upload_max_filesize is AFTER this error in the config file it is being ignored. Please help.

推荐答案

此消息对我有帮助:

请按照以下步骤解决问题:

Folow these steps to resolve the issue:

  1. 评估phpinfo();
  2. phpinfo()输出中搜索"扫描此目录以查找其他.ini文件"文本
  3. 会是这样的/etc/php5/apache2/conf.d
  4. 在目录中创建您的 user.ini 文件. (/etc/php5/apache2/conf.d/user.ini)
  5. 将此ini文件用于自定义设置.
  6. 重新启动服务器
  1. Eval phpinfo();
  2. Search for 'Scan this dir for additional .ini files' text in phpinfo() output
  3. It will be something like this /etc/php5/apache2/conf.d
  4. Create your user.ini file inside the dir. (/etc/php5/apache2/conf.d/user.ini)
  5. Use this ini file for custom settings.
  6. Restart the server

文件/etc/php5/apache2/conf.d/user.ini

post_max_size = 90M
upload_max_filesize = 50M

更新2018.06

如果您使用的是 nginx + php-fpm ,则您的路径将是这样的(在路径中使用您的php版本).使用以下文件创建文件:

If you are using nginx + php-fpm your path will be something like this (use your php version in path). Create file using:

nano /etc/php/7.0/fpm/conf.d/user.ini

conf.d目录中还有许多其他.ini文件.如果您希望您的配置成为最后一个包含的内容,请使用前缀.

There are a lot of other .ini files in the conf.d directory. If you want your config to be the last included - use prefix.

例如:30-user.ini.

创建文件后,别忘了重新启动fpm:

After file creation don't forget to restart fpm:

sudo service php7.0-fpm restart

这篇关于在Ubuntu php.ini中对upload_max_filesize的更改将不会生效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:51