• Home
  • blog
  • The Ultimate Guide to Deploying PHP Apps in the Cloud

The Ultimate Guide to Deploying PHP Apps in the Cloud

TL;DR: There is a popular mantra amongst developers that goes like this write, test and deploy. In this tutorial, I’ll show you how to deploy your PHP apps to different cloud server platforms such as Google Cloud, Microsoft Azure, Heroku, IBM Bluemix, and others.

Introduction to Cloud Servers

Cloud servers are basically virtual servers that run within a cloud computing environment. There are various benefits to hosting and deploying your applications in the cloud. They are:

  • Economically efficient.
  • You have the freedom to modify the server software to your needs.
  • Cloud servers scale very well.
  • Stability and security.

In fact, many companies have moved their infrastructure to the cloud in order to reduce cost and complexity. It’s a great option for small, mid-sized, and enterprise scale businesses. If you write a lot of tutorials and do POCs (Proof-of-concepts) like me, it’s also a great choice for you!

A generic PHP application involves the common LAMP (Linux, Apache, Mysql and PHP) stack.

  • Linux: The operating system that runs the other software packages.
  • Apache: The web server that runs the PHP code. A popular alternative software is Nginx.
  • MySQL: The database. A popular alternative software is PostgreSQL.
  • PHP: The server-side language for building the application.

For a crash course on LAMP / MAMP / WAMP, see this premium resource.

Now let’s cover how to deploy PHP applications to several cloud server platforms.


Heroku is a cloud platform that helps you deploy and host your applications the modern way. It does all the heavy-lifting for you. Let’s quickly take a look at how to deploy and maintain a PHP application on heroku.

PHP-Heroku Architecture
PHP Heroku Architecture

If you don’t have an account, go ahead and create one on Then go ahead and install the heroku cli. Once you have that installed, clone this simple starwars PHP application.

Heroku runs your PHP app in a dyno, a smart container which provides a modern stack with your choice of web server (Apache or Nginx) and runtime (PHP or HHVM).

Make sure you follow these steps below:

  • Create a .env file from .env.example.
  • You need to have an account with Auth0.
  • Go to your Auth0 Dashboard and click the “create a new client” button.
  • Name your new app and select “Regular Web Applications”.
  • In the Settings for your new Auth0 client app, add http://localhost:8000 to the Allowed Callback URLs.
  • Copy out your client id, client secret, domain and callback url. Ensure you assign them to the right variables in your .env file.

We have a composer.json file which contains the list of packages that the application needs. Go ahead and run composer install on your local machine to install these packages. Not familiar with Composer? This video might help.

Go ahead and run the app. The app should be running like so:

Landing page
Landing page

Logged In User
Logged In User

Awesome! Our app works locally. Time to deploy! The first thing we’ll do is to add a Procfile to the root directory of our app.

Continue reading %The Ultimate Guide to Deploying PHP Apps in the Cloud%