Kolvin
Kolvin

Reputation: 185

Deploying a Symfony2 App onto Azure Web hosting

what my aim here is to, upload my project that is basically a controller returning a twig template its as simple as that, i just cant figure out how to get it on the hosting.

I have been using symfony for a few months now, so still new to it all. and all the hosting/details stuff is new too me.

Whats throwing me off is my understanding of a hosting web/ folder and how azures its wwwroot/

i used this website

http://symfony.com/doc/current/cookbook/deployment/azure-website.html

but i'm finding it rather difficult to follow it..

does anyone have any better sites with more clear steps on how to deploy? i've read a lot about a public_html folder but i've never heard/used it before

If someone could explain how the www.domain.com/web/app.php works that would help, i know that, that is the file that is called, but not too sure if i need to say call this file "app.php" or if its done kinda like the way a standard websites looks for 'index.php'

any kinda help or pointers would be much appreciated here as i'm kinda lost

Upvotes: 2

Views: 1862

Answers (2)

Gary Liu
Gary Liu

Reputation: 13918

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 init git 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 install enter image description here Now 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 .

Upvotes: 11

LorenzSchaef
LorenzSchaef

Reputation: 1543

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.

Upvotes: 1

Related Questions