Sunday, January 11, 2015

A big problem for students- How to make a website live ?

I wanted to upload a simple website based on HTML, CSS and JS files, with a few images, and a favicon. So I registered at Heroku, bought a domain name, followed the Heroku instructions on how to set up the “Toolbelt” and GIT.
So I thought I was all set up: I created a folder with an index.html page, with the text “Coming Soon…”. I set up the repository, and tried to commit to Heroku, only to receive a message similar to “This is not a code repository” or something similar. Heroku is primarily aimed at apps running on frameworks, like Ruby on Rails, Django (Python), node.js, or… ahem… PHP.
Heroku allows you to publish PHP sites as well, with NO configuration needed! That’s right, just create your .php files, and it will figure out that the Heroku app should run PHP for this site, and it will auto-configure the app to run on the latest version of PHP/Apache.

So here is how you do it:

Rename your index.html to home.html or something similar.
Create an index.php file with the following code:
<?php include_once("home.html"); ?>
That’s it!
Now go to your app folder in CMD (or Bash), and commit your code to Heroku using the following:
git add .
git commit -m 'Change this to a meaningful description'
git push heroku master
 And finally, you should get the following:
-----> Heroku receiving push
-----> PHP app detected
-----> Bundling Apache version 2.2.22
-----> Bundling PHP version 5.3.10
-----> Discovering process types
Default types for PHP -> web
-----> Compiled slug size: 9.5MB
-----> Launching... done, v4
Congratulations! You have published a static site to Heroku with one line of PHP code :)

No comments:

Post a Comment

See all Posts

About Me

My photo

I am a Tech Enthusiastic and Open Source Lover.