APP Platform PHP web apps configuration

Posted October 1, 2021 382 views
PHPConfiguration ManagementDigitalOcean App Platform

I’m trying to build a simple PHP web app and I’m trying to trace the documentation to a list of available configuration options. All I get is a sample app with an index.php file and “go look at Heroku buildpacks” …

However, there is no canonical example of what file (Procfile, app.yml, JSON(?)) I should use and what it can and should contain and the few examples I find over at Heroku are limited and very specific to themselves.

I want to run a simple php web application that uses a subdirectory for all public routes. Does App Platform use NGINX or APACHE? Heroku let’s me choose, but I have a hunch that DO doesn’t work verbatim like Heroku. Can I choose? If so how do I control request routing and configuration? Can I alter PHP-FPM config options as Heroku describes?

The documentation was equally as terse for the Go web application but trial and error was a bit easier as I was only running a binary.

Does a full list of options and recommendations exist for App Platform or is the expectation that I have a full Docker/docker-compose flow where I run my own nginx on the server behind what I presume is already nginx running publicly?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

I think you need html files or template to make php working

👋 @henderjon

I apologize for the trouble — I’ll make sure to note that this documentation should be expanded.

App Platform uses the Heroku PHP Buildpack so all of the configuration options in the documentation should apply. This is a good page to review: Customizing Web Server and Runtime Settings for PHP

Generally speaking, App Platform uses custom run commands that are configured in the control panel rather than Procfiles. Everywhere the documentation mentions using a Procfile, you’ll want to use the specified command as the component’s run command.

You’ll notice that the run command field is sometimes pre-filled when you add a new component. App Platform tries to find the one that is most suitable for the type of project being added, so it has different values for Laravel for example compared to generic PHP apps.

For example, to set the document root to a subdirectory, you can pass the directory path as an argument to the run command:

heroku-php-apache2 public/

This configured Apache to use the public directory as the document root. If you choose to use Nginx instead of Apache (there is some explanation on that on the documentation page linked above), it would look like so:

heroku-php-nginx public/

As for customizing PHP-FPM options, you can use .user.ini files anywhere inside the document root for that. There’s some details on that under the PHP runtime settings section of the Buildpack’s docs.

I hope that helps!

  • I think as a new comer, it didn’t seem correct to use heroku-php-apache2 public/ a Heroku command in Digital Ocean. I thought to myself “this can’t be right”.

    My frustration was simply that I unknowingly just wanted someone to say “create a Procfile and use the actual Heroku directives.”

    I suppose I mostly just betrayed my own ignorance.

    Thanks for the help!