Increase Max Upload Size on Azure App Service PHP8

Daryl Peter 0 Reputation points
2023-06-19T10:02:01.71+00:00

I'm trying to upload larger files to a PHP 8 app running on Azure App Service.

The instructions in the Microsoft Documentation for Azure App Service are referencing PHP 7 which used Apache, rather than the PHP 8 instances which use NGINX so they don't work.

I have tried adding client_max_body_size 100M; to the sites-available/default config file and restarted NGINX but no luck in getting it to work. The test file is 11MB, smaller files of 1MB work fine.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,262 questions
{count} votes

7 answers

Sort by: Most helpful
  1. Bogdan Berg 5 Reputation points
    2024-11-07T07:29:57.77+00:00

    And here's a good news - looks like I was finally able to chase down which of the couple dozen definitions of those variables actually take effect in WordPress hosted in Azure (Linux)!

    It's this one:

    /usr/local/etc/php/conf.d/uploads.ini

    after making the changes, be sure to restart php-fpm process:

    pkill php-fpm

    and you can verify that changes took effect by running:

    php -r "echo ini_get('upload_max_filesize');"

    I hope this helps someone! I've spent way too much time chasing this down... ;)

    1 person found this answer helpful.

  2. Santibanez, Jared 0 Reputation points
    2024-12-04T21:10:13.6933333+00:00

    edit: /etc/nginx/nginx.conf

    http {

    ...

    client_max_body_size 50M; # Set globally for all servers and locations

    }

    service nginx restart

    1 person found this answer helpful.
    0 comments No comments

  3. Manu Philip 19,346 Reputation points MVP
    2023-06-19T11:05:53.03+00:00

  4. Grmacjon-MSFT 18,816 Reputation points
    2023-08-18T20:03:23.0533333+00:00

    Hi @Daryl Peter I wanted to inform you that the Azure App Service documentation PHP 8 has been updated. Below is how you can upload files in PHP8:

    To customize PHP_INI_USER, PHP_INI_PERDIR, and PHP_INI_ALL directives for linux web apps, such as upload_max_filesize and expose_php, use a custom "ini" file. You can create it in an SSH session.

    1. Go to your KUDU site https://<sitename>.scm.azurewebsites.net.
    2. Select Bash or SSH from the top menu.
    3. In Bash/SSH, go to your "/home/site/wwwroot" directory.
    4. Create a directory called "ini" (for example, mkdir ini).
    5. Change the current working directory to the "ini" folder you just created.

    You need to create an "ini" file to add your settings to. In this example, we use "extensions.ini." There are no file editors such as Vi, Vim, or Nano so you'll use echo to add the settings to the file. Change the "upload_max_filesize" from 2M to 50M. Use the following command to add the setting and create an "extensions.ini" file if one doesn't already exist.

    /home/site/wwwroot/ini>echo "upload_max_filesize=50M" >> extensions.ini
    /home/site/wwwroot/ini>cat extensions.ini
    upload_max_filesize=50M
    /home/site/wwwroot/ini>
    

    Then, go to the Azure portal and add an Application Setting to scan the "ini" directory that you just created to apply the change for upload_max_filesize.

    1. Go to the Azure portal and select your App Service Linux PHP application.
    2. Select Application Settings for the app.
    3. Under the Application settings section, select + Add new setting.
    4. For the App Setting Name, enter "PHP_INI_SCAN_DIR" and for value, enter "/home/site/wwwroot/ini."
    5. Select the save button.

    Hope that helps.

    -Grace


  5. John M 0 Reputation points
    2024-07-03T07:41:32.7733333+00:00

    This is insanity. Wordpress is useless if you can only upload a 50mb database. This is a really basic setting that Microsoft is making very difficult. There is no information anywhere. I spent 16hrs trying to figure this out and am still at square 1. Does anyone have any sort of work around? I am simply trying to migrate a site over with a database that is 1.5gb.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.