Deploying PHP applications on Heroku
Heroku deploys PHP applications
I read a technical blog post on 51cto today, and accidentally saw the heroku cloud platform. As for what this platform does, it’s a long story. The following will focus on how to deploy PHP applications through heroku.
hrerku official website: https://www.heroku.com/
1. Basic operations
Friends who are already familiar with heroku can skip this step
- First register an account and a heroku account
Log in after registration Go to heroku, then go directly to the management background, then click "Personal Apps" on the left menu, enter the page as shown below, click the "+" button on the upper right, and select "Create new app"
Enter the create app page, fill in the app name and select the server location. A project web address will be generated based on the app name: https://myapp-one.herokuapp.com/, as shown in the following figure:
-
app creation completed Then you will see the interface as shown below:
As shown in the picture, the app page will have 5 tab navigation- Resources
What is placed is the project configuration information and third application (database or something) - Deploy
Here I tell you how to deploy your application, which is also the focus of the discussion later - Metrics
Indicates the current project status - Activity
It’s the log of the deployment operation - Access
Project Owner - Settings
Project settings, such as modifying the project name, project git address information, deletion, etc.
- Resources
2. Deploy PHP applications
After the above basic operations are understood and prepared, we can talk about the focus of this article, how to deploy PHP applications
- Open the created application, take the myapp-one I created here as an example, click the "deploy" tab, and then as shown in the figure below, the default is to use heroku git, it can also be github or dropbox, today I will focus on heroku's own Git deployment operation, in fact, the following has roughly introduced how to operate it, I will translate it:
- Download the heroku command line tool, there will be different versions for download according to different platforms. After the download is completed, enter your terminal and enter Enter the following command. After entering, press Enter to prompt you to enter your registration email and password. If you successfully log in, you will be prompted with a success message
<code><span>$ </span>heroku login</code>
- After successful login, enter the project directory you want to deploy, initialize git and set the git project address
<code>$ git init $ heroku git:remote -<span>a</span> myadd-<span>one</span><span># </span> 或者 $ git remote <span>add</span> heroku <span>https</span>://git.heroku.com/myapp-<span>one</span>.git</code>
- After completion, submit the project to git
<code><span>$ </span>git add -<span>A</span><span>$ </span>git commit -m <span>"init myapp-one"</span></code>
- Create a composer.json file in the project directory with the content {}, and then submit it to the project
<code><span>$ </span>echo <span>"{}"</span> > composer.json <span>$ </span>git add composer.json <span>$ </span>git commit -m <span>"add composer.json"</span></code>
- Set up heroku's php build toolkit
<code>$ heroku buildpacks:<span>set</span> https:<span>//github.com/heroku/heroku-buildpack-php</span></code>
-Add a Procfile file in the project root directory to set the initial command for project execution (very important, explain 'php -S 0.0.0.0:<code><span>$ </span>echo <span>" web: php -S 0.0.0.0:$PORT -t site/api/html "</span> > <span>Procfile</span><span>$ </span>git add <span>Procfile</span><span>$ </span>git commit -m <span>"add Procfile to start program"</span></code>
<code><span>$ </span>git push heroku master <span>#部署项目,每次修改了也要执行这个命令</span><span>$ </span>heroku open <span># 打开项目,其实就是用浏览器访问当前web应用</span></code>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

Cryptocurrency data platforms suitable for beginners include CoinMarketCap and non-small trumpet. 1. CoinMarketCap provides global real-time price, market value, and trading volume rankings for novice and basic analysis needs. 2. The non-small quotation provides a Chinese-friendly interface, suitable for Chinese users to quickly screen low-risk potential projects.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

How to set the SpringBoot project default run configuration list in Idea using IntelliJ...

About SpringCloudAlibaba microservices modular development using SpringCloud...

In IntelliJ...

Git and GitHub are key tools for modern software development. Git provides version control capabilities to manage code through repositories, branches, commits and merges. GitHub provides code hosting and collaboration features such as Issues and PullRequests. Using Git and GitHub can significantly improve development efficiency and team collaboration capabilities.

Laravel optimizes the web development process including: 1. Use the routing system to manage the URL structure; 2. Use the Blade template engine to simplify view development; 3. Handle time-consuming tasks through queues; 4. Use EloquentORM to simplify database operations; 5. Follow best practices to improve code quality and maintainability.
