简体   繁体   English

文件“php.ini”中的更改没有任何影响

[英]Changes in file "php.ini" doesn't have any effect

I need to upload file more than 100 MB, yii\\web\\UploadedFile .我需要上传超过 100 MB 的文件yii\\web\\UploadedFile I am using Linux, CentOS 7.我正在使用 Linux、CentOS 7。

I did:我做了:

  1. check path to php.ini in phpinfo()phpinfo() 中检查 php.ini 的路径
  2. add in php_value upload_max_filesize 512M php_value post_max_size 512M in php.ini在 php.ini 中添加php_value upload_max_filesize 512M php_value post_max_size 512M
  3. restart the LAMP server ( lampp ) and run phpnfo() to check, but nothing changed.重新启动 LAMP 服务器( lampp )并运行 phpnfo() 进行检查,但没有任何改变。 Although php.ini changed.虽然php.ini改变了。
  4. restart my PC and start the LAMP server, but still no changes in phpnfo().重新启动我的 PC 并启动 LAMP 服务器,但在 phpnfo() 中仍然没有变化。

I have found some solution to add additional.ini.files, but in my phpinfo(): Scan this directory for additional .ini files (none).我找到了一些添加 additional.ini.files 的解决方案,但在我的 phpinfo() 中:扫描此目录以查找其他 .ini 文件(无)。

I solve this by adding this in file .htaccess :我通过在文件.htaccess 中添加这个来解决这个问题:

php_value upload_max_filesize 512M

php_value post_max_size 512M

But the problem still exists.但问题仍然存在。 I can't influence file php.ini .我无法影响文件php.ini

The syntax php_value ... only works in .htaccess files.语法php_value ...仅适用于 .htaccess 文件。

To change the value in the php.ini file, you dont' need the php_value part.要更改php.ini文件中的值,您不需要php_value部分。 Search the file for the upload_max_filesize attribute, it's most likely already there and change the value to 512M .在文件中搜索upload_max_filesize属性,它很可能已经存在并将值更改为512M The the line starts with a ;该行以;开头remove it as this comments the line.删除它,因为这会评论该行。 Do the same for the post_max_size attribute.post_max_size属性执行相同的操作。 If these attributes does not exists yet, add them to the end of the file:如果这些属性尚不存在,请将它们添加到文件末尾:

upload_max_filesize = 512M
post_max_size = 512M

After editing the file you need to restart PHP and Apache.编辑完文件后,您需要重新启动 PHP 和 Apache。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM