Installation of phpMyAdmin on Fonz fun_plug

What is phpMyAdmin

Quote from Wikipedia:

phpMyAdmin is an open source tool written in PHP intended to handle the administration of MySQL over the World Wide Web. It can do various tasks such as creating, modifying or deleting databases, tables, fields or rows; executing SQL statements; or managing users and permissions.

The installation on the NAS-Device requires a working lighttpd with php and the MySQL-Database server. Please follow the respective tutorials for the installation of these.

Download and unpacking

German version of this tutorialCheck the homepage of phpMyAdmin for the current version and download it. As of 13-Dec-2010, this latest non-beta version is 3.3.8.1:

cd /srv/www/pages/
wget http://switch.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-3.3.8.1-all-languages.tar.gz
tar -zxf phpMyAdmin-3.3.8.1-all-languages.tar.gz
rm phpMyAdmin-3.3.8.1-all-languages.tar.gz
mv phpMyAdmin-3.3.8.1-all-languages phpmyadmin

Now you have a directory called phpmyadmin in the webroot of your lighttpd.

Configuring

Now we need to add a configuration-file for phpmyadmin. We use nano for this:

cd /srv/pages/phpmyadmin/
nano config.inc.php

Simply copy the content below to this file:

<?
/* Servers configuration */
$i = 0;
/* Server localhost */
$i++;
$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';
?>

Errors and Remarks

  • The auth_typehttp” was chosen as cookie is extremely slow without the php-extension mcrypt which is not compiled into the current php-versions
  • If you get an error with the code #2002, you have to change the host to “127.0.0.1” and add a comment in the file my.cnf of mysql on the line skip-networking
  • If you get the error The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results, you have to enable the mbstring-extension in the php.ini of your NAS.

Finally

Now you should see phpmyadmin under http://CH3SNAS/phpmyadmin (substitute CH3SNAS with the network-name of your NAS-Device).
For further information consider reading the documentation online.

Softwaredetails of the Conceptronic CH3SNAS

Supported protocols

Configuration interface showing servers
Configuration interface showing servers
A computer or user can communicate with the CH3SNAS using a range of protocols.

Servers

  • SMB/CIFS server
    This provides the basic file server functionality on the local-area network.
  • FTP server
    This is mainly for allowing the files to be accessed via the Internet. Such access will normally require some configuration of the home router/gateway as general access from the outside to devices on the LAN is normally filtered by the gateway’s firewall function. A typical router (e.g. Linksys WRT54G) can be configured to direct incoming ftp requests (port 21) to the IP address of the NAS. The NAS, in turn, can be configured via the browser interface to only allow access to some directories, to request a user/password or to give only read access.
  • Print server
    Technically this is part of the SMB/CIFS protocol suite. It allows the CH3SNAS to act as a print server on the local network.
  • uPnP (Universal Plug-and-Play)
    This is a set of protocols which allows the CH3SNAS to be discovered as a source of multimedia (music, video, pictures) and to allow a uPnP-enabled rendering device such as a network-enabled video renderer to see and access the available media. Probably the most common current uPnP-enabled rendering devices are Windows PCs running Microsoft Media Player.
  • iTunes server
    Essentially iTunes is, as a networking protocol, Apple’s proprietary counterpart to uPnP. Common iTunes rendering devices are computers running
  • HTTP server (limited)
    There is a small HTTP server to generate and process the HTML forms used to configure the CH3SNAS. That configuration interface can be accessed via a web browser using a computer on the local-area network (or if desired – mind the security – from the Internet). This HTTP server process is known as “Webs” and is from GoAhead. Users interested in using an HTTP server for other uses should consider installing the Lighttpd package under fun_plug.
  • DHCP server
    In case the CH3SNAS is used in a network without a DHCP server, the CH3SNAS can be configured to provided all devices with a unique IP-address. This will presumably be seldom used, but can help if you want to connect the CH3SNAS to, for example, a stand-alone laptop. The laptop sees a more or less fully functioning network without having to temporarily reconfigure the laptop to use static IP address.

