Lighttpd, like Ngnix, is designed to run on devices with low memory, low CPU load, and they are all perfect for running on raspberry PI.

This article shows you how to run Lighttpd in basic configuration on raspberry PI and how to use it with PHP-FRM.

Install Lighthttpd

  1. First, let’s make sure our Raspberry PI software is up to date:
$ sudo apt-get update
$ sudo apt-get upgradeCopy the code
  1. We also need to remove Apache2, so skip this step if you have already removed it from your system.
$ sudo apt-get remove apache2Copy the code
  1. Now you can install Lighttpd.
$ sudo apt-get install lighttpdCopy the code
  1. Once Lighttpd is installed correctly, we need to make sure it works. Use either browser and enter raspberry PI’s LAN address to access it. If you do not know the LAN address, you can use the following command to obtain:
$ hostname -ICopy the code

You should see the following page:

  1. If this page is too ugly for you, you can modify it yourself:
$ sudo vim /var/www/html/index.htmlCopy the code

Install LighttpdPHP

  1. In this tutorial, we will use PHP-fPM, version PHP7. Why use PHP7 instead of PHP5? Because OF the PHP7 update, performance is better and memory management is better.
  2. We can install phP-FPM by:
$sudo apt-get install PHP7.0-fpmCopy the code

Configuration Lighthttpd

  1. After installing PHP-fpm, we need to run the following two commands to create two hyperlinks, which will read the two Settings for PHP when Lighttpd runs.
$ sudo lighttpd-enable-mod fastcgi
$ sudo lighttpd-enable-mod fastcgi-phpCopy the code
  1. Lighttpd runs php-cgi instead of php-fpm by default, we can run php-fpm by modifying the following configuration files:
$ sudo vim /etc/lighttpd/conf-available/15-fastcgi-php.confCopy the code

Modify the configuration file as follows:

# -*- depends: fastcgi -*- # /usr/share/doc/lighttpd/fastcgi.txt.gz # http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi ## Start an FastCGI Server += (".php" => (("socket" => "/var/run/ PHP /php7.0-fpm. Sock ",  "broken-scriptfilename" => "enable" )) )Copy the code
  1. With everything in place, we can restart Lighthttpd.
$ sudo service lighttpd force-reloadCopy the code
  1. After the restart, we can write a PHP file to verify that our configuration is working.
$ sudo vim /var/www/html/index.phpCopy the code

The content of the document is as follows:

<? php phpinfo() ? >Copy the code
  1. Finally, we are accessing raspberry PI in the same way as in step 4. If you can see a page with PHP information, then we have successfully built Lighttpd Web server using PHP on Raspberry PI.

All you see is true love. Why don’t you like it before you leave? Your “sanlian” is the biggest motivation for liang Xu’s continuous creation!

  1. Pay attention to the original public number “good Xu Linux”, the first time to get the latest Linux dry goods!
  2. Public number background reply [information] [interview] [resume] to get selected first-line big factory interview, self-improvement, resume and other information.
  3. Follow my blog: lxLinux.net