Home >Backend Development >PHP Tutorial >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
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
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
<code><span>$ </span>heroku login</code>
<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>
<code><span>$ </span>git add -<span>A</span><span>$ </span>git commit -m <span>"init myapp-one"</span></code>
<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>
<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>
Finally execute the following command to deploy the project online <code><span>$ </span>git push heroku master <span>#部署项目,每次修改了也要执行这个命令</span><span>$ </span>heroku open <span># 打开项目,其实就是用浏览器访问当前web应用</span></code>
I personally tried the above successful configuration process. If there are any omissions, please forgive meFor specific reference, the official documents are as follows:Official instructions for PHP deployment: https://devcenter.heroku.com/articles/getting-started- with-php#introductionHeroku PHP build package address: https://github.com/heroku/heroku-buildpack-phpheroku command line tool instructions: https://devcenter.heroku.com/categories/command -line').addClass('pre-numbering').hide();
$(this).addClass('has-numbering').parent().append($numbering);
for (i = 1; i ').text(i));
};
$numbering.fadeIn(1700);
});
});
The above introduces the deployment of PHP applications on Heroku, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.