How to Install Lighttpd & PHP on Dlink DNS-320


I just obtain my new D-link DNS-320 NAS Storage which supposed to replace my older DNS-323 that died recently. As before, I need to install Webserver Lighttpd & PHP. This guide assumed that you have installed Fonz fun_plug in your DNS-320. This guide should work on D-link DNS-325 as well.

I choose fonz fun_plug version 0.5 instead of version 0.7 as I am unable to get it working correctly.

This guides are divided into 3 main section namely download packages, install, configure & finishing up. I also include some optional guides.

Download

1. Download lighttpd packages

2. Download PHP packages

Install

1. Run PuTTY and log into DNS-320

2. Change directory to “/mnt/HD/HD_a2” & create “pkg” folder inside “ffp” folder. If you are copying from a Windows PC you may need to set permission to copy.

cd /mnt/HD/HD_a2
mkdir -p /ffp/pkg
chmod -R 0777 /ffp/pkg

3. Copy all packages downloaded above into the folder “/ffp/pkg

4. Update & install Lighttpd packages

funpkg -u /ffp/pkg/lighttpd-1.4.29-1.tgz
funpkg -i /ffp/pkg/openssl-0.9.8k-1.tgz

5. Install PHP packages

funpkg -i /ffp/pkg/php-5.2.17-3.tgz
funpkg -i /ffp/pkg/curl-7.23.0-1.tgz
funpkg -i /ffp/pkg/libiconv-1.12-3.tgz

Configure

1. Create all folders required by Lighttpd

mkdir -p /ffp/opt/srv/mysql
mkdir -p /ffp/opt/srv/www/pages
mkdir -p /ffp/opt/srv/www/logs
mkdir -p /ffp/opt/srv/tmp

2. Create a symbolic link

ln -s /ffp/opt/srv/ /srv

3. Symbolik link above will be lost when you restart your DNS-320. To make it permanent, edit “/ffp/etc/fun_plug.init” file. If you are editing it from a Windows PC you may need to set permission to edit.

chmod 0777 /ffp/etc/fun_plug.init

4. Open your favoutrite text editor (don’t use notepad or it will corrupt the files) and open “/ffp/etc/fun_plug.init” file. Add the following at the end.

ln -s /ffp/opt/srv/ /srv

5.  Copy Lighttpd & PHP configuration files

cp /ffp/etc/examples/lighttpd.conf-dns320 /ffp/etc/lighttpd.conf
cp /ffp/etc/examples/php.ini-wolfuli /ffp/etc/php.ini

6. Stating up Lighttpd webserver

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

Finishing up

1. Your Lighttpd with PHP support should be running by now. Root folder of the web server is located at “/ffp/opt/srv/www/pages“. Test it by create a file named “index.php” which contains the following.

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

2. Open web browser and point it to “http://dns320-ip/“. Change “dns320-ip” to your DNS-320 IP address. You should see both notmal HTML & PHP generated output. Your DNS-320 admin page had move to “http://dns320-ip:81/”

Optional

1. For me, I would like to change Lighttpd port to “8080” & revert back admin page to port “80“. To do this, I need to edit “/ffp/etc/lighttpd.conf” file. If you are editing it from a Windows PC you may need to set permission to edit.

chmod 0777 /ffp/etc/lighttpd.conf

i. Find the following

server.port = 80

and change it to

server.port = 8080

ii. Find the following

$SERVER["socket"] == ":81" {

and change it to

$SERVER["socket"] == ":80" {

2. I also would like to enable directory listing. On the same “/ffp/etc/lighttpd.conf” file.

i. Find the following

#dir-listing.activate        = "enable"

and change it to

dir-listing.activate        = "enable"

3. To apply the changes, you have to restart Lighttpd.

sh /ffp/start/lighttpd.sh restart

4. By now, your web server serving port should change to “8080” and admin page port back to “80“. Test it on your web browser.



10 comments… add one
  • Perfect. You’re the man

    Reply
  • i simply get the error message invalid package type! what am i doing wrong?

    Reply
    • You are using which version of fun_plug?

      Reply
      • 0.7, i have used a combination of your guide and another guide i have found elsewhere, i have all the files installed and located in the correct places. the symbolic link is set up the config files is correct however i ma getting nothing on port 8080

        Reply
        • This guide is only for fun_plug version 0.5

          Reply
  • Excellent tutorial, I was able to perform the installation! Now I just need to install mysql, you did some tutorial about it? Greetings.

    Reply
  • Hello. When I’m running 2nd command from configure I get the error message : -sh: syntax error: newline unexpected

    Can you please help?
    Thank you

    Reply
  • I have web server on port 8080, on router forwarding port 80 -> 8080 …
    when I get in browser “http://IP/photo/…” lighttpd returns 302 and redirect on http://IP:8080/photo/installer
    Log:
    2013-05-31 14:53:48: (response.c.128) Response-Header:
    HTTP/1.1 302 Found
    X-Powered-By: PHP/5.4.10
    X-Frame-Options: SAMEORIGIN
    Content-Type: text/html; charset=UTF-8
    Location: http://IP:8080/photo/installer
    Transfer-Encoding: chunked
    Date: Fri, 31 May 2013 10:53:48 GMT
    Server: lighttpd/1.4.32

    how to fix it?

    Reply
  • Awesome was just what I needed!

    Reply
  • Hi Thanks for the wonderful tutorial,

    I have followed your tutorial and changed lighthttpd port to 80, it works fine but my admin interface is not working .

    Tried different ports such as 81, 8080.

    I have also tried changing lighthttpd port to 5050 but cannot get the admin interface on port 80 or 81 any ideas??

    Reply

Leave a Comment