Clients

  • NTP client
    The CH3SNAS can use the Network Time Protocol to get the current time from NTP servers on the internet.
  • DHCP client
    Although the CH3SNAS can be bound to a fixed IP address, it can also get its IP address from a local DHCP server.
  • E-mail client
    The CH3SNAS can be configured to automatically send e-mail to its administrator to notify about certain events.
  • FTP client
    The CH3SNAS can be configured to automatically download files at scheduled times from an FTP server.
  • HTTP client
    The CH3SNAS can be configured to automatically download files at scheduled times from an HTTP server.

Client/server

  • Telnet (requires fun_plug)
    The CH3SNAS contains support for establishing telnet sessions, whereby a remote user can login to the machine via an unsecure connection.
  • SSH (requires fun_plug)
    SSH is a modern successor to telnet. SSH fixes security problems in telnet by encrypting traffic between both machines.

Available firmware and upgrades

Conceptronic regularly provides updates of the firmware (embedded software, or if you like: operating system and servers) inside the CH3SNAS. These are available for download at Conceptronic.net. Test versions (betas and “release candidates”) are also made available for a more technical audience.

You may want to see our overview on all versions to see the new features and if any major issues have been reported. There is also a guide on upgrading the firmware available here

[ return to CH3SNAS page ]

Installation and Configuration of PHP on Fonz fun_plug 0.5

German version of this tutorial

This tutorial is deprecated and should only be used with fonz fun_plug 0.5!
Please check the tutorial page for updated tutorials on this topic!

PHP is a server-side scripting language that is widely used for developing dynamic web sites. PHP allows custom software to run on the server (in our case the NAS) hosting the web site.

Logo of PHPPHP scripts are typically embedded in HTML pages. When a browser requests such a HTML page, the scripts are executed by the PHP add-in module of the HTTP server (here: lighttpd). Usually the PHP code inserts some additional HTML content into the version of the HTML page that gets sent to the browser. The browser (“client”) itself thus doesn’t see the scripts which were executed on the server.

