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

前端 未结 9 2289
耶瑟儿~
耶瑟儿~ 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:16

    I had exactly the same problem and solved it using these steps:

    When running the following command on my server

    php --ini
    

    I got the following path of my php.ini

    Loaded Configuration File:         /etc/php/7.0/cli/php.ini
    

    I kept on making changes in this php.ini file, but none of the changes took effect. I then created a file called info.php in my /var/www/html directory and added the following code

    <?php
        phpinfo();
    ?>
    

    Then I opened the file in my browser http://example.com/info.php, where I saw that the actual loaded php.ini file was in a different directory

    Loaded Configuration File   /etc/php/7.0/apache2/php.ini
    

    When I made changes to the php.ini file inside of this directory, all the changes took effect. In summary make sure that you run the phpinfo(); function to make sure of the actual php.ini file which php uses.

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

    service apache2 reload needs to be run as root, even if it does not appear to fail without root. Running sudo service apache2 reload works. This is in Ubuntu 14.04.

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

    You might also need to increase the maximum size of a post:

    post_max_size=10M

    Try that.

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

    Maybe you find 2 directories for php.ini files. If you search where php.ini is using cli like php --ini maybe it show you /etc/php/7.1/cli/php.ini, but thereis another folder to php-fpm found in /etc/php/7.1/fpm/php.ini and you need to create your new ini file under conf.d folder like /etc/php/7.1/fpm/conf.d/30-user.ini and if you need a ini file to cli command line you need to put your ini file under /etc/php/7.1/cli/conf.d/30-user.ini

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

    After reading great @Jekis's answer, I solved the same issue for Fedora distribution (it's the same thing, just different path):

    1. After evaluting phpinfo(); output I found out that other .ini files are stored in: /etc/php.d directory

    2. In /etc/php.d I created a new file - 40-user.ini. I added upload_max_filesize and other settings that I wanted to change

    3. Then I restarted apache (httpd)

    And then changes were picked up.

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

    If you php.ini resides somewhere like /etc/php/7.*/fpm/php.ini - then modify it as needed and instead of sudo service apache2 restart go with service php7.1-fpm restart

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