PHP is a general purpose scripting language which can be used to create sofisticated web interface with the link to Black Swift hardware capabilities (i.e. switching GPIO pins) or other programs running on Black Swift. Setting up PHP is quite easy as all packages are ready. Default web server uhttpd, which runs LuCI web interface, doesn't support PHP, so the straight solution is to install second web server, keeping uhttpd on another port.

  1. Log in to Black Swift board via SSH
  2. Move uhttpd to another port, say 8080:

    nano /etc/config/uhttpd

    Find two list listen_http directives and change ports from :80 to :8080. Save file (Ctrl-X, Y) and restart uhttpd:

    /etc/init.d/uhttpd restart
  3. Install lighttpd package:
  4. opkg update
    opkg install lighttpd lighttpd-mod-cgi
  5. Install php5 and php5-cgi packages:

    opkg install php5 php5-cgi
  6. Default web server root directory is /www, but it is occupied already by uhttpd. Create new subdirectory to use with lighttp and PHP:

    mkdir /www/lighttpd
  7. Edit lighttpd config file (use Ctrl-W to search for text):

    nano /etc/lighttpd/lighttpd.conf

    Change server.modules as below (it is commented out by default):

    server.modules = (

    Change server.document-root to

    server.document-root = "/www/lighttpd"

    Add index.php to index-file.names:

    index-file.names = ("index.html","default.html","index.htm","default.htm","index.php" )

    Assign php-cgi executable to *.php files:

    cgi.assign = (".php" =>"/usr/bin/php-cgi" )
  8. Edit PHP config file (use Ctrl-W to search for text):

    nano /etc/php.ini

    Change the root folder:

    doc_root = "/www/lighttpd"
  9. Start lighttpd server

    /etc/init.d/lighttpd enable
    /etc/init.d/lighttpd start

    First command will add lighttpd to autostart, and second line will start it right now.

Now you have PHP5-enabled web server on port 80 and regular LuCI web interface on port 8080. All your PHP projects should be in /www/lighttpd folder or its subfolders.