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.
- Log in to Black Swift board via SSH
- Move uhttpd to another port, say 8080:
Find two list listen_http directives and change ports from :80 to :8080. Save file (Ctrl-X, Y) and restart uhttpd:
- Install lighttpd package:
- Install php5 and php5-cgi packages:
opkg install php5 php5-cgi
- Default web server root directory is /www, but it is occupied already by uhttpd. Create new subdirectory to use with lighttp and PHP:
- Edit lighttpd config file (use Ctrl-W to search for text):
Change server.modules as below (it is commented out by default):
server.modules = ( "mod_cgi" )
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" )
- Edit PHP config file (use Ctrl-W to search for text):
Change the root folder:
doc_root = "/www/lighttpd"
- 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.
opkg update opkg install lighttpd lighttpd-mod-cgi
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.