@@ -7,16 +7,17 @@ Deploying to Microsoft Azure Website Cloud
7
7
This step by step article describes how to deploy a small Symfony web
8
8
application to the Microsoft Azure Website cloud platform. It will explain how
9
9
to set up a new Azure website including configuring the right PHP version and
10
- global environment variables. The document also shows how to you can leverage
10
+ global environment variables. The document also shows how you can leverage
11
11
Git and Composer to deploy your Symfony application to the cloud.
12
12
13
13
Setting up the Azure Website
14
14
----------------------------
15
15
16
16
To set up a new Microsoft Azure Website, first `sign up with Azure `_ or sign in
17
17
with your credentials. Once you're connected to your `Azure Portal `_ interface,
18
- scroll down to the bottom and select the **New ** panel. On this panel, click
19
- **Web Site ** and choose **Custom Create **:
18
+ select the **New ** panel. On this panel, use the search bar, search for
19
+ **Web App + MySQL ** and choose **Web App + MySQL ** by **Microsoft ** and
20
+ click **Create **:
20
21
21
22
.. image :: /_images/deployment/azure-website/step-01.png
22
23
:alt: Create a new custom Azure Website
@@ -29,58 +30,51 @@ Here, you will be prompted to fill in some basic information.
29
30
.. image :: /_images/deployment/azure-website/step-02.png
30
31
:alt: Setup the Azure Website
31
32
32
- For the URL, enter the URL that you would like to use for your Symfony application,
33
- then pick **Create new web hosting plan ** in the region you want. By default, a
34
- *free 20 MB SQL database * is selected in the database dropdown list. In this
35
- tutorial, the Symfony app will connect to a MySQL database. Pick the
36
- **Create a new MySQL database ** option in the dropdown list. You can keep
37
- the **DefaultConnection ** string name. Finally, check the box
38
- **Publish from source control ** to enable a Git repository and go to the
39
- next step.
33
+ For the URL, enter the URL that you would like to use for your Symfony
34
+ application, then select your **Subscription **, **Create a new Resource Group **
35
+ (which is a collection of resources that share the same lifecycle, permissions
36
+ and policies). Pick ClearDB as a **Database Provider **. Create a new **App
37
+ Service plan/Location ** you will be prompted to set up your app service plan
38
+ with a name, a region and a pricing tier. Then create a new **Database **, you
39
+ will be prompted to set up your MySQL database storage with a database name and
40
+ a region. The MySQL database storage is provided by Microsoft in partnership
41
+ with ClearDB. Choose the same region you selected for App Service plan.
40
42
41
- Step 2: New MySQL Database
42
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
43
+ Click Create to continue.
43
44
44
- On this step, you will be prompted to set up your MySQL database storage with a
45
- database name and a region. The MySQL database storage is provided by Microsoft
46
- in partnership with ClearDB. Choose the same region you selected for the hosting
47
- plan configuration in the previous step.
45
+ Once you created the web site, select **All resources ** in the left menu and
46
+ choose the website you just created.
48
47
49
- .. image :: /_images/deployment/azure-website/step-03.png
50
- :alt: Setup the MySQL database
51
-
52
- Agree to the terms and conditions and click on the right arrow to continue.
53
-
54
- Step 3: Where Is your Source Code
48
+ Step 2: Where Is your Source Code
55
49
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
50
57
- Now, on the third step, select a **Local Git repository ** item and click
58
- on the right arrow to configure your Azure Website credentials.
51
+ Now, select **Deployment options ** under **APP DEPLOYMENT **, select **Choose
52
+ Source ** and choose **Local Git repository ** to configure your Azure Website
53
+ credentials. If you choose a different source like GitHub or Bitbucket you can
54
+ ignore the next step.
59
55
60
- .. image :: /_images/deployment/azure-website/step-04 .png
56
+ .. image :: /_images/deployment/azure-website/step-03 .png
61
57
:alt: Setup a local Git repository
62
58
63
- Step 4: New Username and Password
64
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
-
66
- Great! You're now on the final step. Create a username and a secure password:
67
- these will become essential identifiers to connect to the FTP server and
68
- also to push your application code to the Git repository.
59
+ Once you selected **Local Git repository **, click **Setup connection ** you will
60
+ be prompted to create a username and a secure password: these will become
61
+ essential identifiers to connect to the FTP server and also to push your
62
+ application code to the Git repository.
69
63
70
- .. image :: /_images/deployment/azure-website/step-05 .png
64
+ .. image :: /_images/deployment/azure-website/step-04 .png
71
65
:alt: Configure Azure Website credentials
72
66
73
67
Congratulations! Your Azure Website is now up and running. You can check
74
68
it by browsing to the Website url you configured in the first step. You should
75
69
see the following display in your web browser:
76
70
77
- .. image :: /_images/deployment/azure-website/step-06 .png
71
+ .. image :: /_images/deployment/azure-website/step-05 .png
78
72
:alt: Azure Website is running
79
73
80
74
The Microsoft Azure portal also provides a complete control panel for the Azure
81
75
Website.
82
76
83
- .. image :: /_images/deployment/azure-website/step-07 .png
77
+ .. image :: /_images/deployment/azure-website/step-06 .png
84
78
:alt: Azure Website Control Panel
85
79
86
80
Your Azure Website is ready! But to run a Symfony site, you need to configure
@@ -100,10 +94,10 @@ Even though Symfony only requires PHP 5.3.9 to run, it's always recommended
100
94
to use the most recent PHP version whenever possible. PHP 5.3 is no longer
101
95
supported by the PHP core team, but you can update it easily in Azure.
102
96
103
- To update your PHP version on Azure, go to the **Configure ** tab of the control
104
- panel and select the version you want.
97
+ To update your PHP version on Azure, go to the **Application settings ** under
98
+ ** SETTINGS ** and select the version you want.
105
99
106
- .. image :: /_images/deployment/azure-website/step-08 .png
100
+ .. image :: /_images/deployment/azure-website/step-07 .png
107
101
:alt: Enabling the most recent PHP runtime from Azure Website Control Panel
108
102
109
103
Click the **Save ** button in the bottom bar to save your changes and restart
@@ -117,10 +111,10 @@ the web server.
117
111
is no need to install and set up APC.
118
112
119
113
The following screenshot shows the output of a :phpfunction: `phpinfo ` script
120
- run from an Azure Website to verify that PHP 5.5 is running with
114
+ run from an Azure Website to verify that PHP 7.0 is running with
121
115
OPCache enabled.
122
116
123
- .. image :: /_images/deployment/azure-website/step-09 .png
117
+ .. image :: /_images/deployment/azure-website/step-08 .png
124
118
:alt: OPCache Configuration
125
119
126
120
Tweaking php.ini Configuration Settings
@@ -158,17 +152,16 @@ Website repository.
158
152
Enabling the PHP intl Extension
159
153
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
154
161
- This is the tricky part of the guide! At the time of writing this article,
162
- Microsoft Azure Website provided the ``intl `` extension, but it's not enabled
163
- by default. To enable the ``intl `` extension, there is no need to upload
164
- any DLL files as the ``php_intl.dll `` file already exists on Azure. In fact,
165
- this file just needs to be moved into the custom website extension directory.
155
+ **The ** ``intl `` **extension is now enabled by default. The following steps are
156
+ no longer necessary. ** You can check if the ``intl `` extension is enabled in the
157
+ :phpfunction: `phpinfo ` page.
166
158
167
- .. note ::
159
+ However if the `` intl `` extension is not enabled you can follow these steps.
168
160
169
- The Microsoft Azure team is currently working on enabling the ``intl `` PHP
170
- extension by default. In the near future, the following steps will no
171
- longer be necessary.
161
+ This is the tricky part of the guide! To enable the ``intl `` extension, there is
162
+ no need to upload any DLL files as the ``php_intl.dll `` file already exists on
163
+ Azure. In fact, this file just needs to be moved into the custom website
164
+ extension directory.
172
165
173
166
To get the ``php_intl.dll `` file under your ``site/wwwroot `` directory, simply
174
167
access the online **Kudu ** tool by browsing to the following URL:
@@ -182,7 +175,7 @@ explorer, a command line prompt, a log stream and a configuration settings summa
182
175
page. Of course, this section can only be accessed if you're logged in to
183
176
your main Azure Website account.
184
177
185
- .. image :: /_images/deployment/azure-website/step-10 .png
178
+ .. image :: /_images/deployment/azure-website/step-09 .png
186
179
:alt: The Kudu Panel
187
180
188
181
From the Kudu front page, click on the **Debug Console ** navigation item in the
@@ -201,26 +194,26 @@ new directory must be created under the main directory ``site/wwwroot``.
201
194
202
195
The whole process and output should look like this:
203
196
204
- .. image :: /_images/deployment/azure-website/step-11 .png
197
+ .. image :: /_images/deployment/azure-website/step-10 .png
205
198
:alt: Executing commands in the online Kudu Console prompt
206
199
207
200
To complete the activation of the ``php_intl.dll `` extension, you must tell
208
201
Azure Website to load it from the newly created ``ext `` directory. This can be
209
202
done by registering a global ``PHP_EXTENSIONS `` environment variable from
210
- the **Configure ** tab of the main Azure Website Control panel.
203
+ the **Application settings ** page of the main Azure Website control panel.
211
204
212
205
In the **app settings ** section, register the ``PHP_EXTENSIONS `` environment
213
206
variable with the value ``ext\php_intl.dll `` as shown in the screenshot below:
214
207
215
- .. image :: /_images/deployment/azure-website/step-12 .png
208
+ .. image :: /_images/deployment/azure-website/step-11 .png
216
209
:alt: Registering custom PHP extensions
217
210
218
211
Hit "save" to confirm your changes and restart the web server. The PHP ``Intl ``
219
212
extension should now be available in your web server environment. The following
220
213
screenshot of a :phpfunction: `phpinfo ` page verifies the ``intl `` extension is
221
214
properly enabled:
222
215
223
- .. image :: /_images/deployment/azure-website/step-13 .png
216
+ .. image :: /_images/deployment/azure-website/step-12 .png
224
217
:alt: Intl extension is enabled
225
218
226
219
Great! The PHP environment setup is now complete. Next, you'll learn how
@@ -242,10 +235,10 @@ following command in your terminal:
242
235
Get your Git from the `git-scm.com `_ website and follow the instructions
243
236
to install and configure it on your local machine.
244
237
245
- In the Azure Website Control panel, browse the **Deployment ** tab to get the
238
+ In the Azure Website Control panel, browse the **Overview ** tab to get the
246
239
Git repository URL where you should push your code:
247
240
248
- .. image :: /_images/deployment/azure-website/step-14 .png
241
+ .. image :: /_images/deployment/azure-website/step-13 .png
249
242
:alt: Git deployment panel
250
243
251
244
Now, you'll want to connect your local Symfony application with this remote
@@ -296,7 +289,7 @@ Git repository.
296
289
The deployment with Git should produce an output similar to the screenshot
297
290
below:
298
291
299
- .. image :: /_images/deployment/azure-website/step-15 .png
292
+ .. image :: /_images/deployment/azure-website/step-14 .png
300
293
:alt: Deploying files to the Git Azure Website repository
301
294
302
295
The code of the Symfony application has now been deployed to the Azure Website
@@ -316,7 +309,7 @@ of the Kudu application and execute the following commands in it:
316
309
317
310
$ cd site\wwwroot
318
311
$ curl -sS https://getcomposer.org/installer | php
319
- $ php -d extension=php_intl.dll composer.phar install
312
+ $ php composer.phar install
320
313
321
314
The ``curl `` command retrieves and downloads the Composer command line tool and
322
315
installs it at the root of the ``site/wwwroot `` directory. Then, running
@@ -326,28 +319,21 @@ libraries.
326
319
This may take a while depending on the number of third-party dependencies
327
320
you've configured in your ``composer.json `` file.
328
321
329
- .. note ::
330
-
331
- The ``-d `` switch allows you to quickly override/add any ``php.ini `` settings.
332
- In this command, we are forcing PHP to use the ``intl `` extension, because
333
- it is not enabled by default in Azure Website at the moment. Soon, this
334
- ``-d `` option will no longer be needed since Microsoft will enable the
335
- ``intl `` extension by default.
336
322
337
323
At the end of the ``composer install `` command, you will be prompted to fill in
338
324
the values of some Symfony settings like database credentials, locale, mailer
339
325
credentials, CSRF token protection, etc. These parameters come from the
340
326
``app/config/parameters.yml.dist `` file.
341
327
342
- .. image :: /_images/deployment/azure-website/step-16 .png
328
+ .. image :: /_images/deployment/azure-website/step-15 .png
343
329
:alt: Configuring Symfony global parameters
344
330
345
331
The most important thing in this article is to correctly set up your database
346
- settings. You can get your MySQL database settings on the right sidebar of the
347
- ** Azure Website Dashboard ** panel . Simply click on the
348
- ** View Connection Strings ** link to make them appear in a pop-in .
332
+ settings. You can get your MySQL database settings in the ** Application
333
+ settings ** page . Simply click on the ** Show connection string values ** link to
334
+ make them appear.
349
335
350
- .. image :: /_images/deployment/azure-website/step-17 .png
336
+ .. image :: /_images/deployment/azure-website/step-16 .png
351
337
:alt: MySQL database settings
352
338
353
339
The displayed MySQL database settings should be something similar to the code
@@ -377,9 +363,6 @@ doesn't provide a built-in mailer service. You should consider configuring
377
363
the host-name and credentials of some other third-party mailing service if
378
364
your application needs to send emails.
379
365
380
- .. image :: /_images/deployment/azure-website/step-18.png
381
- :alt: Configuring Symfony
382
-
383
366
Your Symfony application is now configured and should be almost operational. The
384
367
final step is to build the database schema. This can easily be done with the
385
368
command line interface if you're using Doctrine. In the online **Console ** tool
@@ -421,8 +404,6 @@ application, configure it with the following content:
421
404
422
405
.. code-block :: xml
423
406
424
- <!-- web.config -->
425
- <?xml version =" 1.0" encoding =" UTF-8" ?>
426
407
<configuration >
427
408
<system .webServer>
428
409
<rewrite >
@@ -472,7 +453,7 @@ to implement. And as a bonus, Microsoft is continuing to reduce the number
472
453
of steps needed so that deployment becomes even easier.
473
454
474
455
.. _`sign up with Azure` : https://signup.live.com/signup.aspx
475
- .. _`Azure Portal` : https://manage.windowsazure .com
456
+ .. _`Azure Portal` : https://portal.azure .com
476
457
.. _`PHP MSDN documentation` : http://blogs.msdn.com/b/silverlining/archive/2012/07/10/configuring-php-in-windows-azure-websites-with-user-ini-files.aspx
477
458
.. _`git-scm.com` : http://git-scm.com/download
478
459
.. _`SymfonyAzureEdition` : https://github.com/beberlei/symfony-azure-edition/
0 commit comments