Publish PHP application as Windows Azure Cloud service

Source: Internet
Author: User
Keywords Php azure azure
Tags aliyun application applications cloud cloud service different directory download

Website is easy to use, but sometimes we want to get more flexibility, such as the need for special PHP plug-ins, the need for different versions of PHP, or the need to run other processes, and even want to log on to the target virtual machine. At this point, you can use the cloud service to run PHP applications. The Cloud service is a group of http://www.aliyun.com/zixun/aggregation/13357.html ">azure managed virtual machines running Windows operating systems, And the IIS and PHP runtime environments are loaded, enabling ASP and PHP to run. When PHP publishes to website, use FTP to upload code. When using cloud service, the upload process is slightly different. You need to use the Azure tool to package when uploading. Take a look at the specific steps below.

The tool can only run under Windows. Download the install Windows Azure SDK for PHP from here. The tool includes a local azure emulator and power shell tool. After installation, locate the Windows Azure PowerShell program in the Start menu to run as an administrator

The next step is to publish. First, generate a corresponding cloud service application for this PHP application

C:\>new-azureserviceproject MyProject

The operation generates a directory under C:\ that contains the basic files for the service, such as the service definition Servicedefinition.csdef and the service configuration information ServiceConfiguration.Cloud.cscfg. They define that the service is composed of several roles, each with several virtual machines, and various variable information. Any cloud service is composed of one or more roles (role). A role represents a set of virtual machines with the same functionality. For example, a PHP site has a previous Web page and a batch program at the back end, so we can define two role, respectively, Webrole and Workerrole.

Next you can build a role

C:\myproject> Add-azurephpwebrole Mywebrole

This will generate a directory in the current directory containing the files that the role contains, with only index.php and a bin directory in the new build. Where index.php is the display of current PHP environment information. The bin directory is some of the scripts required by Azure for system configuration, and we can take care of it. We can copy the existing PHP application code to the role directory (C:\myProject\MyWebRole)

Before uploading the application to azure, we can test it locally. Start the emulator locally

C:\myproject>start-azureemulator

You can see the following output:

Creating local package ... Starting emulator ... Role is running at http://127.0.0.1:81Started

Then open the browser to access the address given above to test. The following command can end debugging

C:\myproject> Stop-azureemulator

When the test is complete, the final release begins. We have to associate with Azure subscriptions first when we publish. Execute the following command:

C:\myproject>get-azurepublishsettingsfile

The operation opens a browser and prompts you to log in to Azure. After entering the login information, a download dialog box pops up. Download the file locally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.