Run PHP Web Files Locally without Web Server Installed

From Bonus Bits
Jump to: navigation, search

Purpose

This article gives the steps to run local PHP web files without installing a web server. Basically, PHP 5.4 and higher come with the capability to do this. This can be good if you download a git repo that has a mini site for like converting excel to wikitext that you just want to use temporarily.


Prerequisites

  • PHP 5.4+


Display Used TCP Ports

netstat -tan | grep tcp | grep LISTEN


Launch Site Locally

  1. Change directories to were you have the index.php file.
    cd $HOME/Development/myphpsite
    
  2. Use PHP to launch a servlet in your code directory. Use a TCP Port between 1025-65535 and not currently used (Listen) from the netstat command above.
    php -S localhost:<tcp port>
    
    Example
    php -S localhost:8880
    


Sources