Categories
Technical

Static website on heroku using terminal

TOPIC : Deploy a static website on heroku using comand line


A) Prerequisites :

    a)Heroku installed on your machine – 

        – To install heroku on your machine type the command “snap install –classic heroku”

        

        – Check if heroku is installed properly using “heroku –version”. 

            – NOTE : If you see a warning message such as “The command could not be located because ‘/snap/bin’ is not included in the PATH environment variable” run the following command “export PATH=$PATH:/snap/bin” for a temporary fix


B) Creating a project :

    a)Project Folder – 

        – Create a project directory from the command line using “mkdir your_projectname”

        

        – Navigate to your project folder and create 3 files (home.html, index.php, composer.json)

    

    b)Project contents –

        – Open “home.html” file, paste the following markup code and save the file

            <!DOCTYPE html>

            <html>

            <head>

            <title>Heroku Website</title>

            </head>

            <body>

                <h1>My Website</h1>

                <p>This is a static website deployed on heroku.</p>

            </body>

            </html>


        – Open index.php, paste the following and save the file

            <?php include_once(“home.html”); ?>


        – Open composer.json, paste the following and save the file

            {


            }


C) Pushing the project on heroku

    a)Initialize the project folder with git

        – Type the following in terminal for your project 

            git init

            git add .

            git commit -m “My first commit”


    b)Deployment 

        – heroku create (Creating an app)

        – git remote -v (To check if heroku has been set for your app)

        – git login (Login url would be generated in the terminal, copy the link and paste in your browser to login to your heroku account)

        – git push heroku master


        After completion of the above steps a url would be generated which mentions “deployed to heroku”, open the url in your browser and you can view your deployed app