Difference between revisions of "Lighttpd"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
== Install Lighttpd with PHP support == | == Install Lighttpd with PHP support == | ||
+ | |||
<pre><nowiki>ipkg-opt install lighttpd php-fcgi</nowiki></pre> | <pre><nowiki>ipkg-opt install lighttpd php-fcgi</nowiki></pre> | ||
== Tweak settings == | == Tweak settings == | ||
+ | |||
<pre><nowiki>vi /opt/etc/lighttpd/lighttpd.conf</nowiki></pre> | <pre><nowiki>vi /opt/etc/lighttpd/lighttpd.conf</nowiki></pre> | ||
If you are going to run static HTML pages, there is no need to do this. If you want the ability to run PHP pages then this line must be uncommented: | If you are going to run static HTML pages, there is no need to do this. If you want the ability to run PHP pages then this line must be uncommented: | ||
Line 16: | Line 18: | ||
You may also want to adjust the port that the web server runs on. Sprint blocks port 80 and this package installs Lighttpd to run on port 8081 : | You may also want to adjust the port that the web server runs on. Sprint blocks port 80 and this package installs Lighttpd to run on port 8081 : | ||
+ | |||
<pre><nowiki> | <pre><nowiki> | ||
## bind to port (default: 80) | ## bind to port (default: 80) | ||
Line 26: | Line 29: | ||
== Add a startup script == | == Add a startup script == | ||
+ | |||
I placed a file at /etc/event.d/optware-lighttpd so that the web server starts up after each reboot and the iptables firewall rules are executed to allow access to port 8080: | I placed a file at /etc/event.d/optware-lighttpd so that the web server starts up after each reboot and the iptables firewall rules are executed to allow access to port 8080: | ||
Line 50: | Line 54: | ||
== Add files to the web directory: == | == Add files to the web directory: == | ||
+ | |||
The default home directory lives at: | The default home directory lives at: | ||
+ | |||
<pre><nowiki>/opt/share/www/</nowiki></pre> | <pre><nowiki>/opt/share/www/</nowiki></pre> | ||
Sample gps.php file that will load your current location via Google maps: | Sample gps.php file that will load your current location via Google maps: | ||
+ | |||
<pre><nowiki> | <pre><nowiki> | ||
<?php | <?php | ||
Line 61: | Line 68: | ||
<iframe width="600" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small> | <iframe width="600" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small> | ||
</html> | </html> | ||
− | |||
</nowiki></pre> | </nowiki></pre> | ||
Revision as of 05:40, 31 July 2009
Configuring the Lighttpd web server
Preliminaries
- Gain root access.
- Setup the Optware Feed.
- Open the root file system to read/write with rootfs_open.
Install Lighttpd with PHP support
ipkg-opt install lighttpd php-fcgi
Tweak settings
vi /opt/etc/lighttpd/lighttpd.conf
If you are going to run static HTML pages, there is no need to do this. If you want the ability to run PHP pages then this line must be uncommented:
"mod_fastcgi",
You may also want to adjust the port that the web server runs on. Sprint blocks port 80 and this package installs Lighttpd to run on port 8081 :
## bind to port (default: 80) server.port = 8081
Start the web server:
/opt/etc/init.d/S80lighttpd start
Add a startup script
I placed a file at /etc/event.d/optware-lighttpd so that the web server starts up after each reboot and the iptables firewall rules are executed to allow access to port 8080:
# don't start until the WebOS finishes it's normal boot # that way no delay is added to the GUI startup start on stopped finish stop on runlevel [!2] # Restart the lighttpd daemon if it exits/dies respawn exec /opt/sbin/lighttpd -f /opt/etc/lighttpd/lighttpd.conf pre-start script /usr/sbin/iptables -D INPUT -p tcp --dport 8081 -j ACCEPT || /bin/true /usr/sbin/iptables -I INPUT -p tcp --dport 8081 -j ACCEPT end script
Reboot the phone so that the firewall rules are executed:
/sbin/reboot
Add files to the web directory:
The default home directory lives at:
/opt/share/www/
Sample gps.php file that will load your current location via Google maps:
<?php $gps = `luna-send -n 2 palm://com.palm.location/startTracking '{"appId": "ILovePalm", "subscribe": true}' 2>&1 | tail -1 | cut -d, -f4,5 | sed -r 's/[^-\.0-9,]//g'`; ?> <html> <iframe width="600" height="500" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&output=embed"></iframe><br /><small><a href="http://maps.google.com/?ie=UTF8&q=<?php echo $gps ?>&z=16&ll=<?php echo $gps ?>&source=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small> </html>
Other Considerations
Dynamic DNS
- Install the ez-ipupdate package
- Configure ez-ipupdate to update a DDNS service any time the EVDO IP changes
- CNAME record of primary domain - I have a CNAME record pointed to my DDNS record so that I always have the most up-to-date IP of my phone
Log files
- Need to keep an eye on the /opt/var/log/lighttpd/ log files and make sure they are rotated consistently