Deploying PHP and Mysql Apps on Heroku
This tutorial will help you deploying a PHP and Mysql app. Prerequisites a free Heroku account. PHP installed locally. Composer installed locally. Set up In this step you will install the Heroku Toolbelt. This provides you access to the Heroku Command Line Interface (CLI), which can be used for managing and scaling your applications and add-ons. To install the Toolbelt for ubuntu/Debian wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh After installing Toolbelt you can use the heroku command from your command shell. $ heroku login Enter your Heroku credentials. Email: dz@example.com Password: ... Authenticating is required to allow both the heroku and git commands to operate. Prepare the app In this step, you will prepare a fossasia/engelsystem application that can be deployed. To clone the sample application so that you have a local version of the code that you can then deploy to Heroku, execute the following commands in your local command shell or terminal: $ git clone --recursive https://github.com/fossasia/engelsystem.git $ cd engelsystem/ If it is not a git repository you follow these steps $ cd engelsystem/ $ git init You now have a functioning git repository that contains a simple application now we need to add a composer.json file. Make sure you’ve installed Composer. The Heroku PHP Support will be applied to applications only when the application has a file named composer.json in the root directory. Even if an application has no Composer dependencies, it must include at least an empty ({}) composer.json in order to be recognized as a PHP application. When Heroku recognizes a PHP application, it will respond accordingly during a push: $ git push heroku master -----> PHP app detected … Define a Procfile A Procfile is a text file in the root directory of your application that defines process types and explicitly declares what command should be executed to start your app. Your Procfile will look something like this for engelsystem: web: vendor/bin/heroku-php-apache2 public/ Since our folder named public that contains your JavaScript, CSS, images and index.php file, your Procfile would define the Apache web server with that directory used as document root. Create the app In this step you will create the app to Heroku. Create an app on Heroku, which prepares Heroku to receive your source code: $ heroku create Creating sharp-rain-871... done, stack is cedar-14 http://sharp-rain-871.herokuapp.com/ | https://git.heroku.com/sharp-rain-871.git Git remote heroku added When you create an app, a git remote (called heroku) is also created and associated with your local git repository. Heroku generates a random name (in this case sharp-rain-871) for your app, or you can pass a parameter to specify your own app name. But Once you open http://sharp-rain-871.herokuapp.com/ we will not be able to view the site if there are database connections. We need to migrate the database using Cleardb ClearDB MySQL Migrating database Creating your ClearDB database To create your ClearDB database, simply type the following Heroku command: $ heroku addons:create cleardb:ignite -----> Adding cleardb to sharp-mountain-4005... done, v18 (free) This will automatically provision your new ClearDB database for…
