@@ -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
@@ -30,57 +31,46 @@ Here, you will be prompted to fill in some basic information.
30
31
:alt: Setup the Azure Website
31
32
32
33
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.
40
-
41
- Step 2: New MySQL Database
42
- ~~~~~~~~~~~~~~~~~~~~~~~~~~
43
-
44
- On this step, you will be prompted to set up your MySQL database storage with a
34
+ then select your **Subscription **, **Create a new Resource Group ** (which is a
35
+ collection of resources that share the same lifecycle, permissions and policies).
36
+ Pick ClearDB as a **Database Provider **. Create a new **App Service plan/Location **
37
+ you will be prompted to set up your app service plan with a name, a region and a pricing tier.
38
+ Then create a new **Database **, you will be prompted to set up your MySQL database storage with a
45
39
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.
40
+ in partnership with ClearDB. Choose the same region you selected for App Service plan.
48
41
49
- .. image :: /_images/deployment/azure-website/step-03.png
50
- :alt: Setup the MySQL database
42
+ Click Create to continue.
51
43
52
- Agree to the terms and conditions and click on the right arrow to continue .
44
+ Once you created the web site, select ** All resources ** in the left menu and choose the website you just created .
53
45
54
- Step 3 : Where Is your Source Code
46
+ Step 2 : Where Is your Source Code
55
47
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56
48
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.
49
+ Now, select **Deployment options ** under **APP DEPLOYMENT **, select **Choose Source ** and choose
50
+ **Local Git repository ** to configure your Azure Website credentials. If you choose a different source
51
+ like GitHub or Bitbucket you can ignore the next step.
59
52
60
- .. image :: /_images/deployment/azure-website/step-04 .png
53
+ .. image :: /_images/deployment/azure-website/step-03 .png
61
54
:alt: Setup a local Git repository
62
55
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.
56
+ Once you selected **Local Git repository **, click **Setup connection ** you will be prompted
57
+ to create a username and a secure password: these will become essential identifiers
58
+ to connect to the FTP server and also to push your application code to the Git repository.
69
59
70
- .. image :: /_images/deployment/azure-website/step-05 .png
60
+ .. image :: /_images/deployment/azure-website/step-04 .png
71
61
:alt: Configure Azure Website credentials
72
62
73
63
Congratulations! Your Azure Website is now up and running. You can check
74
64
it by browsing to the Website url you configured in the first step. You should
75
65
see the following display in your web browser:
76
66
77
- .. image :: /_images/deployment/azure-website/step-06 .png
67
+ .. image :: /_images/deployment/azure-website/step-05 .png
78
68
:alt: Azure Website is running
79
69
80
70
The Microsoft Azure portal also provides a complete control panel for the Azure
81
71
Website.
82
72
83
- .. image :: /_images/deployment/azure-website/step-07 .png
73
+ .. image :: /_images/deployment/azure-website/step-06 .png
84
74
:alt: Azure Website Control Panel
85
75
86
76
Your Azure Website is ready! But to run a Symfony site, you need to configure
@@ -100,10 +90,9 @@ Even though Symfony only requires PHP 5.3.9 to run, it's always recommended
100
90
to use the most recent PHP version whenever possible. PHP 5.3 is no longer
101
91
supported by the PHP core team, but you can update it easily in Azure.
102
92
103
- To update your PHP version on Azure, go to the **Configure ** tab of the control
104
- panel and select the version you want.
93
+ To update your PHP version on Azure, go to the **Application settings ** under **SETTINGS ** and select the version you want.
105
94
106
- .. image :: /_images/deployment/azure-website/step-08 .png
95
+ .. image :: /_images/deployment/azure-website/step-07 .png
107
96
:alt: Enabling the most recent PHP runtime from Azure Website Control Panel
108
97
109
98
Click the **Save ** button in the bottom bar to save your changes and restart
@@ -117,10 +106,10 @@ the web server.
117
106
is no need to install and set up APC.
118
107
119
108
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
109
+ run from an Azure Website to verify that PHP 7.0 is running with
121
110
OPCache enabled.
122
111
123
- .. image :: /_images/deployment/azure-website/step-09 .png
112
+ .. image :: /_images/deployment/azure-website/step-08 .png
124
113
:alt: OPCache Configuration
125
114
126
115
Tweaking php.ini Configuration Settings
@@ -158,17 +147,13 @@ Website repository.
158
147
Enabling the PHP intl Extension
159
148
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160
149
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.
150
+ **The ** ``intl `` **extension is now enabled by default. The following steps are no longer necessary. ** You can check if the ``intl `` extension is enabled in the :phpfunction: `phpinfo ` page.
166
151
167
- .. note ::
152
+ However if the `` intl `` extension is not enabled you can follow these steps.
168
153
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 .
154
+ This is the tricky part of the guide! To enable the ``intl `` extension, there is no need to upload
155
+ any DLL files as the `` php_intl.dll `` file already exists on Azure. In fact,
156
+ this file just needs to be moved into the custom website extension directory .
172
157
173
158
To get the ``php_intl.dll `` file under your ``site/wwwroot `` directory, simply
174
159
access the online **Kudu ** tool by browsing to the following URL:
@@ -182,7 +167,7 @@ explorer, a command line prompt, a log stream and a configuration settings summa
182
167
page. Of course, this section can only be accessed if you're logged in to
183
168
your main Azure Website account.
184
169
185
- .. image :: /_images/deployment/azure-website/step-10 .png
170
+ .. image :: /_images/deployment/azure-website/step-09 .png
186
171
:alt: The Kudu Panel
187
172
188
173
From the Kudu front page, click on the **Debug Console ** navigation item in the
@@ -201,26 +186,26 @@ new directory must be created under the main directory ``site/wwwroot``.
201
186
202
187
The whole process and output should look like this:
203
188
204
- .. image :: /_images/deployment/azure-website/step-11 .png
189
+ .. image :: /_images/deployment/azure-website/step-10 .png
205
190
:alt: Executing commands in the online Kudu Console prompt
206
191
207
192
To complete the activation of the ``php_intl.dll `` extension, you must tell
208
193
Azure Website to load it from the newly created ``ext `` directory. This can be
209
194
done by registering a global ``PHP_EXTENSIONS `` environment variable from
210
- the **Configure ** tab of the main Azure Website Control panel.
195
+ the **Application settings ** page of the main Azure Website control panel.
211
196
212
197
In the **app settings ** section, register the ``PHP_EXTENSIONS `` environment
213
198
variable with the value ``ext\php_intl.dll `` as shown in the screenshot below:
214
199
215
- .. image :: /_images/deployment/azure-website/step-12 .png
200
+ .. image :: /_images/deployment/azure-website/step-11 .png
216
201
:alt: Registering custom PHP extensions
217
202
218
203
Hit "save" to confirm your changes and restart the web server. The PHP ``Intl ``
219
204
extension should now be available in your web server environment. The following
220
205
screenshot of a :phpfunction: `phpinfo ` page verifies the ``intl `` extension is
221
206
properly enabled:
222
207
223
- .. image :: /_images/deployment/azure-website/step-13 .png
208
+ .. image :: /_images/deployment/azure-website/step-12 .png
224
209
:alt: Intl extension is enabled
225
210
226
211
Great! The PHP environment setup is now complete. Next, you'll learn how
@@ -242,10 +227,10 @@ following command in your terminal:
242
227
Get your Git from the `git-scm.com `_ website and follow the instructions
243
228
to install and configure it on your local machine.
244
229
245
- In the Azure Website Control panel, browse the **Deployment ** tab to get the
230
+ In the Azure Website Control panel, browse the **Overview ** tab to get the
246
231
Git repository URL where you should push your code:
247
232
248
- .. image :: /_images/deployment/azure-website/step-14 .png
233
+ .. image :: /_images/deployment/azure-website/step-13 .png
249
234
:alt: Git deployment panel
250
235
251
236
Now, you'll want to connect your local Symfony application with this remote
@@ -296,7 +281,7 @@ Git repository.
296
281
The deployment with Git should produce an output similar to the screenshot
297
282
below:
298
283
299
- .. image :: /_images/deployment/azure-website/step-15 .png
284
+ .. image :: /_images/deployment/azure-website/step-14 .png
300
285
:alt: Deploying files to the Git Azure Website repository
301
286
302
287
The code of the Symfony application has now been deployed to the Azure Website
@@ -316,7 +301,7 @@ of the Kudu application and execute the following commands in it:
316
301
317
302
$ cd site\wwwroot
318
303
$ curl -sS https://getcomposer.org/installer | php
319
- $ php -d extension=php_intl.dll composer.phar install
304
+ $ php composer.phar install
320
305
321
306
The ``curl `` command retrieves and downloads the Composer command line tool and
322
307
installs it at the root of the ``site/wwwroot `` directory. Then, running
@@ -326,28 +311,20 @@ libraries.
326
311
This may take a while depending on the number of third-party dependencies
327
312
you've configured in your ``composer.json `` file.
328
313
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
314
337
315
At the end of the ``composer install `` command, you will be prompted to fill in
338
316
the values of some Symfony settings like database credentials, locale, mailer
339
317
credentials, CSRF token protection, etc. These parameters come from the
340
318
``app/config/parameters.yml.dist `` file.
341
319
342
- .. image :: /_images/deployment/azure-website/step-16 .png
320
+ .. image :: /_images/deployment/azure-website/step-15 .png
343
321
:alt: Configuring Symfony global parameters
344
322
345
323
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.
324
+ settings. You can get your MySQL database settings in the **Application settings ** page. Simply click on the
325
+ **Show connection string values ** link to make them appear.
349
326
350
- .. image :: /_images/deployment/azure-website/step-17 .png
327
+ .. image :: /_images/deployment/azure-website/step-16 .png
351
328
:alt: MySQL database settings
352
329
353
330
The displayed MySQL database settings should be something similar to the code
@@ -377,9 +354,6 @@ doesn't provide a built-in mailer service. You should consider configuring
377
354
the host-name and credentials of some other third-party mailing service if
378
355
your application needs to send emails.
379
356
380
- .. image :: /_images/deployment/azure-website/step-18.png
381
- :alt: Configuring Symfony
382
-
383
357
Your Symfony application is now configured and should be almost operational. The
384
358
final step is to build the database schema. This can easily be done with the
385
359
command line interface if you're using Doctrine. In the online **Console ** tool
@@ -421,8 +395,6 @@ application, configure it with the following content:
421
395
422
396
.. code-block :: xml
423
397
424
- <!-- web.config -->
425
- <?xml version =" 1.0" encoding =" UTF-8" ?>
426
398
<configuration >
427
399
<system .webServer>
428
400
<rewrite >
@@ -472,7 +444,7 @@ to implement. And as a bonus, Microsoft is continuing to reduce the number
472
444
of steps needed so that deployment becomes even easier.
473
445
474
446
.. _`sign up with Azure` : https://signup.live.com/signup.aspx
475
- .. _`Azure Portal` : https://manage.windowsazure .com
447
+ .. _`Azure Portal` : https://portal.azure .com
476
448
.. _`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
449
.. _`git-scm.com` : http://git-scm.com/download
478
450
.. _`SymfonyAzureEdition` : https://github.com/beberlei/symfony-azure-edition/
0 commit comments