In this tutorial we assume that the lighttpd HTTP server is already installed on the NAS (see tutorial on installing lighttpd On bigger systems, PHP is sometimes used in combination with an Apache server (instead of the leaner lighttpd) and an SQL database. This widely-used bundle of software tools is sometimes known as LAMP: Linux, Apache, MySQL, PHP. The installation of MySQL on the NAS is covered in another tutorial.

Contents

PHP uses

With regular HTML pages, your web server can only provide static content: all users see the same set of pages and the pages don’t change until someone (e.g. manually) updates the stored HTML pages. A server-side scripting language like PHP helps if you need to add dynamic content, such as a visitor counter (see example code below) or maybe news-of-the-day.
Public domain as well as proprietary PHP software is available for various applications including:

Setting up PHP

Installation

Uli kindly provided a packaged version of php for the NAS in his repository.

PHP is not installed as part of fun_plug by default, but you should already have downloaded a copy as part of the general tutorial on how to download, install and upgrade packages. Let’s make sure you still have the latest version (as Uli upgrades his repository regularly). Note that the rsync command could take a while because it can download multiple packages depending on what is already in your /ffp/pkg/packages directory. Also note that you have to install curl additionally! As of PHP 5.2.17 you also have to install libiconv which is in fonz repository.

cd /ffp/pkg
funpkg -i /ffp/pkg/additional/dev-lang/php-*.tgz
funpkg -i /ffp/pkg/additional/net-misc/curl-*.tgz
funpkg -i /ffp/pkg/packages/libiconv-*.tgz

If you have a version of php installed that is outdated, you will need to run in upgrade mode instead (see here for help). Still, make sure you have curl and libiconv installed!

funpkg -u /ffp/pkg/additional/dev-lang/php-*.tgz
funpkg -u /ffp/pkg/additional/net-misc/curl-*.tgz
funpkg -u /ffp/pkg/packages/libiconv-*.tgz

Configuring PHP

PHP is configured with a file called php.ini. You thus need to copy one of the example-files from /ffp/etc/examples/ to /ffp/etc/ while renaming it to php.ini:

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

Configuring Lighttpd

To use PHP with the lighttpd-webserver, you have to use another configuration file as explained in the section on config files in the tutorial.

If you have a NAS other than the DNS-320, you execute the following:

cp /ffp/etc/examples/lighttpd.conf-with-php /ffp/etc/lighttpd.conf

If you have a DNS-320, you execute:

cp /ffp/etc/examples/lighttpd.conf-dns320 /ffp/etc/lighttpd.conf

Activation

Restart lighttpd to load the new configuration – including the PHP module. This can be done by rebooting the entire NAS or using

cd /ffp/start
sh lighttpd.sh restart

Testing PHP

You can test your installation of PHP by placing a file called index.php in the server.document-root directory (e.g. /mnt/HD_a2/www/pages) with the following content:

<H1>This is normal HTML</H1>
But the <U>following table</U> is generated by PHP:
<?php
phpinfo();
?>

PHP configuration information
PHP configuration information
Now go to the website on your NAS using the configured address and e.g. http://CH3SNAS:80. You should see a long page with configuration information for the PHP server as shown in the picture). This output is generated by the function call “phpinfo()“.

Using PHP

Let us now go back to a somewhat less intimidating and possibly even boring example: the standard “Hello World” in PHP. Copy and paste the following text to a file named helloworld.php and store it in the server.document-root:

<?php
echo "Hello World";
?>

Then go to the website on your NAS using the configured address and port and add /helloworld.php (the address may look like this: http://CH3SNAS/helloworld.php).

The following example shows a more complete web page (adapted from the lighttpd tutorial). It adds 3 features:

  • visitors are greeted using their IP address (using the $_SERVER['REMOTE_ADDR'])
  • any viewing of the web page triggers updates to a file (counter.txt) stored on the NAS
  • the web site uses counter.txt to show how often the page has been viewed

This requires three fragments of PHP code, each enclosed between and ?> tokens:

 
<?php
$fname = "counter.txt";             // The file where the number of hits gets stored
if(!file_exists($fname)) {          // If file doesn't exist..
    $countfile=fopen($fname,"a");   // .. create it
    $counter=0;                     // .. and initialize hit counter to zero
}
else {
    $countfile=fopen($fname,"r+");  // Open for read and write
    $counter=fgets($countfile,100); // Load number of hits by reading first 100 bytes
    rewind($countfile);             // Reset the file pointer to overwrite old counter value
}
$counter++;                         // Increment counter by one
fputs($countfile,$counter);         // Write the new value to the file
fclose($countfile);                 // Close the File
?>
 
<html>
    <head>
        <title>Hello PHP World!</title>
        <style type="text/css">
        <!--
                        h1 {text-align:center; font-family:Arial, Helvetica, Sans-Serif;}
                        h2 {text-align:center;}
                        p  {text-indent:20px;}
        -->
        </style>
    </head>
 
    <body bgcolor = "#ffffcc" text = "#0000ff">
        <h1>Welcome, <?php echo $_SERVER['REMOTE_ADDR']; ?>, <BR>to the PHP world</h1>
        <h2>This page was viewed <?php echo $counter; ?> times</h2>
        <p><A HREF="page1.html">Link to page1</A></p>
        <p><A HREF="page2.html">Link to page2</A></p>
        <p><A HREF="https://nas-tweaks.net/">external link</A></p>
    </body>
</html>

Output of final example
Output of final example
HTML output as visible using the browser's View Source feature
HTML output as visible using the browser's View Source feature

The first and by far the longest PHP section looks to see if a file name counter.txt exists in the server.document-root If it doesn't exist, it creates it and decides there have been zero hits so far ($counter=0). Note that variables in PHP do not need to be declared and start with a $ and that no clear distinctions are made between numeric and string variables: conversions are done on demand.

If the file already exists, the first 100 bytes (should be enough for a decent number) are copied into $counter. Then $counter is incremented, written to the counter.txt file and the file is closed.

The remaining HTML code is similar to the code in the lighttpd tutorial. In the level one header (H1), a string is generated by a PHP echo command which prints the IP address of the remote client. In the level two header the value of $counter that was previously computed is used.

Optional: Using shared extensions

PHP allows the use of additional modules, so called "shared extensions". E.g. there is calendar for calendar-related functions. The modules are stored in /ffp/lib/php/extensions/no-debug-non-zts-20060613/.

Available modules

You can list the available modules using:

ls -al /ffp/lib/php/extensions/no-debug-non-zts-20060613/*.so

As of version php-5.2.6-3 the following modules are available:

Module Description Requires installation of ffp package
calendar functions related to days/months/years and Unix timestamps -
ctype character type checking -
ftp File Transfer Protocol -
gd image processing libjpeg, libpng
mbstring manipulation of non-ASCII strings (e.g. unicode) -
mysql MySQL database access mysql
pdo PHP data objects -
pdo_mysql PDO interface to the MySQL database mysql
pdo_sqlite PDO interface to the SQLlite database -
sqlite SQLlite database access -
tokenizer access to PHP tokens found by the lexical analyzer -
zlib .gz file compression -

Editing php.ini

If you want to add one or more modules, you need to edit the file /ffp/etc/php.ini.
Open php.ini and find:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

And add below the extension you want. E.g. to enable the calendar extension, you add:

; Linux extensions
extension=calendar.so
;extension=ctype.so
;extension=ftp.so

Afterwards you have to restart lighttpd to load the changes.

Demo of calendar extension

To see whether or not calendar was indeed loaded, you could run the PHPinfo.php script shown above.
Or run a script calendar.php containing:

<?php
for ($year=2000;$year<2011;$year++) {
    $days = cal_days_in_month(CAL_GREGORIAN,2,$year);
    echo "February in $year has $days days <BR>";
}
?>

Notes

PHP and HTML

A page with PHP code is generally stored on disk as HTML code with one or more fragments of embedded PHP. When the HTTP sends delivers the actual page to the browser ("client") the PHP sections have been interpreted and removed. In general they have been replaced by additional HTML code (see the counter example above). The receiving client thus does not see the PHP code and cannot even directly know whether PHP has been used to generate the served page.

Short open tag

If you want to use "<?" instead of "<?php" to mark the start of PHP code fragments, you need to change change the value of "short_open_tag" (line 131) in /ffp/etc/php.ini file to On:

short_open_tag = On

This is a matter of taste and convenience. When you distribute PHP code for use in other servers, you need to keep in mind that they may be set to short_open_tag = Off.

File extensions and default file names

HTML pages containing PHP code should have a .php extension. This tells the lighttpd server to pass the code via the PHP preprocessor before sending it across the network.

When you access the lighttpd server without providing a specific file name, it successively checks for files in the server.document-root directory(typically /srv/www/pages/) named

  • index.php
  • index.html
  • index.htm
  • default.htm

This is defined in a parameter called index-file.names in the lighttpd.conf file. As the list suggests, if you have both an index.php file and an index.html file in the same directory, the index.php file has precedence. If you explicitly ask for index.html, however, you will get that file instead of index.php.

Stateless

Note that after a page has been processed, when a new request for the same page is made by the same or another client, all computation starts from scratch: PHP is "stateless" in the sense that variables such as $counter are all lost after the page request has been completed. So the only way to track state in a PHP server is to store information in a file (as in counter.txt above), to store information in a database (another tutorial), or to assume the client maintains any relevant information between one page request and the next one.

Learning the PHP language

There are numerous books (printed and online) on PHP. See for example php.net.

Dealing with PHP errors

PHP syntax errors messages are appended to the Lighttpd error.log file. So if you are experimenting with- or developing PHP code, it can help to keep an eye on that file.

Installation and Configuration of the Webserver lighttpd for Fonz fun_plug

LIGHTTPD Logo
LIGHTTPD Logo
This tutorial is deprecated and should only be used with fonz fun_plug 0.5!
Please check the tutorial page for updated tutorials on this topic!

The lighttpd daemon is a lightweight web server. Its main task is to respond to HTTP requests. In other words, it allows HTTP clients (such as Internet Explorer and Firefox) to retrieve hyperlinked HTML pages stored on a web site stored on the CH3SNAS.

In terms of complexity, lighttpd lies between the basic GoAhead HTTP server (which comes with the CH3SNAS) and an Apache server.

Contents

Example uses

German version of this tutorialThe lighttpd server allows you to build a web site which is accessible via your local area network (LAN). If you configure your router’s firewall properly, you can also let others access the website via the Internet. Opening your firewall to give access to outside HTTP requests obviously requires paying some attention to security.

A basic web site consists of a collection of HTML pages which provide text, links, images, documents, etc. HTML pages can be written with an ASCII editor. There are numerous books and online tutorials on how to create basic and advanced web pages directly in HTML. This can be worth trying if you want to understand how the World Wide Web works: HTML is the main technology behind WWW.

In recent years, however, the average web page has gotten increasingly sophisticated in terms of its technical and visual design. Furthermore, the content of many web sites has become dynamic: what you see in your browser often changes daily (the weather, the news, a blog, photos). Such dynamic HTML pages are generated (by running programs or scripts) whenever the set of HTML pages needs to be updated, or are created on the fly whenever the server receives a page request.

Some examples of what you can do with a web site consisting of basic, static HTML served via lighttpd:

  • a basic home page telling who you are
  • a set of pages about your hobby, your recipes, or reporting on your holiday trip (all with embedded pictures)

Using this approach you “program” your page using the HTML language.

Examples of ways to generate ”’fancier static HTML”’ pages using software:

  • Microsoft Word can generate a HTML version of a document (including formatting, links and pictures)
  • professional photographers may use Photoshop Lightroom to generate an online gallery of sample pictures

Using this approach you use software to generate the HTML pages. This means you don’t need to learn (much) HTML, but instead need to learn how to use the (often fancy) software. All-in-all this can save you some typing and helps generate a uniform look for the web site.

Examples of applications involving generating dynamic HTML pages:

  • a Blog or Forum contains HTML forms that allow users to type in text that is appended to certain pages. Example: NAS-Tweaks uses a PHP server and software by WordPress for its Blog. Often this approach uses a database like MySQL to store and manage the raw data used to generate the HTML.
  • many well-known Web 2.0 sites that provide a service for you (WikiPedia, Google Maps, YouTube, Flickr)

Using using this approach, software generates HTML pages on demand, keeps the pages updated, and allows interaction with the user. If you go overboard on this, and manage to get the users of your website to provide content which keeps you web site interesting, you can call this Web 2.0 and tell your friends you may become rich – someday.
This kind of software is often known as Content Management Systems and includes engines like Drupal, Joomla, Mediawiki (as used by Wikipedia) and WordPress (as used for blogs).

Setting up Lighttpd

Installation

By default a lighttpd is already installed with the fun_plug packages. But there is an update available. Before you can install it, be sure to synchronize my repository. Then update using the following command:

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

If you didn’t install all packages from the “packages”-directory (why not?), you should execute at least the installation of the OpenSSL-package:

funpkg -i /ffp/pkg/packages/openssl-*.tgz

Directories

The default lighttpd configuration needs a small directory tree where it can store logfiles and retrieve the data to display to the users. Instead of creating the directory at that location, you may prefer to create a symbolic link from /srv/ to the target-directory of your choice.

mkdir -p /ffp/opt/srv/mysql
ln -s /ffp/opt/srv/ /srv

This link will be lost after rebooting the device, so you have to add the following two lines to the end of the file /ffp/etc/fun_plug.init to recreate the link every time the NAS boots. You can edit this file using an editor like nano. Use the following for all NAS other than the DNS-320 or DNS-325:

# create custom link to the server-folder
ln -s /ffp/opt/srv/ /srv

Now create the folders for the webserver:

mkdir -p /srv/www/pages
mkdir -p /srv/www/logs
mkdir -p /srv/tmp

The folder /srv/www/pages is the default location for the web site itself. The location is set via a parameter called server.document-root in the /ffp/etc/lighttpd.conf file. This means that any directories below server.document-root are visible via the HTTP server (careful), while any other directories are not visible.

The folder /srv/www/logs is for log files in which lighttpd can record what happened.

HTML test pages

Within the www folder, you should create a home page named index.html containing the following ASCII text. Note that the indentation is only for readability and can be (and often is) omitted. You don’t need to worry about using Linux or Windows end-of-line conventions here (both work). You may have to adapt the line CH3SNAS:81 to reflect the network name of your NAS or use its IP address instead (e.g. 192.168.0.20:81).

<html>
    <head>
        <title>Hello world</title>
        <style type="text/css">
            <!--
                h1 {text-align:center;
                    font-family:Arial, Helvetica, Sans-Serif;}
                p  {text-indent:20px;}
            -->
        </style>
    </head>
 
    <body bgcolor="#ffffcc" text="#0000ff">
        <h1>Hello, CH3SNAS Tweak'n World!</h1><p>
        <A HREF="page1.html">Link to local page1</A><p>
        <A HREF="page2.html">Link to local page2</A><p>
        <A HREF="http://CH3SNAS:81">Configure the CH3SNAS</A><p>
        <A HREF="https://nas-tweaks.net/CH3SNAS:Tutorials/lighttpd">external link to the Lighttpd tutorial</A>
    </body>
</html>

The HTML code consists of a head and a body section. The head contains the title (shown at the top of the browser window) and, in this case, defines formatting styles for Header1 and new paragraph (<p>).
The body starts with a header, followed by four links (“<A>nchors”) to other pages, to the original HTML configuration page for the CH3SNAS (on port 81 instead of the default 80) and a link to a remote web site.

Then create page1.html in the same directory containing:

<html>
    <head>
        <title>Page #1</title>
        <style type="text/css">
            <!--
                h1 {text-align:center;
                font-family:Arial, Helvetica, Sans-Serif;}
                p {text-indent:20px;}
            -->
        </style>
    </head>
 
    <body bgcolor = "#ffffcc" text = "#0000ff">
        <h1>Page 1</h1><p>
        <A HREF="index.html">Home</A><p>
        <A HREF="page2.html">Link to page2</A><p>
    </body>
</html>

Similarly you can create page2.html in the same directory:

<html>
    <head>
        <title>Page #2</title>
        <style type="text/css">
            <!--
                h1 {text-align:center;
                font-family:Arial, Helvetica, Sans-Serif;}
                p {text-indent:20px;}
            -->
        </style>
    </head>
 
    <body bgcolor = "#ffffcc" text = "#0000ff">
        <h1>Page 2</h1><p>
        <A HREF="index.html">Home</A><p>
        <A HREF="page1.html">Link to page1</A><p>
    </body>
</html>

Enabling lighttpd

This tutorial assumes that fun_plug is installed and that you have installed the additional packages (these include lighttpd). You can test whether lighttpd is installed using

which lighttpd

on the ssh command line. If it is installed, it will respond with the location of the lighttpd script file: /ffp/sbin/lighttpd.

Waking up daemons

Next we need to enable the lighttpd server from the command line (see the packages tutorial for a detailed explanation):

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

and enable a script which disables the standard HTML server called webs (if you are running a DNS-320 / DNS-325 please skip this step and go to the following section):

chmod a+x /ffp/start/kickwebs.sh

The standard “webs” server then restarts automatically within a few minutes, but moves to port 81 because the standard HTTP port (80) is already occupied by the lighttpd server.

If you are running a DNS-320 or a DNS-325, you need to enable “kickwebs_dns320.sh” for kicking the internal lighttpd (which is used for the Webinterface of the Device) from Port 80:

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

Note that the chmod commands only take effect on the next reboot. If you would reboot now, however, nothing changes. If you want to try, you can see test this manually using:

sh /ffp/start/kickwebs.sh start # When you run a Device other than DNS-320 / DNS-325
sh /ffp/start/kickwebs_dns320.sh start # When you run a DNS-320 / DNS-325
sh /ffp/start/lighttpd.sh start

Unless you have installed the server before, you will get the error message /ffp/etc/lighttpd.conf: Required file not found or not readable. Which, by Linux standards is an unusually clear error message: a file with configuration settings for lighttpd is missing in the /ffp/etc directory (see the packages tutorial for more explanation).

lighttpd.conf

We can resolve the missing /ffp/etc/lighttpd.conf file by copying the file from the directory /ffp/etc/examples/. If you are not on a DNS-320 or a DNS-325 and you don’t need PHP, then run the following command:

cp /ffp/etc/examples/lighttpd.conf /ffp/etc/

This copies one of the two supplied configuration files from the /ffp/etc/examples subdirectory to the /ffp/etc directory.
if you want to run PHP and you are not on a DNS-320 or a DNS-325, then run the following:

cp /ffp/etc/examples/lighttpd.conf-with-php /ffp/etc/lighttpd.conf

If you are on the DNS-320 or DNS-325, you have no choice but to run the Webserver with PHP (Please configure PHP before you try starting lighttpd again!):

cp /ffp/etc/examples/lighttpd.conf-dns320 /ffp/etc/lighttpd.conf

Port insight

Next we can try starting lighttpd manually again to see how we are doing:

sh /ffp/start/kickwebs.sh start # When you run a Device other than DNS-320/DNS-325
sh /ffp/start/kickwebs_dns320.sh start # When you run a DNS-320 / DNS-325
sh /ffp/start/lighttpd.sh start
sh /ffp/start/lighttpd.sh status

Example HTML page being hosted by Lighttpd
Example HTML page being hosted by Lighttpd
As, this suggests that lighttpd is now happily running, we try typing http://CH3SNAS:81 in the address bar of your Web browser. Note that if your network name for the device differs from “CH3SNAS“, use that name or its IP address instead. You should now get the standard configuration screen. Please remember the :81 port number in case you need to access it in the future (it is one more than the standard port 80 used for HTTP servers – which you can look up on the internet). You can close that screen – it was only to demonstrate that kickwebs.sh did its job.

We now try entering http://CH3SNAS in the address bar of the Web browser. If all goes well, you will see the expected web page.

To boot or not to boot

Remember that you now have a lighttpd running on port 80 each time you boot the NAS. If you want to connect to the Webinterface of the NAS, connect to Port 81.

Testing Lighttpd

At this point, you can enter any of the following into your browser’s address bar (assuming CH3SNAS is the correct network name of your NAS):

  • http://CH3SNAS:80/index.html
  • http://CH3SNAS:80 – index.html is a default for browsers
  • http://CH3SNAS – port 80 is default for HTTP
  • CH3SNAS – http is the default protocol for web browsers

Notes

The log files

The directory /srv/www/logs contain log files which respectively record the access to the server and any errors (including starting and stopping) reported by the server.

-rw-r--r-- 1 root  root    0 Oct 19 17:06 access.log
-rw-r--r-- 1 root  root   48 Oct 19 17:06 error.log

The file access.log contains timestamped records which are appended whenever a file on the server is accessed via HTTP (which file, which IP address, HTTP statuscode, browser used). Here is a schematic line from the access.log file:

client_IP server_URL - [date:time +0200] "GET /path/file_1.jpg HTTP/1.1" status_code file_length "-" "client_browser_type"

If you want to clear the log files, one quick-and-dirty way to do so is to delete them and restart the CH3SNAS. The lighttpd server will regenerate the log files when it is started. A quicker approach is to restart the lighttpd server using:

rm /srv/logs/access.log
cd /ffp/start
sh lighttpd.sh restart

Now What?

You should now install PHP if not already installed and try using MySQL. Have fun 🙂