In last post we have installed lighttpd and fastcgi++, it’s create a demo page to have a quick verification.
Let’s write a simple html for demo:
This page will show a picture as page background, meanwhile a from will be created for testing GET method. The path we are using in html is relative path, i.e. if you put your pages to /var/www/pages/test.html, the absolute path of back.jpg will be /var/www/pages/img/back.jpg and the relative path will be /img/back.jpg.
Beware of access rights of those files/directories, the user and user group of lighttpd was configured in lighttpd.conf by server.username and server.groupname. Make sure lighttpd can access them.
Use environment().gets to get all data passed by frontend through GET method.
g++ fcgi_get.cpp -lfastcgipp -o cpp_get.fcgi
Then copy it to /var/www/fcgi-bin/cpp_get.fcgi. Don’t forget add rights of execution for this fcgi file.
"/cpp_get.fcgi" => (
This configuration allows you execute your fcgi by access localhost/cpp_get.fcgi.
If lighttpd is already started on your device, you might need to restart lighttpd services to apply changes:
service lighttpd force-reload
Open http://localhost/test.html, input something in the form then click “提交”, if everything is ok, browser will jump to http://localhost/cpp_get.fcgi and show what you have inputted. Meanwhile a file called output.patch will be generated at your page folder which contains the text you inputted as well.
Tips: If error occurred, you can find the path of error log by checking the value of server.errorlog in your lighttpd.conf.