Deploying a Symfony2 App onto Azure Web hosting Deploying a Symfony2 App onto Azure Web hosting azure azure

Deploying a Symfony2 App onto Azure Web hosting


Generally, we can build our project and test on local, then deploy on Azure Web Apps via Git or FTP tools.

Here is my test steps:

  1. Build Symfony project on local, referring Using the Symfony full-stack framework
  2. Login to Azure preview Portal, click NEW=> Web+Mobile=> Marketplace, in Web Apps section click Web app + MySQL, then click create.
  3. When finishing creating Web app service, we can find MySQL connection string in Settings=>Application settings=>Connection strings click show connection string.enter image description here
  4. then click Set up continuous deployment in Deployment section. Select Local Git Repository for the source. Then in Essentials section, we can find there added a Git URL. Copy it.enter image description here
  5. In your local symfony project, make sure your Symfony repository has a .gitignore file at its root directory with at least the following contents:/app/bootstrap.php.cache/app/cache/*/app/config/parameters.yml/app/logs/*!app/cache/.gitkeep!app/logs/.gitkeep/app/SymfonyRequirements.php/build//vendor//bin//composer.phar/web/app_dev.php/web/bundles//web/config.php
  6. run the following commands to init git repo and first-time push to Azure:`git initgit add .git commit -m "initial commit"git remote add azure [URL for remote repository]git push azure master

  7. Sign on Kudu console of your Azure web site, at https://<your-website-name>.scm.azurewebsites.net/DebugConsole, run following commands:cd site\wwwroot curl -sS https://getcomposer.org/installer | php php composer.phar installenter image description hereNow visit http://<your-website-name>.azurewebsites.net/web/app.php in browser, we should see the project.

  8. Now we need to configure URL rewrite to remove /web/app.php pattern of the url. Add a file named web.config with the content shown in Deploying to Microsoft Azure Website Cloud in the root directory which is /site/wwwroot on Azure. Click restart on Azure portal, now we can visit the site at http://<your-website-name>.azurewebsites.net .

By the way, for deploying a PHP-MySQL application on Azure Web Apps, we can get more information at Create a PHP-MySQL web app in Azure App Service and deploy using Git. And specifically for Symfony project, the Symfony guide is still useful, and we can ignore section Enabling the PHP intl Extension .


If you can't change the name of the "wwwroot" directory to "web", you have to change the configuration of symfony to use "wwwroot" instead.

Have a look at this page!

I think the easiest solution is the one with the symlink:

Some shared hosts have a public_html web directory root. Renaming your web directory from web to public_html is one way to make your Symfony project work on your shared host. Another way is to deploy your application to a directory outside of your web root, delete your public_html directory, and then replace it with a symbolic link to the web in your project.