Click here to Skip to main content
15,867,308 members
Articles / DevOps / Git

Getting started with PHP on Azure

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
17 May 2016CPOL6 min read 17.3K   4   3
How to host PHP application on Azure and how to auto-deploy the code through bitbucket.

Introduction

Hello Everyone, today let's make ourselves ready to learn a new topic i.e. hosting PHP application on Azure. Many of us must have came across the word Azure and some of us must be knowing how to host the application written in PHP on it. Today we will go over how to host the application on Azure and how to auto-deploy the code through bitbucket. So, why to wait !! Lets start then :).

Background

In this blog, we will mainly come across these following words.
1. PHP
2. Microsoft Azure
3. Bitbucket

 

1. PHP :-

Quote:

"PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language." - wiki

The word PHP i.e. Hypertext Preprocessor earlier called as Personal Home Page. In 1994, Rasmus Lerdorf created this pretty language and in 1995, it came into existence as an open source technology. Because of its simplicity (as most of the syntax resembles to C, C++, Java), it is much popular in web development market and among the developers. One can take 100% advantage of using this language to make dynamic web pages quickly. It is a server side scripting language. Server side, as the name suggests, it runs on a web server and it requires a web browser to send/receive request/response. Scripting language, as the name suggests, it is only compiled when an interpreter reads it and convert it into machine understandable language.

But, first and foremost thing why developers love this technology is easy to learn, free of cost, platform independent and secure.

 

2. Microsoft Azure :-

Quote:

“Microsoft Azure is a cloud computing platform and infrastructure created by Microsoft for building, deploying, and managing applications and services through a global network of Microsoft-managed data centers.” – wiki

The name Azure suggests, bright blue in colour like a cloudless sky. But in our context, this is little different :D. It is a platform which provides PaaS (Platform as a Service) and IaaS (Infrastructure as a Service) categories of cloud computing services. It supports many different programming languages including Microsoft and non-Microsoft related technologies. Azure was launched on 1st February 2010 as Windows Azure and then acquired the name as Microsoft Azure on 25th March 2014.

It is easy to publish and manage websites with PaaS environment. Mostly used for cloud computing, which literally means of using network to manage data, process and store which is hosted on remote servers rather than a local or personal server.

 

3. Bitbucket :-

Quote:

“Bitbucket is a web-based hosting service for projects that use either the Mercurial (since launch) or Git (since October 2011) revision control systems.” – wiki

I hope everyone here are familiar with GIT, the version control system which is used for data integrity and support for distributed workflows. It is used to manage source code and the name satisfies as SCM, Source Code Management.

Bitbucket is the solution for professional teams who uses GIT. It offers hosting source code in free of cost and it has the option to add wikis for project & option to track issues. It is similar to Github which is used to manage the code for a distributed application.

 

Using the steps

Now, let’s start with setting up and host a PHP application on Azure.
 
 
Step 1 :- 
 
First, we need to login into the account on Azure Portal. For that, we need to provide work or school or personal Microsoft account, otherwise need to create a new Microsoft account without any cost.

Once you successfully logged in into the system, it will redirect into Azure Portal page. See the below image for reference.

 

Step 2 :- 

Now, click on All Resources -> New button for creating the base/marketplace.

 

Then select Web App + MySQL for hosting the application. Click on Create button for creating the hosting setup.

 

Step 3 :- 

Once you click on Create button, it will open one form to provide App Name, Subscription Details, Resource Group, Database Details and Legal Terms to accept. Provide a unique App Name as the website hosting name would be app_name.azurewebsites.net and the DB details (choose Database pricing tier as Mercury, the free one) as like below.


 

Step 4 :-

Once you provide every information mentioned above, check Pin to dashboard option and click on Create. Now, it will start the process of deployment the server and it may take few time to complete the process.


 

Step 5 :-

Now lets go to Bitbucket (https://bitbucket.org/) and create the account. Do the Signup here (https://bitbucket.org/account/signup/) and you can see the Dashboard like the below once you successfully logged in into the system.

 

Step 6 :-

Inside Bitbucket, go to Repositories -> Create Repository. Provide the necessary details there like below :

 

Once you Create Repository, it will show the dashboard for Repository setup and then select “I’m starting from scratch”.

 

Step 7 :-

Open your Terminal to run some commands. Follow the rules mentioned in the above section i.e. “Set up your local directory”, “Create your first file, commit, and push”. For reference, do the following :

Set up Git on your machine if you haven’t already

Create your first file, commit, and push

  • phpinfo() >> phpinfo.php
  • git add phpinfo.php
  • git commit -m ‘Initial commit with phpinfo’
  • git push -u origin master

 

Step 8 :- 

Now time is to connect Azure with the deployment source for continuous integration. Again lets go to https://portal.azure.com and click on All Resources. Select the app we have created so far i.e. test-demo-app (type as App Service) and then choose Deployment Source from PUBLISHING section like below.

 

Step 9 :- 

Click on Choose Source and select Bitbucket as the source. Provide the Authorization details of Bitbucket. Once Authorization is completed, it will ask to choose Project and branch. Provide all the details like below.

 

Step 10 :-

After providing the details and click on OK will start the source deployment and finally it will show one flash message as Successfully set up deployment source.

 

Conclusion

We are all DONE !!! :) Now browse http://test-demo-app.azurewebsites.net/ (as we have provided the name as test-demo-app so far) and you can view the current PHP information for your server now.

Isn’t it cool & easy !!! :) So, why to wait? Create one simple PHP page and host the application into Azure along with continuous integration using git Bitbucket. Do you really find it useful? If yes, then please like and add some comments, if you want.

Thanks and I will be happy to hear from you :) :).

 

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Software engineer with around 6 years of web application development experience in open source technologies like PHP, MySQL, HTML, HTML5, CSS, CSS3, Javascript, jQuery etc.

I love to learn and share my knowledge in which manner I can and like to solve the issues as in the coding perspective. I am an active contributor in community forums like StackOverflow, CodeProject etc. Besides that, I write blogs in free time and speak in various technical community events.

Comments and Discussions

 
Questionit's nicee Pin
faizan ali28-Jun-16 20:42
faizan ali28-Jun-16 20:42 
It's awesome. Smile | :) it's a very easy way to host php application. But is there a some extra benefits to host a php application on azure rather than a linux hosting ?

modified 29-Jun-16 2:48am.

AnswerRe: it's nicee Pin
Prava-MFS6-Jul-16 22:41
professionalPrava-MFS6-Jul-16 22:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.