Linux: PHP as a standalone application

Geschreven door Erwin A.W. Maas

Run only PHP in Linux (Ubuntu / Zorin and whatever more...)

Most of my websites don't use a database, therefore I do not need Apache or MySQL to edit them on localhost.
Now I know, you can do that by installing Lamp (Xampp), but easier and quicker is it to just run PHP on it's own (provided that you already have downloaded and unpacked PHP to somewhere in your filesystem).

If you do not yet have PHP installed, here's a quick how-to (1 = check if PHP exists and which version, 4 if no PHP installed, 5 = to check the version again and write the configuration to a file for easier upgrade, 6 = get the last version and 8 = remove old version):

  1. php -v
  2. sudo apt update
  3. sudo apt full-upgrade
  4. sudo apt install php
  5. dpkg -l | grep php | tee packages.txt
  6. sudo add-apt-repository ppa:ondrej/php
  7. sudo apt update
  8. sudo apt autoremove

Now you have PHP installed and you can run it either through the terminal or make a bashfile and add a starter to it on the desktop for convenience. In contrary to what most webresources say, you do not need to move your website-files to a specific default location, just point to them in the bashfile. You basically only need 2 lines to get PHP going.
Open a text-editor or IDE, start with an empty new file and write (editing the path/to-part):
#! /usr/bin/bash
php -S localhost:8080 -t /path/to/my/websites/

Save the file as and remember the save-path

Now you only have to create a starter which points to the bash-file and let it run in the terminal (check this option)

Terminal-notifications while running PHP

In the Terminal you should be able to read that PHP has started and while working on your websites the terminal will provide all kinds of useful information about the processes that PHP follows as ordered by the pages that you open in the browser.

In your browser go to localhost:8080 and you'll see your websites. Now you can edit them local in whatever application you wish and upload them to the webserver whenever you are happy to share them 😎


  1. Markdown is toegestaan. Toegestane HTML-Tags: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.