Turning Raspberry Pi into a web server
Here's how to install Lighttpd on Raspberry Pi.
Publishing Static Web Pages
First things first. Update your package manager called Advanced Package Tool.
sudo apt-get update && sudo apt-get upgrade
Time to install a web server so that you can publish a static web page.
Install the Lighttpd web server.
sudo apt-get install lighttpd
Add the PI user to
www-data group and set the permission flags of the
/var/www directory. This is the default document root.
sudo adduser pi www-data
sudo chown -R www-data:www-data /var/www/
sudo chmod -R 775 /var/www/
Once you're logged in and you've completed setting up a few permissions, go ahead and create your first web page.
Publishing Dynamic Web Pages
PHP is a good choice for Raspberry Pi because it's easy to install and it doesn't consume a lot of resources.
Update apt-get package manager for Raspberry Pi
sudo apt-get update
sudo apt-get install php5-cgi
Install FastCGI module in the Lighttpd to speed things up
sudo lighty-enable-mod fastcgi
Reload lighttpd web server.
sudo /etc/init.d/lighttpd force-reload
Use nano to modify the web server config file
sudo nano /etc/lighttpd/lighttpd.conf
Enable PHP and FastCGI
fastcgi.server = (".php" => (("bin-path" => "/usr/bin/php-cgi","socket" => "/tmp/php.socket")))
Restart the web server
sudo service lighttpd restart
Test your work by adding this to the file
<?php phpinfo(); ?>
Configuring your Raspberry Pi to a wireless network is a little bit harder than going to your "Settings" on iPhone or Android. Here are a few helpful commands.
After installing a Wifi USB dongle to your USB port, use this command to find it's location.
You can take a closer look at the Piâ€™s boot message with the dmesg command and see whether the WLAN stick has been initialized properly.
dmesg | less
Get the current status of your Piâ€™s wireless network interfaces.
Once your Wifi USB dongle is working properly, you'll need to search for your Wifi network.
sudo iwlist scan | grep ESSID