{"id":475,"date":"2017-08-13T03:16:31","date_gmt":"2017-08-13T02:16:31","guid":{"rendered":"http:\/\/www.adienicholls.co.uk\/blog\/?p=475"},"modified":"2024-04-30T03:17:09","modified_gmt":"2024-04-30T02:17:09","slug":"install-lighttpd-with-php-and-a-custom-web-page","status":"publish","type":"post","link":"http:\/\/www.adienicholls.co.uk\/blog\/install-lighttpd-with-php-and-a-custom-web-page\/","title":{"rendered":"Install Lighttpd with PHP and a custom web page"},"content":{"rendered":"<p><a href=\"https:\/\/www.lighttpd.net\/\" target=\"_blank\" rel=\"noopener\">Lighttpd<\/a> web server has been chosen for this project, you can use Apache or anything else you like that supports PHP, I found others a little heavy for this.<\/p>\n<p>As normal, ensure your system is up to date and cleanup any archived download packages using the below code;<\/p>\n<p class=\" language-bash\"><code class=\" language-bash\">sudo apt<span class=\"token operator\">-<\/span>get update &amp;&amp; sudo apt<span class=\"token operator\">-<\/span>get dist<span class=\"token operator\">-<\/span>upgrade<\/code><\/p>\n<p><code>sudo apt-get clean<\/code><\/p>\n<h2>Install Lighttpd<\/h2>\n<p>After running the update and cleanup from above, go for launch!<\/p>\n<p><code>sudo apt-get install lighttpd<\/code><\/p>\n<p>Reboot the system to get all the services up and running together.<\/p>\n<p><code>sudo reboot now<\/code><\/p>\n<h2>www-data Permissions<\/h2>\n<p>I think there is a miss conception concerning the folder permissions for this section,\u00a0 most instructions that I have come across say to add the <em>pi<\/em> user to the <em>www-data<\/em> group to allow modify access the the files.<\/p>\n<p>I think this is wrong as the Lighttp daemon runs in its own service with access to no writable files\/folders, apart from \\tmp. This is great for security, but if you add the <em>pi<\/em> user to this group, you are then allowing write access to your web folder.<\/p>\n<p>Instead, the <em>pi<\/em> user takes ownership of the <em>www-data<\/em> folder and provides Lighttp with read and modify access to only the files it needs.<\/p>\n<pre>sudo chown -R pi:www-data \/var\/www<\/pre>\n<pre>sudo chmod u+rxw,g+rx-w,o-rwx \/var\/www<\/pre>\n<pre>sudo chmod g+s \/var\/www<\/pre>\n<p><a href=\"https:\/\/ss64.com\/bash\/chmod.html\" target=\"_blank\" rel=\"noopener\">chmod documentation: https:\/\/ss64.com\/bash\/chmod.html<\/a><\/p>\n<h2>Install PHP<\/h2>\n<p>Install php7.0 including it&#8217;s dependencies<\/p>\n<p><code class=\"bash plain\">sudo apt-get install php7.0-common php7.0-cgi php7.0<\/code><\/p>\n<p>To enable Lighttp with PHP FastCGI, use the below code;<\/p>\n<p><code class=\"bash plain\"><code>sudo lighty-enable-mod fastcgi-php<\/code><\/code><\/p>\n<p>Reload the service;<\/p>\n<p><code>sudo service lighttpd force-reload<\/code><code class=\"bash plain\"><br \/>\n<\/code><\/p>\n<h2>Testing time<\/h2>\n<p>From another device, using an internet browser, navigate to your Raspberry Pi&#8217;s address i.e. http:\/\/<span class=\"_Tgc _s8w\">raspberrypi or the hostname updated in the<a href=\"http:\/\/www.adienicholls.co.uk\/pigrow\/install-raspbian-lite-with-simple-rasp-config-changes\/\"> install section<\/a>. <\/span><\/p>\n<p>If no page loads, check the logs Lighttp logs located at \/var\/log\/lighttpd\/error.log<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lighttpd web server has been chosen for this project, you can use Apache or anything else you like that supports PHP, I found others a little heavy for this. As normal, ensure your system is up to date and cleanup any archived download packages using the below code; sudo apt-get update &amp;&amp; sudo apt-get dist-upgrade &hellip; <a href=\"http:\/\/www.adienicholls.co.uk\/blog\/install-lighttpd-with-php-and-a-custom-web-page\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Install Lighttpd with PHP and a custom web page<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[258,260,257,259],"_links":{"self":[{"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/posts\/475"}],"collection":[{"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=475"}],"version-history":[{"count":1,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/posts\/475\/revisions"}],"predecessor-version":[{"id":476,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/posts\/475\/revisions\/476"}],"wp:attachment":[{"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=475"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.adienicholls.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}