Deploying your PHP / apache webapp in under a minute with Hasura
This post will help you deploy a webapp that you’re writing with PHP and apache onto the cloud in just a few clicks.
- You know
- You know how to get your
sshkey that git uses (eg: if you set up a github account and are able to git push to your github repo without entering a password every time, you already know this. But here’s a reference in case you don’t).
1. Create a Hasura project
2. Login to your console and add your SSH key
Login to your project console using the credentials you would have received over email once you activated the project.
Now get your SSH key. Here are some examples of how you could get your SSH key on different OSes:
Once you have your SSH key, paste it into the console by heading to the advanced section (click on the ⚙ icon on the left sidebar):
3. Setup a php-apache based git repo for your work
3.1 Clone the quickstart repo to your computer: https://github.com/hasura/quickstart-docker-git
3.2 Copy the php-apache folder to create your own app folder
cp -r quickstart-docker-git/php-apache webapp
3.3 Initialise a new git repo in your own app folder
git add .
git commit -am 'Adds base repo files'
This app folder contains a basic ‘Hello world’ HTML webapp. You can see the source files in:
app/src. Eg: the HTML file is:
4. Create a subdomain on your hasura project for your webapp
Head to the create service section (click on the ➕ icon the sidebar) and add a service as shown on the left.
After you click on create, you will automatically be redirected to the manage
5. Git push and deploy your webapp
5.1 Head to your git repo (webapp) that you created in step 3
5.2 Add a new git remote
Copy the git remote command from the manage app page. In this case, my project is lumber59, and so:
git remote add hasura ssh://email@example.com/~/git/app/
5.3 Push this git repo to hasura
git push hasura master
This is what a successful git push will look like on the terminal:
5.4 Check out your deployed app:
app.<project-name>.hasura-app.io. In my case, I head to: https://app.lumber59.hasura-app.io/
6. Make a change and deploy again
To make a change to your project, change files in the
app/src/ directory. For eg, I changed
app/src/index.php and added another key to the JSON object that is
Commit and push again:
git commit -a 'Made some new changes'
git push hasura master
And after a successful push, your app will be live again: