Heroku Deploying PHP Applications
Today in 51cto read an article about technology blog, inadvertently saw Heroku this cloud platform, as to what this platform is wordy. The following is a key to how to deploy PHP applications through Heroku.
Hrerku Official website: https://www.heroku.com/
First, the basic operation
Friends who are already familiar with Heroku can skip this step.
- First register an account with a Heroku account
Login to Heroku, then go directly to the management background, and then click on the left menu "Personal Apps", go to the page as shown, click on the "+" button on the right, select "Create new App"
Enter the Create app page to fill in the app name and select the server location, according to the app name will generate a Project Web address: https://myapp-one.herokuapp.com/, as shown in the steps:
After the app is created, you'll see an interface like this:
, the App page will have 5 tabs to navigate
- Resources
Put the project configuration information and the third application (database, etc.)
- Deploy
Here's how you can deploy your application, and that's what you'll focus on later.
- Metrics
Indicates the status of the current project
- Activity
is the log of the deployment operation
- Access
Project owner
- Settings
Project settings, such as Modify project name, project git address information, delete, etc.
II. Deployment of PHP applications
After the basic operation of the above understanding and ready to complete the focus of this article, how to deploy PHP applications
- Open the created app, take the Myapp-one I created here as an example, click on the "Deploy" tab, and then, as shown, use Heroku git, or GitHub or Dropbox, to focus today on Heroku's own GIT deployment operations, In fact, the following is probably how to operate the introduction, I will translate the following:
- Download Heroku command line tool, depending on the platform will have a different version for download Download complete, after installation, enter your terminal, enter the following command, enter after entering the prompt you enter the registration email and password, login success will be successful prompt
$ heroku login
- Login successfully to the project directory you want to deploy, initialize git and set git project address
$ git init$ heroku git:remote -a myadd-one# addhttps://git.heroku.com/myapp-one.git
- Submit project to Git after completion
$ git add -A$ "init myapp-one"
- Create a Composer.json file in the project directory with {}, and then submit it to the project
$ "{}" > composer.json$ git add composer.json$ "add composer.json"
- Set up the PHP build toolkit for Heroku
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-php
-Add the Procfile file under the project root to set the initial command for project execution (very important, explained under ' php-s 0.0.0.0: PORT?TsITe/aPI/hTm l -itajustis aPhP5.4ofafterfromwithof theWebseRveR,with?SKaiMoving,0.0.0.0TableshownRen what machine can be interviewed , Port is ports (do not change),-T represents Docroot, if the startup web directory in the root directory is not writable, if in a subdirectory, write a relative path can be like site/api/html),
$ " web: php -S 0.0.0.0:$PORT -t site/api/html "Procfile$ git add Procfile$ "add Procfile to start program"
- Finally, execute the following command, deploy the project to the online
$ #部署项目,每次修改了也要执行这个命令$ # 打开项目,其实就是用浏览器访问当前web应用
I personally try to configure the success of the process, if there are omissions, please also forgive
For specific reference, the official documentation is as follows:
PHP Deployment Official Description: Https://devcenter.heroku.com/articles/getting-started-with-php#introduction
Heroku PHP Build Package Address: https://github.com/heroku/heroku-buildpack-php
Heroku command-line tool instructions for use: https://devcenter.heroku.com/categories/command-line
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the Heroku deployment of PHP applications, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.