Heroku is a cloud platform (PaaS - Platform as a Service) that allows developers to deploy, manage and scale web applications without worrying about server infrastructure. It supports multiple programming languages like Node.js, Python, Ruby, Java, PHP, Go, Scala and Clojure.
1. Install Required Tools
Install the Heroku CLI
curl https://cli-assets.heroku.com/install.sh | sh
Install Git (if not installed)
sudo apt install git # Ubuntu/Debian
brew install git # macOS
2. Create a Heroku Account
Sign up at Heroku.
Log in via CLI:
heroku login
3. Prepare Your Application
Heroku needs a Procfile to know how to start your application.
For a Node.js App
Create a file named Procfile (no extension) in the root directory:
web: npm start
For a Python (Flask/Django) App
web: gunicorn app:web: npm start
For PHP
web: heroku-php-apache2 .
If your project is not already in Git:
git init
git add .
git commit -m "Initial commit"
4. Create a Heroku App
Run the following command to create an app:
heroku create your-app-name
If you don’t specify a name, Heroku assigns a random one.
5. Deploy the Application
Add the Heroku remote repository:
git remote add heroku https://git.heroku.com/your-app-name.git
git push heroku main
or
git push heroku master
(depending on your Git branch)
6. Set Up Environment Variables (Optional)
If your app needs environment variables, set them using:
heroku config:set VAR_NAME=value
7. Scale and Open the App
heroku ps:scale web=1
heroku open
8. View Logs and Debug
To check logs:
heroku logs --tail
To restart the app:
heroku restart
9. Add a Database (Optional)
If your app requires a database, use:
heroku addons:create heroku-postgresql:hobby-dev
That's it! Your web application is now live on Heroku.
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.