Difference between revisions of "Lighttpd"

From ArmadeusWiki
Jump to: navigation, search
(Configuration)
(Test the result)
Line 73: Line 73:
 
== Test the result ==
 
== Test the result ==
  
*Create the final rootfs:
+
* Create the final rootfs:
 
  $ make
 
  $ make
  
*Then [[Target_Software_Installation | update the rootfs]] on your board. Reboot it, and start Boa:
+
* Then [[Target_Software_Installation | update the rootfs]] on your board. Reboot it, and lighttpd should start automagically:
 
<pre class=apf>
 
<pre class=apf>
  # boa
+
  Starting lighttpd: OK
 
</pre>
 
</pre>
  
*To access your web page, use a browser:
+
* To access your web page, use a browser:
 
  http://''<your board's IP Address>''/
 
  http://''<your board's IP Address>''/
  
You should see the page ! <br />
+
* You should see the page !
If not, check the file ''/var/log/lighttpd/error_log'' on your board
+
* If not, check the file ''/var/log/lighttpd-error.log'' on your board
  
 
[[Image:Boa_welcome.png]]
 
[[Image:Boa_welcome.png]]

Revision as of 17:00, 14 April 2016

How-to install and configure the Lighttpd Web server on your Armadeus board.

Lighttpd.png


Installation

  • Launch Buildroot's configuration:
 $ make menuconfig
  • Select:
...
Target packages  --->
        ...
    [*] Networking applications  --->
            ...
            [*] lighttpd
            [ ]   openssl support
            [ ]   zlib support
            [ ]   bzip2 support
            [ ]   pcre support
            [ ]   webdav support
  • Save the configuration
  • Then build the binaries and the default filesystem. This will be useful later to perform the configuration:
 $ make

Configuration

Generalities

To apply a permanent configuration, be sure not to change anything on the board filesystem: that would be erased the next time you reflash the rootfs.
Instead, do all changes on the filesystem "image" located on your Host PC in buildroot/output/target/.

The Lighttpd configuration file is located in /etc/lighttpd.conf on the board; this means that to permanently change the configuration, you need to edit the file buildroot/output/target/etc/lighttpd.conf on the Host.

There is an envt variable to easily access the target directory:

 $ make shell_env && source armadeus_env.sh

Then the directory can be accessed with $ARMADEUS_ROOTFS_DIR.

Create a Dummy page

  • By default, DocumentRoot is set to /var/www, so let's add a dummy file here to test our configuration:
 $ mkdir -p $ARMADEUS_ROOTFS_DIR/var/www
 $ vim $ARMADEUS_ROOTFS_DIR/var/www/index.html
  • And fill the file with:
<html>
    <head>
        <title> Welcome on the Armadeus Board </title>
    </head>
    <body>
        <nowiki><h1> Welcome on the Armadeus Board </h1></nowiki>
    </body>
</html>

Enable hostname resolution

  • Boa has to be able to resolve the hostname to work, so let's do:
 $ echo "127.0.0.1 `cat $ARMADEUS_ROOTFS_DIR/etc/hostname`" >> $ARMADEUS_ROOTFS_DIR/etc/hosts

Test the result

  • Create the final rootfs:
$ make
  • Then update the rootfs on your board. Reboot it, and lighttpd should start automagically:
 Starting lighttpd: OK
  • To access your web page, use a browser:
http://<your board's IP Address>/
  • You should see the page !
  • If not, check the file /var/log/lighttpd-error.log on your board

Boa welcome.png

Working with cgi

  • First, check the lighttpd.conf file. Once more, you should use the one located on your host before changing anything.
$ vi $ARMADEUS_ROOTFS_DIR/etc/lighttpd.conf
  • Be sure to have an uncommented line like this:
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  • Now, let's write a dummy cgi:
$ mkdir $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin
$ vim $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/get_ipconfig.sh
  • And add the following :
#!/bin/sh
echo -e "Content-type: text/html\r\n\r\n";
echo -e `/sbin/ifconfig  eth0 | grep 'inet addr'`;

The script have to be executable:

$ chmod a+x $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/get_ipconfig.sh
  • Then change your index.html page to add a link to the cgi:
$ vi $ARMADEUS_ROOTFS_DIR/var/www/index.html
<html>
    <head>
        <title> Welcome on the Armadeus Board </title>
    </head>
    <body>
        <h1> Welcome on the Armadeus Board </h1>
        <br> <br>
        <a href=http://<Your board IP Address>/cgi-bin/get_ipconfig.sh> Get the board ip config </a>
        <br>
    </body>
</html>
  • Create the new rootfs:
$ make

You can now access to the new web page and click on the cgi link !

Links