php solution in windows azure - microsoft · 2016-08-23 · php solution in windows azure 1windows...
TRANSCRIPT
PHP Solution in Windows Azure
1 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
PHP Solution in Windows Azure
Version 1.0
Date: 10.15.2010
Avkash Chauhan [email protected]
PHP Solution in Windows Azure
2 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Contents
1. Azure Companion for PHP
2. Downloading Azure Companion for PHP
3. What is in Azure Companion for PHP Solution
4. Azure Companion for PHP Solution contents
5. Modifying Azure Companion configuration CSCFG file
6. Publishing Azure Companion for PHP solution
7. Executing PHP Service and administration site
8. PHP Service Administration
9. Installing PHP Runtime and other modules
10. Verifying PHP Service and PHP applications
11. Using eXtplorer PHP Application
12. Creating custom PHP Application XML Feed
13. Configuring Service with updated configuration
14. Installing PHP Application from updated XML Feed
15. Stopping PHP Service
16. Configuring PHP Service by editing PHP.INI
17. Resetting full Azure Companion Solution
18. Application Update and delete scenarios
19. Role of Azure Storage in Azure Companion
20. Understanding Azure Companion Source
21. Azure companion VHD Analysis
22. Common Errors
PHP Solution in Windows Azure
3 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Location: http://code.msdn.microsoft.com/azurecompanion
Getting Started
“Getting Started” with the using the Windows Azure Companion for deploying PHP runtimes,
frameworks, and applications is as easy as 1, 2, 3. OK, it’s more like 1,2,3,4.
PHP Solution in Windows Azure
4 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
http://code.msdn.microsoft.com/azurecompanion/Release/ProjectReleases.aspx?ReleaseId=4956
You can choose your kind of VM and download it.
It is always good to download the source to understand the solution architecture, which we will study
later.
PHP Solution in Windows Azure
5 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Here I have downloaded all 4 types of VM:
Once you have downloaded the VM file the cscfg is same in all the VM:
However the actual CSPKG file is different in the following aspects:
PHP Solution in Windows Azure
6 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
This main difference is related to the fact that the CSDEF file which is part of CSPKG has different in the
following aspects:
WindowsAzureCompanion-ExtraLargeVM-Sep2010CTP <WebRole name="WebRole1" vmsize="ExtraLarge">
WindowsAzureCompanion-LargeVM-Sep2010CTP <WebRole name="WebRole1" vmsize="Large">
WindowsAzureCompanion-MediumVM-Sep2010CTP
<WebRole name="WebRole1" vmsize="Medium">
WindowsAzureCompanion-SmallVM-Sep2010CTP
<WebRole name="WebRole1" vmsize="Small">
The CSPKG file is encrypted so you will not be able to decrypt the contents however if you want to build
your own package you use the source and just rebuild it.
PHP Solution in Windows Azure
7 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Now we will work on Small VM and look the contents of the ZIP file:
We will keep the cspkg file as it is and look for cscfg for modification:
<?xml version="1.0"?> <ServiceConfiguration serviceName="WindowsAzureCompanion" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"> <Role name="WorkerRole"> <!-- Windows Azure Companion does not support multiple instances yet. Please do not change this count. --> <Instances count="1" /> <ConfigurationSettings> <!-- Application Details. Title and Welcome text --> <Setting name="ApplicationTitle" value="Windows Azure Companion" /> <Setting name="ApplicationDescription" value="<p>The <span class="textlink"><a href="http://www.microsoft.com/windowsazure/windowsazure">Windows Azure platform</a></span> is a cloud platform that allows applications to be hosted and run at Microsoft datacenters. It provides a cloud operating system called Windows Azure that serves as the runtime for the applications and provides a set of services that allow development, management and hosting of applications.</p> <p>With its standards-based and interoperable approach, the Windows Azure platform supports multiple Internet protocols including HTTP, XML, SOAP and REST. As an open platform, the Windows Azure platform allows developers to use multiples languages (.NET, Java, and PHP & other dynamic languages ) to build applications which run on Windows Azure and/or consume any of the Windows Azure platform offerings.</p>
PHP Solution in Windows Azure
8 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
<p>The Windows Azure Companion aims to provide a seamless experience for deploying platform-level components as well as applications on to Windows Azure. The first community preview of the Windows Azure Companion has been tested with PHP runtimes, frameworks, and applications. However, the system may be extended to be used for deploying any component or application that has been tested to run on Windows Azure.</p>" /> <!-- Windows Azure Storage Account Details. --> <Setting name="WindowsAzureStorageAccountName" value="*****" /> <Setting name="WindowsAzureStorageAccountKey" value="*****" /> <!-- Admin user name, password and e-mail. Please user strong username and password --> <Setting name="AdminUserName" value="*****" /> <Setting name="AdminPassword" value="*****" /> <Setting name="AdminEmail" value="*****@*****.***" /> <!-- Atom Feed for Product items to be installed. This URL should be internet addressable --> <Setting name="ProductListXmlFeed" value="*****" /> <!-- Settings for Windows Azure Drive used for durability --> <Setting name="PHPApplicationsBackupContainerName" value="phpapps" /> <Setting name="InstallationStatusConfigFileBlob" value="status.xml" /> <Setting name="ProgressInformationFileBlob" value="progress.xml" /> <Setting name="XDrivePageBlobName" value="backup.vhd" /> <Setting name="XDriveSizeInMB" value="2000" /> <!-- Max value is defined as 500 in ServiceDefinition.csdef file (XDriveLocalCache Local Resource) --> <!-- Windows Azure Drive size is defined in ServiceDefinition.csdef. Look for ApplicationsAndRuntimeResource --> <Setting name="XDriveCacheSizeInMB" value="500" /> <!-- Diagnostics and Performance Counter Capture Frequency in minutes --> <Setting name="DiagnosticsAndPerformanceCounterCaptureFrequencyInMinutes" value="1" /> <!-- Make sure that this HttpIn is same as that of HttpIn InputEndpoint in ServiceDefinition.csdef --> <Setting name="HttpIn" value="80" /> <!-- MachineKey setting with ASP.NET machineKey XML. You can generate an XML element with http://www.developmentnow.com/articles/machinekey_generator.aspx --> <Setting name="machineKeyElement" value="<machineKey validationKey="F80F3A81BCF22C2CA0C0167E26AC477FAD18EE946F5B330BC394DC6819CCB43D4B7C88CFA9CA071719E214E548A1085B96B927ADA025D4C054DCAEAF3C54B1CC" decryptionKey="A82434E6F99C1ECC3E20675D57A88EE5E7325E816F87323C5CD503D1B6670A23" validation="SHA1" decryption="AES" />" /> </ConfigurationSettings> </Role>
PHP Solution in Windows Azure
9 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
</ServiceConfiguration>
Based on cscfg contents we can keep them it 3 editable categories:
1. Must Edit Category
<!-- Application Details. Title and Welcome text --> <Setting name="ApplicationTitle" value="Windows Azure Companion" /> <Setting name="ApplicationDescription" value="<p>The <span”/> <!-- Windows Azure Storage Account Details. --> <Setting name="WindowsAzureStorageAccountName" value="*****" /> <Setting name="WindowsAzureStorageAccountKey" value="*****" /> <!-- Admin user name, password and e-mail. Please user strong username and password --> <Setting name="AdminUserName" value="*****" /> <Setting name="AdminPassword" value="*****" /> <Setting name="AdminEmail" value="*****@*****.***" /> <!-- Atom Feed for Product items to be installed. This URL should be internet addressable --> <Setting name="ProductListXmlFeed" value="*****" />
2. Suggested Edit Category:
<!-- Windows Azure Companion does not support multiple instances yet. Please do not change this count. -->
<Instances count="1" />
<!-- MachineKey setting with ASP.NET machineKey XML. You can generate an XML element with http://www.developmentnow.com/articles/machinekey_generator.aspx --> <Setting name="machineKeyElement" value="<machineKey validationKey="F80F3A81BCF22C2CA0C0167E26AC477FAD18EE946F5B330BC394DC6819CCB43D4B7C88CFA9CA071719E214E548A1085B96B927ADA025D4C054DCAEAF3C54B1CC" decryptionKey="A82434E6F99C1ECC3E20675D57A88EE5E7325E816F87323C5CD503D1B6670A23" validation="SHA1" decryption="AES" />" />
3. Optional Editable Category
Rest of the settings you can edit per your requirement or not.
PHP Solution in Windows Azure
10 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
General Application Settings:
Setting Application Title:
<Setting name="ApplicationTitle" value="My PHP Service on Azure" />
Setting Application Description:
<Setting name="ApplicationDescription" value=”This is my PHP Test Service”/>
Azure Storage Settings:
Setting Azure Storage Account Name:
<Setting name="WindowsAzureStorageAccountName" value=" happybuddha" />
Setting Azure Storage Account Name:
<Setting name="WindowsAzureStorageAccountKey" value="
dyjrnWG0/ibgI4k9/j6DSZqyhCK5QlZDVYgwqyFqrH8IXW8od9XY1s1TyiDB+1nPCLrT2LOrx34Tyhm
sI7YyVg==" />
PHP Administration Settings:
Setting PHP Admin Account User Name:
<Setting name="AdminUserName" value="Avkash" />
Setting PHP Admin Account Password:
PHP Solution in Windows Azure
11 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
<Setting name="AdminPassword" value="AvkashAvkash" />
Setting PHP Admin Account Email Address:
<Setting name="AdminEmail" value="[email protected]" />
PHP Applications XML Feed:
This is a very important feature of Azure companion in which you will create an application feed
XML and add your PHP related product in this feed format so you can install on Azure instantly
as soon as the service is ready.
Application Feed Schema Please refer to the WACompanionFeedSchema.pdf for detailed documentation of the application feed schema used by the Windows Azure Companion.
Please use the following value as your XML Feed to start you work: http://wazstorage.blob.core.windows.net/azurecompanion/default/WindowsAzureCompanionFeed.xml
PHP Product List XML Feed Setting:
<Setting name="ProductListXmlFeed" value="
http://wazstorage.blob.core.windows.net/azurecompanion/default/WindowsAzureCompanion
Feed.xml" />
In Chapter “Creating PHP Products XML Feed” I have shown how you can create your own XML
Feed.
If you will look for what is in the XML Feed you will see the following applications:
PHP Runtime
PHP Wincache Extension
Microsoft Drivers for PHP for SQL Server
MariaDB
Windows Azure SDK for PHP
phpBB
Wordpress
phpMyAdmin
eXtplore File Manager
PHP Solution in Windows Azure
12 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
So after above modification, your cscfg modified content going to look like as below:
<Setting name="ApplicationTitle" value="My PHP Service on Azure" /> <Setting name="ApplicationDescription" value=”This is my PHP Test Service”/> <Setting name="WindowsAzureStorageAccountName" value=" happybuddha" /> <Setting name="WindowsAzureStorageAccountKey" value=" dyjrnWG0/ibgI4k9/j6DSZqyhCK5QlZDVYgwqyFqrH8IXW8od9XY1s1TyiDB+1nPCLrT2LOrx34TyhmsI7YyVg==" /> <Setting name="AdminUserName" value="Avkash" /> <Setting name="AdminPassword" value="AvkashAvkash" /> <Setting name="AdminEmail" value="[email protected]" /> <Setting name="ProductListXmlFeed" value="
http://wazstorage.blob.core.windows.net/azurecompanion/default/WindowsAzureCompanionFeed.xml" />
PHP Solution in Windows Azure
13 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
First I have created an Azure service name “PHPAzure” on Windows Azure portal. The account looks like
as below:
The service URL will be as below:
http://php-azure.cloudapp.net
Now I will upload cspkg and cscfg in the staging slot:
PHP Solution in Windows Azure
14 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Once deployment is done and you can see the Ready sign next to your role as below:
PHP Solution in Windows Azure
15 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Let’s launch the web URL: http://php-azure.cloudapp.net
You will see that there is no content on the web page. Actually it is expected!! Now let’s launch the
service in admin mode using the same URL on port 8080:
http://php-azure.cloudapp.net:8080/
Actually the PHP Administration is already part of PHP project and it is configured to use port 8080 to
run. If you deploy into production slot the admin URL will be as below:
http://<your_PHP_Service_name>.cloudapp.net:8080/
PHP Solution in Windows Azure
16 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
URL: http://<your_PHP_Service_name>.cloudapp.net:8080/
Now select “Admin” Tab on PHP admin page and enter user name and password which you have
configured in the cscfg as below:
<Setting name="AdminUserName" value="Avkash" /> <Setting name="AdminPassword" value="AvkashAvkash" />
If your input information is correct you will be logged into PHP Admin portal:
PHP Solution in Windows Azure
17 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
If you select any of the sub menu items i.e. PHP Logs or Corn Jobs you will not see any details as none of
the services are configured to run yet.
I would suggest looking the “Performance Monitor” sub menu to see the physical RAM pressure details:
Our next step is to configure the PHP runtime and other necessary platform modules and for this
purpose we will select “Platform” tab from the admin mode. Once PHP is ready and we need to deploy
any given PHP solution in the XML feed we will select “Applications” tab.
PHP Solution in Windows Azure
18 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Now let’s take a look at “Platform” main menu option:
Above you can see lots of option however to get the PHP running we will select the above highlighted
ones:
- RunTime
o PHP Runtime
o PHP Wincache Extension
- SDKs
o Windows Azure SDK for PHP
PHP Solution in Windows Azure
19 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Once you have marked the checkbox for the above modules in the “Platform” section please select
“Next”.
You will see the confirmation screen as below before the final installation will start. This window will
show you the selected application version which are provided in the XML feed.
Once you are satisfied with your selection please select “Accept”. You will see a progress window similar
to as below with lots of logs information about installation progress and results.
PHP Solution in Windows Azure
20 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Finally once the installation is done you will see the completion window as below:
Above you can see the installation was successful and it will also print the version and time when the
installation was completed.
Now if you go back to “Admin” option and select “Windows Azure logs” you will find detailed logs about
the installation success regarding each selected module as below:
PHP Solution in Windows Azure
21 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
As PHP runtime is installed successfully, if you launch the main service URL you can see the PHP is
successfully running.
PHP Solution in Windows Azure
22 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
To verify our service is running we can launch the main service URL.
PHP Web Service URL: http://<Your_Service_URL>.cloudapp.net
In our case the URL is: http://php-azure.cloudapp.net as below:
You might wonder how and form where this page contents are coming, then you will have to wait a little
more. Later I have explained everything on this regard.
This page is actually a very powerful php function as below:
<?php phpinfo() ?>
Now as PHP is service is running we can use Application tab to install the applications as provided in the
XML feed. Please select the “Application” tab from PHP administration section:
You will see the XML feed we select comes with 3 applications and 1 utility as below:
PHP Solution in Windows Azure
23 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
We will not install any application here however we will install the eXtplorer utility which will be very
helpful to manage our service.
So please mark the “eXtplorer” utility checkbox and select “Next”:
PHP Solution in Windows Azure
24 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
You will see the confirmation window as below:
- It shows that eXtplorer version 2.1.0RC1 is going to install in /extplorer folder
Once installation is started you will see the progress window:
And once installation is completed you can see confirmation as below:
PHP Solution in Windows Azure
25 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
You can launch eXtplorer as below:
eXtplorer URL: http://<Your_Service_URL>.cloudapp.net/extplorer
The default user name and password for eXtplorer is admin/admin so please enter it correctly.
Once you have select the username and password, please select “Login” and you will see the eXtplorer
shell opened in the same window with important notification as below:
PHP Solution in Windows Azure
26 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
The notification is the change your password because using this utility anyone can modify your PHP
application files and their contents.
Select “OK” in the above window and you will see the “Change password” window appeared as below:
Please input your desired new password and then go ahead and select “Change”. Here you can also add
more users to your website just by selecting the “Users” tab in the “Administration” dialog window.
Once password is changed to new password i.e. “password” you will see the eXtplorer shell running as
below:
PHP Solution in Windows Azure
27 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
If you remember the php main page at php-azure.cloudapp.net as below is actually rendered from the
file phpinfo.php from the file location seen in eXtplorer.
Utility eXtplorer is a tool to add/remove files and folder in your PHP service in real time. We can see
from the example.
PHP Solution in Windows Azure
28 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Example: Uploading a file from local machine to Azure
1. Let’s create a php file name echo in local machine:
2. Copying the file to PHP Service
PHP Solution in Windows Azure
29 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
PHP Solution in Windows Azure
30 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
PHP Solution in Windows Azure
31 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
3. Now launching the file in web browser:
Example: Downloading file from local machine to Azure
1. Selecting the file in the list and then select “Download” button:
Depend on your web browser either you will be prompt to save the file on a certain location or
the file will be downloaded to predefined folder on your local machine.
PHP Solution in Windows Azure
32 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Example: Editing a file on Azure
1. Select the file in the list and then press “Edit” button:
2. You will see that the file is opened in the editor as below:
As you can see I have added on more line to it.
PHP Solution in Windows Azure
33 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
3. Now save the file using the “Save” button and you will see the “Success” message as below:
4. Now launch the file in browser to see the changes:
Please spend some to familiar with the eXtplorer tool bar as below:
When you are done pleae logout using the logout button as below:
Note: While writing this tutorial IE9 was not supported with eXtplorer so please use older IE for it.
PHP Solution in Windows Azure
34 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Now we will learn how to create an XML feed for your project.
Please refer to the WACompanionFeedSchema.pdf for detailed documentation of the application feed
schema used by the Windows Azure Companion.
Here I will show you how you will create a new feed XML for your project and add necessary modules
needed for our project.
Things to need:
1. Your complete PHP project in a zip file uploaded to an internet location which is directly
downloadable
2. If you want to add a license file with your project then it should also be available on internet
location which is directly accessible
Creating a PHP Project:
I have a php file name hello.php and an image Avkash.jpg as below and the hello.php file shows the
Avkash.jpg image when launched.
PHP Solution in Windows Azure
35 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Creating the PHP Project ZIP file:
Now I have created a zip name ShowImagePhp.zip which contains hello.php and Avkash.jpg both files in
the zip file as below:
Creating a license file: I have created a license file as “ShowImagePHPLicense.txt” as below:
Uploading PHP Project ZIP and License file on Azure Storage: Our next step is to upload these files to a public storage location from where I can download. As you remember we already have created an Azure storage name “happybuddha” so we can use the same Azure Storage. I create a new container name “projectfiles” and then copied both files in this container.
PHP Solution in Windows Azure
36 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
As you can see both the files in the following “CloudBerry Explorer for Azure Blob Storage” view of my happybuddha storage and projectfiles container:
So based on above we can get the following URL for:
1. Project ZIP URL http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHP.zip
2. Project License file URL http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHPLicense.txt Note: Please verify that the above links are working properly.
Now we will create an entry for our project so before we go further let’s decided what is needed:
1. Product ID 2. Product Category 3. Install Category 4. Product Title 5. Product Summary 6. Product Tab (in which this application will be listed on PHP Admin page) 7. Product License URL 8. Product Installation properties 9. Product installer location 10. Product Dependencies (This is needed to install other products first )
So based on our project we have the following:
1. Product ID : ShowImagePHP 2. Product Category: Web Applications 3. Install Category: Web Applications 4. Product Title: Show Image PHP Application
PHP Solution in Windows Azure
37 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
5. Product Summary: This is sample PHP project to show the Feed XML 6. Product Tab: Applications 7. Product License URL:
http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHPLicense.txt 8. Product Installation properties:
/ShowImagePHP 9. Product installer location:
http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHP.zip 10. Product Dependencies: (Because this is a PHP web site so it will need PHP runtime at minimum)
PHP_Runtime Based on above details the Entry XML will look like as below:
<entry> <productId>ShowImagePHP</productId> <productCategory>Web Applications</productCategory> <installCategory>Web Applications</installCategory> <updated>2010-10-14T12:00:00Z</updated> <title>Show Image PHP Application</title> <tabName>Applications</tabName> <summary>This is sample PHP project to show the Feed XML</summary> <licenseURL>http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHPLicense.txt</licenseURL> <productProperties> <productProperty name="installPath" caption="Installation Path" defaultValue="/ShowImagePHP" /> </productProperties> <installerFileChoices> <installerFile version="1.0" url="http://happybuddha.blob.core.windows.net/projectfiles/ShowImagePHP.zip" /> </installerFileChoices> <dependencies>PHP_Runtime</dependencies> </entry>
Our next step is to create a feed where our PHP application is visible to PHP service so we can install the
same way we have installed “PHP Runtime” and ““eXtplorer” previously. Here is what we will do
1. We will use the same default PHP companion XML Feed so first we will download it
2. We will add our entry to the same XML and same as a new name
3. Then we will upload this to a Azure Storage location so it is available on internet
4. Finally we will modify the CSCFG file with the new path of XML Feed location so our application
is available to install
Creating XML Feed XML for our project:
First lets download the default XML feed form the given below Azure companion Location and save it to
local machine and open in VS2010 for editing because we need to add our entry in this XML.
PHP Solution in Windows Azure
38 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
http://wazstorage.blob.core.windows.net/azurecompanion/default/WindowsAzureCompanionFeed.xml
As you can see below I have added our Entry content to this XML:
Now I have saved this file to a new XML file as:
WindowsAzureCompanionFeedAvkash.xml
PHP Solution in Windows Azure
39 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
My next step is to upload this file to Azure Storage “happybuddha” and then get the web URL for it.
The web URL for our XML Feed is as below: http://happybuddha.blob.core.windows.net/projectfiles/WindowsAzureCompanionFeedAvkash.xml Now opening this XML Feed in IE we can see our PHP Project at the top as below:
PHP Solution in Windows Azure
40 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Editing ServiceConfiguration.cscfg
Now let’s go back to ServiceConfiguration.cscfg and add the xml feed location as blow:
<Setting name="ApplicationTitle" value="My PHP Service on Azure" /> <Setting name="ApplicationDescription" value=”This is my PHP Test Service”/> <Setting name="WindowsAzureStorageAccountName" value=" happybuddha" /> <Setting name="WindowsAzureStorageAccountKey" value=" dyjrnWG0/ibgI4k9/j6DSZqyhCK5QlZDVYgwqyFqrH8IXW8od9XY1s1TyiDB+1nPCLrT2LOrx34TyhmsI7YyVg==" /> <Setting name="AdminUserName" value="Avkash" /> <Setting name="AdminPassword" value="AvkashAvkash" /> <Setting name="AdminEmail" value="[email protected]" /> <Setting name="ProductListXmlFeed" value="
http://happybuddha.blob.core.windows.net/projectfiles/WindowsAzureCompanionFeedAvkash.xml" />
So above we have the final modified ServiceConfiguration.cscfg.
There are other parameters in this file so you can edit them per your convenience.
PHP Solution in Windows Azure
41 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
To update the Service Configuration we can just update the configuration only and we don’t need to
republish the CSPKG.
Once we decided to update the configuration, please be sure that you don’t have any application
running anywhere and if yes then please close all PHP services.
1. Let’s suspend the service first
2. After service is suspended select “Configure”
PHP Solution in Windows Azure
42 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
3. Now “browse” our updated ServiceConfiguration.cscfg and upload it:
4. Please verify that the update XML Feed is visible there as below:
PHP Solution in Windows Azure
43 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
5. Once you are sure then select “Save” button the confirm the configuration update.
6. You will see that the Service update is in progress
PHP Solution in Windows Azure
44 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
7. Once the deployment is updated completely then you can start the service by select “Run”:
8. Now when the service is ready please let run the service in Admin mode to check your sample
application.
PHP Solution in Windows Azure
45 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
After the service is ready launch the below web URL brings the previous running content and this is
because we have already installed PHP runtime and eXtprorer earlier and because the VHD is still the
same so everything installed previously is still accessible.
http://php-azure.cloudapp.net/
Now let’s go to admin mode to verify our “PHP Sample Application” is visible so we can install it:
(I have edited the above image to show only sample PHP project on top otherwise it will be listed below
other PHP Web Applications.)
PHP Solution in Windows Azure
46 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Now please mark “check” the “Show Image PHP Application” checkbox and then select “Next”:
Above you can see that it is installing version 1.0 at the location “ShowImagePHP”. Once we verified the
info please select “Accept”.
You will see that the project ZIP is being download..
And when the installation is done the service will show the completion status as below:
PHP Solution in Windows Azure
47 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Now we can view our “Show Image PHP Project” on Azure as given URL:
http://php-azure.cloudapp.net/showImagePHP/hello.php
Now if you try the following URL you will see that this does not have render any web content:
http://php-azure.cloudapp.net/showImagePHP/
PHP Solution in Windows Azure
48 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
The error occurred because when you launch a web site from a folder it tries to launch the default
settings page i.e. index.asp or index.php or default.php etc. Because we had only hello.php in our
project zip and didn’t have any other default page, that’s why we see the above error.
So let’s add the index.php to solve this problem.
Open the eXtplorer shell and then go to our project folder name “ShowImagePHP” as below:
Then select the “New File/Dir” Icon:
Enter the file name “index.php” and select the type “File” and press “Create” button.
PHP Solution in Windows Azure
49 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Once file is created please select the index.php from the list and press “Edit” button. The file will open in
the editor window. Please type the following text in it:
Once you are done editing please select “Save” button at the top bar to save the file.
After you save the file, you can see the content in web url as below:
Once you select the “Show Image” hyperlink you can see the content as below:
PHP Solution in Windows Azure
50 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
To stop PHP service, please go to administrator mode select “Configure Runtime”:
Select “Stop” to stop the service
Select “Restart” to start the service which will stop and then restart the service.
PHP Solution in Windows Azure
51 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
If you wish to change the PHP runtime behavior you can do as below:
1. Stop the service
2. Modify PHP.INI
3. Restart the service
To modify the PHP.INI please go the Administrator mode and select “Configure Runtime”
After modifying the PHP.INI please select “Update”.
After it please restart the service.
PHP Solution in Windows Azure
52 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Resetting means removing everything you have configured on Azure VHD and clearing as the service
back to same as original setting when you started service first time.
To reset the solution please go to Administrator mode and then select “Backup and Cleanup”.
Then select “Reset”:
As this process will remove everything on VHD it will take long time so be patience.
PHP Solution in Windows Azure
53 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
During your PHP project development it is possible that you may have to modify your project or update
the full project.
To Delete a PHP web application:
There is no turnkey or just “select and click” functionality to delete a PHP web application once installed
by administrator. To delete a PHP web application you can try any or combination of the following:
1. Full Reset the Service
2. User eXtplorer to manually delete the PHP web application
3. Stop the Azure Service and then delete the VHD on Azure Storage
To Update a PHP web application:
If you wanted to update a project you have a few options as below:
1. Deploy the new ZIP using:
a. First Stop the Azure Service
b. Delete the VHD at Azure Storage by removing phpapps folder.
c. Update PHP Web Application Zip
i. Either Update the XML Feed with new updated ZIP location
ii. Update the same ZIP file with updated content
d. Update the Configuration on Azure Portal
e. Restart the service
2. Use eXtplorer to add your project however
a. It might be cumbersome if you have lots of files to deploy
b. It is very good to edit content of something within your files i.e. settings etc.
PHP Solution in Windows Azure
54 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
You might wonder about what the Azure Storage role is, in this over all solution. To start with I would
suggest you to look at your Azure Storage which you have used in this application for any clue:
Below you can see in the Azure Storage a new container name “phpapps” is created:
Opening phpapps I see the following:
Looking above gives you an idea that the PHP solution creates this VHD on Azure Storage and all PHP
platforms, applications, utilities etc are installed in this VHD. This VHD is mounted with the service so
when we access the PHP the application installed on this VHD is visible to us. So when you use web URL
http://<your_php_service>.cloudapp.net the filed located on this VHD actually renders on IE.
The PHP admin component (which runs on port 8080) is actually written in ASP.NET which we will dig
more in Azure Companion source code study.
PHP Solution in Windows Azure
55 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Please download the WindowsAzureCompanion-Source-Sep2010CTP.zip from the link below:
http://code.msdn.microsoft.com/azurecompanion/Release/ProjectReleases.aspx?ReleaseId=4956
After unzipping the project you will see the solution as below on your machine:
Opening this project in VS2010 we see that the full solution consists of 4 components:
Here I will show you a few source locations which are important to understand the solution
architecture:
PHP Solution in Windows Azure
56 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
Azure Companion Administrator Application:
WorkerRole\WorkerRole.cs
// Start ASP .NET Admin WebSite private void StartAdminWebSite()
Running PHP in Hostable Web Core:
VMManagerService\WindowsAzureVMManager.cs
public static string HWCForPHPProcessName = "HWCForPHP.exe";
VMManagerService\WindowsAzureVMManager.cs
// setting the file name and arguments hwcServerProcess.StartInfo.FileName = Path.Combine(approot,
WindowsAzureVMManager.HWCForPHPProcessName); hwcServerProcess.StartInfo.Arguments = Path.Combine(configPath, "php_applicationHost.config") + " " + Path.Combine(configPath, "php_web.config"); hwcServerProcess.Start(); // Start the asynchronous read of the output stream. hwcServerProcess.BeginOutputReadLine(); Trace.TraceInformation("Started Hosted Web Core Server for PHP Applications
on port {0}", endpoint.Port.ToString());
Performance Counter for RAM utilization:
WorkerRole\WorkerRole.cs
// Add performance counter monitoring cfg.PerformanceCounters.DataSources.Add( new PerformanceCounterConfiguration() { CounterSpecifier = @"\Processor(_Total)\% Processor Time",
PHP Solution in Windows Azure
57 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
SampleRate = timeSpan }); cfg.PerformanceCounters.DataSources.Add( new PerformanceCounterConfiguration() { CounterSpecifier = @"\Memory\Available Mbytes", SampleRate = timeSpan }); cfg.PerformanceCounters.ScheduledTransferPeriod = timeSpan;
Cloud Drive is created and backup.vhd is mounted:
VMManagerService\WindowsAzureVMManager.cs
// Get Windows Azure Drive container and blob names from service configuration file string xdriveContainerName = RoleEnvironment.GetConfigurationSettingValue("PHPApplicationsBackupContainerName"); string xdriveBlobName = RoleEnvironment.GetConfigurationSettingValue("XDrivePageBlobName");
Modifying Cloud Drive name, size etc:
ServiceConfiguration.cscfg
<!-- Settings for Windows Azure Drive used for durability --> <Setting name="PHPApplicationsBackupContainerName" value="phpapps" /> <Setting name="InstallationStatusConfigFileBlob" value="status.xml" /> <Setting name="ProgressInformationFileBlob" value="progress.xml" /> <Setting name="XDrivePageBlobName" value="backup.vhd" /> <Setting name="XDriveSizeInMB" value="2000" />
PHP Solution in Windows Azure
58 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
After copying the VHD to local machine and then mounting it to machine you can see it is all the
modules i.e. platform, web application and utilities, you installed when you ran the service in the admin
mode.
First I download the backup.vhd to my local machine.
There are several ways you can attach a VHD to your machine so once you have attached you can open
the VHD in Windows Explorer:
PHP Solution in Windows Azure
59 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
So the PHP runtime is installed on the root php folder. Opening application folder we can see:
Above we can see that all the application and utility installation were done in the application folder.
This way you can look around to file. You can also update the contents in the VHD and update back to
Azure Storage when Azure Service is stopped.
PHP Solution in Windows Azure
60 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
[1] Service does not show any content
Reason: It means the PHP is not configured yet.
Solution: Please configure the PHP Runtime first to get the PHP Working on your Service.
[2] HTTP Error 404.0 - Not found
If you meet error when launching the service:
Reason: The VHD could not mount that’s why the files are not available.
Solution:
PHP Solution in Windows Azure
61 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
1. Make sure that your Azure Storage used in this PHP solution, must not be used in other PHP
solutions otherwise the VHD may be mounted with other service and you could not use in this
service
2. If you have verified that this is the only service use the VHD and if you still see the error then
give some time to get the VHD mounted. I found that sometime the VHD mount takes longer
than expected and it could cause this error.
[3] “Installation Failed Error: Could not find a part of the path ‘B:\php’.
When you try to install any application or utility from PHP Administration site you might get error below:
Reason: It means you are hitting error #2.
Solution:
1. Try to check if the service is active using service web url as:
http://<your_php_service>.cloudapp.net
2. Follow all other suggestions given in error #2.
PHP Solution in Windows Azure
62 W i n d o w s A z u r e L e a r n i n g S e r i e s 2 0 1 0
PHP Solution in Windows Azure