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