Difference between revisions of "Lighttpd"
(→Test the result) |
(→Working with cgi) |
||
Line 103: | Line 103: | ||
== Working with cgi == | == Working with cgi == | ||
+ | * Create an new ''cgi.conf'' configuration file with the following lines: | ||
<pre class="host"> | <pre class="host"> | ||
# vi /etc/lighttpd/conf.d/cgi.conf | # vi /etc/lighttpd/conf.d/cgi.conf | ||
Line 120: | Line 121: | ||
</pre> | </pre> | ||
− | * Then add | + | * Then add this configuration sourcing in ''lighttpd.conf'': |
+ | <pre class="host"> | ||
+ | $ vi $ARMADEUS_ROOTFS_DIR/etc/lighttpd.conf | ||
+ | </pre> | ||
+ | |||
<pre class="host"> | <pre class="host"> | ||
Line 133: | Line 138: | ||
</pre> | </pre> | ||
− | + | * Now, let's write a dummy CGI script that will get IP address of your board: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | *Now, let's write a dummy | + | |
$ mkdir $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin | $ mkdir $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin | ||
− | $ vim $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/ | + | $ vim $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/ip.sh |
− | |||
<source lang="bash"> | <source lang="bash"> | ||
#!/bin/sh | #!/bin/sh | ||
Line 150: | Line 148: | ||
echo -e `/sbin/ifconfig eth0 | grep 'inet addr'`; | echo -e `/sbin/ifconfig eth0 | grep 'inet addr'`; | ||
</source> | </source> | ||
− | |||
− | |||
− | *Then change your index.html page to add a link to the | + | * The script have to be executable: |
+ | $ chmod a+x $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/ip.sh | ||
+ | |||
+ | * Then change your index.html page to add a link to the CGI: | ||
$ vi $ARMADEUS_ROOTFS_DIR/var/www/index.html | $ vi $ARMADEUS_ROOTFS_DIR/var/www/index.html | ||
Line 170: | Line 169: | ||
</source> | </source> | ||
− | *Create the new rootfs: | + | * Create the new rootfs: |
$ make | $ make | ||
− | *Finally, [[Target_Software_Installation | transfer the rootfs]] to the board & flash it. | + | * Finally, [[Target_Software_Installation | transfer the rootfs]] to the board & flash it. |
− | You can now access to the new web page and click on the | + | You can now access to the new web page and click on the CGI link ! |
==Links== | ==Links== |
Revision as of 15:41, 20 April 2016
How-to install and configure the Lighttpd Web server on your Armadeus board.
Contents
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:
$ 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/lighttpd.conf on the board; this means that to permanently change the configuration, you need to edit the file buildroot/output/target//etc/lighttpd/lighttpd.conf on the Host.
var.log_root = "/var/log" var.server_root = "/var/www" var.state_dir = "/var/run" var.home_dir = "/var/lib/lighttpd" var.conf_dir = "/etc/lighttpd" server.document-root = "/var/www/" server.errorlog = log_root + "/lighttpd-error.log" server.port = 80 mimetype.assign = ( ".html" => "text/html", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".png" => "image/png" )
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, server.document-root 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 an Armadeus Board </title>
</head>
<body>
<nowiki><h1> Welcome to your APF board ! :-) </h1></nowiki>
</body>
</html>
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
Working with cgi
- Create an new cgi.conf configuration file with the following lines:
# vi /etc/lighttpd/conf.d/cgi.conf
server.modules += ( "mod_cgi" ) cgi.assign = ( ".pl" => "/usr/bin/perl", ".cgi" => "/bin/sh", ".sh" => "/bin/sh", ".py" => "/usr/bin/python" ) index-file.names += ( "index.pl", "default.pl", "index.py", "default.py", "index.php", "default.php" )
- Then add this configuration sourcing in lighttpd.conf:
$ vi $ARMADEUS_ROOTFS_DIR/etc/lighttpd.conf
... ## ## CGI ## include "conf.d/cgi.conf" mimetype.assign = ( ...
- Now, let's write a dummy CGI script that will get IP address of your board:
$ mkdir $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin $ vim $ARMADEUS_ROOTFS_DIR/usr/lib/cgi-bin/ip.sh
#!/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/ip.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
- Finally, transfer the rootfs to the board & flash it.
You can now access to the new web page and click on the CGI link !