question

Rahul-7230 avatar image
Rahul-7230 asked ·

How to deploy PHP (laravel) Application on Azure App services ? (Lower version of PHP)

Hi Team,

I need to deploy PHP(Laravel) application to Azure App Service.


Environment: Azure App Service (Linux) platform, Azure MySQL.

I'm referring to this documentation. (https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-php-mysql)

Issue:

  1. What is the minimum Version of PHP supported by Azure App Service ? And how to set the version ? Reason I'm asking is because application supports only this version (PHP >= 5.4, PHP < 7). In Portal I'm not getting the option to set it less than 7


  2. How to set Virtual path for PHP Laravel Application in Azure ? I'm not able to understand this statement "In the Cloud Shell, set the virtual application path by using the az resource update command. Replace the <appname> placeholder."



az resource update --name web --resource-group myResourceGroup --namespace Microsoft.Web --resource-type config --parent sites/<app_name> --set properties.virtualApplications[0].physicalPath="site\wwwroot\public" --api-version 2015-06-01

  *Reference*: https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-php-mysql#set-the-virtual-application-path
azure-webapps
2 comments
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PHP 5.x is long dead, https://www.php.net/supported-versions.php and even 7.2 is phasing out. So the initial challenge for you is that you won't get any support from Azure App Service by default, and you have to use your own container image or virtual machine to host PHP 5.x apps.

1 Vote 1 · ·

Hi rahul,

Did the answer below help answer your question?

0 Votes 0 · ·

1 Answer

GraceMacJonesMSFT-2612 avatar image
GraceMacJonesMSFT-2612 answered ·

Hi Rahul,


The minimum PHP version supported on App Service is 7.3 .

The Laravel application, uses the /public subdirectory as the site root. The default PHP Docker image for App Service uses Apache, and it doesn't let you customize the DocumentRoot for Laravel. However, you can use .htaccess to rewrite all requests to point to /public instead of the root directory. In the repository root, an .htaccess is added already for this purpose. With it, your Laravel application is ready to be deployed.


However, if you wish to change the site root, you can update the .htaccess file in your repository root with the following content:


   <IfModule mod_rewrite.c>
         RewriteEngine on
        
         RewriteRule ^.*$ /public/$1 [NC,L,QSA]
     </IfModule>


Hope that helps. please let us know if you have further questions.


Thanks,
Grace







1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@GraceMacJonesMSFT-2612 : It worked for me, now it's after editing the .htaccess , when hitting the direct URL it's taking to the application. Thanks for the Help.

1 Vote 1 · ·