Follow by Email

Blog Archive

Search This Blog

Set up lighttpd web server on Raspberry Pi

There are several web servers for the Raspberry Pi. The easiest way is with the "lighttpd". Here you have to least configure and the installation is effectively done with a command on the command line. task Install the web server "lighttpd".
Share it:
Set up web server lighttpd on Raspberry Pi
apt-get install lighttpd

There are several web servers for Raspberry Pi. The easiest way is with the "lighttpd". Here you have to least configure and the installation is effectively done with a command on the command line.
task
  • Install the web server "lighttpd".
  • Check the availability of the web server over the local network.
  • Create a new HTML page and make it available through a web server.
Solution: install lighttpd
Before the installation, you can still update the package database and upgrade:
sudo apt-get update
sudo apt-get upgrade

Then you install the lighttpd server:
 sudo apt-get install lighttpd

After installation, the HTTP daemon usually starts automatically. If this worked, you can check with the following command:
 sudo systemctl status lighttpd

If all went well, that will be done with "Started Lighttpd Daemon." acknowledged.
Then we open a web browser and the host name of Raspberry Pi in the address bar. If everything went well, the standard page of the Lighttpd server ("Placeholder page") appears.
 http: //raspberrypi.local/

You may have given your Raspberry Pi a different hostname. Alternatively, you can also use the IP address.
 http: // {IP} Adresse_des_Raspberry_Pi /

Solution: Set permissions
The webserver directory is located at Raspbian Weezy under "/ var / www" and at Raspbian Jessie under "/ var / www / html". Of course you can change these default settings later. For now we leave it that way. In these directories, we will later remove the HTML files.
Before you can now put files in the web server directory, you should successively set a few rights.
sudo groupadd www-data
sudo usermod -G www-data -a pi
sudo chown -R www-data: www-data / var / www / html
sudo chmod -R 775 / var / www / html

This creates the user group "www-data" if it does not already exist. Then the user "pi" is assigned to this group and the web server directory "/ var / www / html" is passed as the owner. New files are automatically assigned to the group "www-data".

Note: In order for the permissions for the user "pi" to be accepted, he must log in again!

Now lighttpd restart again:
 sudo service lighttpd force-reload

Solution: Create your own HTML file
Then we create an HTML file for testing in the web server directory:
 nano /var/www/html/test.html

In the editor window, enter the following lines:

<Html>
<Head> <title> Test Page </title> </head>
<Body>
<h1> This is a test page. </h1>
</Body>
</Html>

Save and Exit with: Ctrl + O, Enter, Ctrl + X

Note: It can happen that the file can not be saved. In this case, the permission for the user "pi" is set incorrectly or it was forgotten to reload the configuration of the web server.

Then you can test whether this file is accessible via the web browser, in which one enters the following address in the address line:
 http: //raspberrypi.local/test.html
Or:
 http: // {IP} Adresse_des_Raspberry_Pi /test.html

Extension: PHP install
Running a web server on Raspberry Pi is just half the fun without PHP. The point is to extend the already installed web server "lighttpd" with PHP5 support so that PHP files can be executed.
Share it:

Raspberry Pi

Post A Comment:

0 comments: