Using PHP / LAMP Stacks

Last updated 4 months ago

How to configure a PHP or LAMP lesson.

This guide will walk you through a few configuration options necessary to make PHP / LAMP lessons work out of the box.

Stacks

There are two different stacks you may want to use:

PHP

The PHP stack comes with PHP 7.2 and Apache 2 pre-installed. You may want to use this stack instead of the full LAMP stack if you don't need MySQL, to keep extra resources (like memory, which is limited to 256MB by default) allocated to Apache.

LAMP

If you need MySQL, no worries! Just choose the LAMP stack. This stack comes with everything in the PHP stack plus MySQL 5.7. You can always increase the sandbox size.

Directory Configuration

The default directory persisted and accessible to the user is /root/sandbox . Apache loads files from /var/www/html , so you'll want to change the default (first) tracked directory to this one. You'll also want to set the chmod value to be applied to files created in the code editor to +x so that Apache can execute them (since they're technically created by the root user).

You can configure this by clicking Settings Gear > Advanced:

NB: The first directory watched is the one that will load in the code editor.

Web Browser Configuration

By default, the web browser's starting URL is localhost:8080 (the static file proxy running in /root/sandbox ). Apache runs on port 80, which you can set as the default by clicking the blue sliders at the bottom corner of the web browser component, and then setting the starting URL to {{localhost:80}}/{{entry}} :

Database Persistence

By default, only tracked directories are backed up, which doesn't include the database values.

If database persistence is important to you, please contact us to learn more about the currently available and upcoming options.