DNS 325 - Funplug 0.5 : Web server with PHP and MySQL



This article explains how to install a full LAMP server on a DNS-325.

This server will be based on the following bricks :

  • Lighttpd
  • PHP
  • MySQL
  • phpMyAdmin

It is adapted from the tutorials found on NAS Tweaks. Some of the installation aspects have been adapted to the DNS-325 specificities (webdav shares, memory size of 256 Mb, default path, …).

As a pre-requisite, you must have prepared your DNS-325 with fun_plug and adds-on.

This procedure should also be compatible with a DNS-320, which is running the same system with less memory and less processor power.

Once you have successfully followed all these steps, you will, for example, be able to install a fully running Joomla site.

This guide is based on fun_plug 0.5.
It has not been tested on fun_plug 0.7.

1. Install Lighthttpd web server

You first need to install OpenSLL (if not already done) & to update the Lighttpd server (provided by default with fun_plug) :

# funpkg -i /ffp/pkg/packages/openssl-*.tgz
Installing package openssl-0.9.8 ...

# funpkg -u /ffp/pkg/additional/*/lighttpd-*.tgz

Then you have to create a new working directory and to create a link to it

# mkdir -p /ffp/opt/srv/www/pages
# mkdir -p /ffp/opt/srv/www/logs
# mkdir -p /ffp/opt/srv/tmp
# ln -s /ffp/opt/srv/ /srv

To make the link permanent, edit /ffp/etc/fun_plug.init and add these lines at the end of the file :



# create link to Web server folders
ln -s /ffp/opt/srv/ /srv

In the original approach, we configure a new lighttpd.conf that includes a complete administration web server confiuration. This approach was ok with previous generation of DNS NAS, but with the DNS-325, which offers a new webdav service it's not suitable. In fact every webdav share is added in the original /etc/lighttpd/lighttpd.conf. So, to be able to use them, we need to setup the lighttpd to use the original configuration file.

The main principle of the configuration file below is :

  1. to include original /etc/lighttpd/lighttpd.conf
  2. to leave the administrative web server on the same ports (80 & 443)
  3. to declare some virtual hosts for the other web servers

This way, the web server used is only selected by its URL. With services like dyndns, you can create 2 URL :

  • one will be for the adminstration interface,
  • a second one for the public Web server.

So let's create the new /ffp/etc/lighttpd.conf


# Special Configuration file for the DNS-325
# web servers are declared as virtual hosts

# include, relative to dirname of main config file
include "/etc/lighttpd/lighttpd.conf"

# add support for new virtual host
$HTTP["host"] =~ "(^|\.)your.public.url$" {
server.document-root = "/srv/www/pages"
server.errorlog = "/srv/www/logs/error.log"
accesslog.filename = "/srv/www/logs/access.log"
server.error-handler-404 = "/e404.php"

# files to check for if .../ is requested
index-file.names = ( "index.php", "index.html", "index.htm", "default.htm" )
cgi.assign = (".cgi" => "")
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi" )
flv-streaming.extensions = ( ".flv" )
fastcgi.server = ( ".php" => ("localhost" => ("bin-path" => "/ffp/bin/php-cgi", "socket" => "/tmp/php-fastcgi.socket", "bin-environment" => ( "PHP_FCGI_CHILDREN" => "0" ), "max-procs" => "1") ) )
server.max-request-size = 65536
server.upload-dirs=( "/ffp/tmp" )

You now need to stop the original Web server and to start the new lighttpd daemon.

# sh /ffp/start/kickwebs_dns320.sh start
# sh /ffp/start/lighttpd.sh start

Your new web server is now running in parallel with the NAS web adminsitration.

Create a test file /srv/www/pages/index.html


Test successful

If your router port forwarding or your computer /etc/hosts is setup properly, you should be able to display it thru http://your.new.nas.url/.

To be on the safe side, empty your browser cache before accessing http://your.new.nas.url.

Finally, make the startup scripts executable for Lighttpd to automatically start at every boot.

# chmod a+x /ffp/start/kickwebs_dns320.sh
# chmod a+x /ffp/start/lighttpd.sh

2. Install PHP

To install PHP you first need to install php and its dependencies :

# funpkg -i /ffp/pkg/additional/dev-lang/php-*.tgz
Installing package php-5.2.17-3 ...

# funpkg -i /ffp/pkg/additional/*/curl-*.tgz
Installing package curl-7.21.7-1 ...
Homepage: http://curl.haxx.se/

# funpkg -i /ffp/pkg/packages/libiconv-*.tgz
Installing package libiconv-1.12-3 ...

As we have done it with lighttpd, we have to copy a php.ini configuration example under /ffp/etc.

# cp /ffp/etc/examples/php.ini-wolfuli /ffp/etc/php.ini

Create a test file /srv/www/pages/index.php


<?php phpinfo(); ?>

Thru http://your.public.url/, you should now display your PHP configuration.

If so, PHP is running fine.

3. Install MySQL

To install MySQL, you need to install mysql package :

# funpkg -i /ffp/pkg/additional/*/mysql-*.tgz
Installing package mysql-5.1.58-2 ...

MySQL will be configured with a configuration file provided as an example.

As DNS-325 is having 256 Mb memory, we will use the medium template.

# cp /ffp/etc/examples/mysql/my-medium.cnf /ffp/etc/my.cnf

We now have to create the MySQL data directory and to start the database initialization.

# mkdir -p /ffp/opt/srv/mysql
# /ffp/bin/mysql_install_db

Once done, the MySQL server has to be started manually for further configuration.

Please notice that you have to type ENTER at the end of the start process to get back the prompt.

# sh /ffp/start/mysqld.sh start

Next very important step is to secure the installation, but setting a root password, removing anaonymous user, dropping test tables, …

# /ffp/bin/mysql_secure_installation

Finally, make the startup script executable for MySQL to automatically start at every boot.

# chmod a+x /ffp/start/mysqld.sh

4. Install PhpMyAdmin

PhpMyAdmin source files are available at http://www.phpmyadmin.net/. At the time of this article, stable version was 3.4.8.

You can check on the site what is the latest stable version, and adapt the command lines below.

So, first, we have to install the PhpMyAdmin PHP sources.

# cd /srv/www/pages/
# wget http://netcologne.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.4.8/phpMyAdmin-3.4.8-all-languages.tar.gz
# tar -zxf phpMyAdmin-3.4.8-all-languages.tar.gz
# rm phpMyAdmin-3.4.8-all-languages.tar.gz
# mv phpMyAdmin-3.4.8-all-languages phpmyadmin

PhpMyAdmin files are now accessible thru http://your.site.url/phpmyadmin/

To be able to use it you still need to create the PhpMyAdmin configuration file. You can create it via nano editor.


/* Servers configuration */
$i = 0;
/* Server localhost */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
$cfg['Servers'][$i]['auth_type'] = 'http';

Please note that as mcrypt.so module is not available under php, you have to use http authentification.

You just need to restart lighttpd server to run phpmyadmin.

# sh /ffp/start/lighttpd.sh restart

Your Web server is now fully operational.

You can start to populate your site under /srv/www/pages/

Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus