Roll Your Own Self-Hosted PHP Sandbox Page

View interactive steps on GitHub

What is PHPSandbox?

A PHP-based sandboxing library with a full suite of configuration and validation options.https://github.com/Corveda/PHPSandbox

  1. Log into the Debian device
  2. Run the following commands in a terminal:
    # update repositories
    sudo apt update
    # install any available software updates
    sudo apt upgrade -y
    # install some dependencies
    sudo apt install git composer apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
    # install Apache HTTPD and PHP components
    sudo apt install apache2 php7.3 libapache2-mod-php7.3 php-imagick php-gnupg php7.3-common php7.3-mysql php7.3-fpm php7.3-ldap php7.3-gd php7.3-imap php7.3-json php7.3-curl php7.3-zip php7.3-xml php7.3-mbstring php7.3-bz2 php7.3-intl php7.3-gmp php7.3-xsl -y
    # change directory
    cd /var/www
    # clone php sandbox from github
    sudo git clone https://github.com/Corveda/PHPSandbox.git
    # rename PHPSandbox to phpsandbox
    sudo mv ./PHPSandbox ./phpsandbox
    # set the owner of the phpsandbox directory to www-data
    sudo chown -R www-data:www-data /var/www/phpsandbox
    # setup composer working directory
    sudo mkdir /var/www/.composer
    sudo chown -R www-data:www-data /var/www/.composer
    # change directory
    cd phpsandbox
    # install dependencies with composer
    sudo -u www-data composer install
    # create and edit phpsandbox.conf
    sudo nano /etc/apache2/sites-available/phpsandbox.conf
  3. Paste the following into phpsandbox.conf

    Alias /phpsandbox "/var/www/phpsandbox/toolkit/"
    <directory /var/www/phpsandbox/toolkit/>
    Options +FollowSymlinks
    AllowOverride All
    Require all granted
    </directory>

  4. Press CTRL+O, Enter, CTRL+X to write the changes to phpsandbox.conf
  5. Continue with the following commands
    # enable the phpsandbox site
    sudo a2ensite phpsandbox
    # restart apache2
    sudo systemctl restart apache2
  6. Open a web browser and navigate to http://DNSorIP/phpsandbox
  7. Welcome to your very own self-hosted PHP Sandbox