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.
7,407 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Manu Philip 17,751 Reputation points MVP
    2023-06-19T11:05:53.03+00:00

  2. Grmacjon-MSFT 17,456 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


  3. 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