Changes to upload_max_filesize in Ubuntu php.ini will not take effect

前端 未结 9 2290
耶瑟儿~
耶瑟儿~ 2020-12-05 04:54

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

相关标签:
9条回答
  • 2020-12-05 05:36

    This message helped me:

    The newest php version installed on server does not allow global settings (such as execution time, max upload filesize, max post file size, etc.) to be changed.

    Folow these steps to resolve the issue:

    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

    File /etc/php5/apache2/conf.d/user.ini

    post_max_size = 90M
    upload_max_filesize = 50M
    

    Update 2018.06

    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
    

    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.

    For example: 30-user.ini.

    After file creation don't forget to restart fpm:

    sudo service php7.0-fpm restart
    
    0 讨论(0)
  • 2020-12-05 05:36

    Have you restarted apache2?

    sudo service apache2 restart

    The new php.ini configuration is only applied when apache starts.

    0 讨论(0)
  • 2020-12-05 05:39

    I had a very strange experience which caused the same symptom like this.

    The point is that my php.ini file contained an old-style comment (starting with hashmark) which, as of php 7.0, is not a comment any more. The incorrect comment confused the ini-parser.

    The solution was to replace all # comment symbols with semicolon (;) which is the only standard way for writing comments.

    For further details, please read my comment here:

    https://serverfault.com/a/1012262/494670

    0 讨论(0)
提交回复
热议问题