12

I've installed lighttpd, and it is working fine. I've tried to install php5 as described here, but when I try the last step

sudo service lighttpd force-reload

I get:

[FAIL] Reloading web server configuration: lighttpd failed!

and php is not working.

My lighttpd configuration can be found at http://pastebin.com/eagG4SwF:

server.modules = (
        "mod_fastcgi",
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
)

        server.document-root        = "/mnt/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80
        server.follow-symlink       = "enable"
        server.dir-listing          = "enable"
        dir-listing.encoding = "utf-8"

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
Euphorbium
  • 539
  • 2
  • 7
  • 15

2 Answers2

3

I've got mine working by following instruction from Running a lightweight webserver on the Raspberry Pi (lighttpd).

Summary of the steps required following the link above.

  1. Install lighttpd -> sudo apt-get install lighttpd

  2. Install mysql database (optional) -> sudo apt-get install mysql-server mysql root password will be prompt upon completion of installation

  3. Install PHP -> sudo apt-get install php5-common php5-cgi php5 php5-mysql

    NOTE it's important to install in the order listed above. If you try to install php5 without first installing the php5-cgi package then it will install Apache as well, which we don't want for this light-weight lighttpd server.

  4. Install php mysql libraries -> sudo apt-get install php5-mysql

  5. Enable lighttpd to handle php -> sudo lighty-enable-mod fastcgi-php followed by reloading lighttpd sudo service lighttpd force-reload

  6. Set permission for /var/www -> sudo chown www-data:www-data /var/www, then allow group to write to the dir sudo chmod 775 /var/www, followed by adding pi to the www-data group sudo usermod -a -G www-data pi

  7. Logout/Login to pickup group permission so pi can also write to the /var/www dir

faulty
  • 146
  • 4
  • What if apache got installed, when I installed php using just: apt-get install php5 ? How can I return to the previous state? – Euphorbium Aug 01 '12 at 17:59
  • @Euphorbium you can remove it by sudo apt-get autoremove apache or whichever version of apache you've installed. The reason to use autoremove is to remove dependency as well. http://superuser.com/questions/398670/when-would-you-use-apt-get-remove-over-apt-get-autoremove – faulty Aug 02 '12 at 10:06
  • As the top result on Google I thought it worth pointing out that the command to install php is now sudo apt-get install php-common php-cgi php php-mysql – Gavin Dec 02 '20 at 06:16
1

I have lighttpd/php working on my Pi:

I also have moved my www folder to a mounted drive.

In my case I've sim-linked /var/www to the folder on /mnt/usb/www (as I have it), rather than changing the config in lighttpd.conf itself.

The other thing that stands out doing a comparison is that I have the section below at the end of the file:

fastcgi.server = ( ".php" => ((
                     "bin-path" => "/usr/bin/php5-cgi",
                     "socket" => "/tmp/php.socket"
                 )))

I'll try to find the instructions I followed to set it all up and edit here.

Edit: I may have based my setup on this but I can't be sure.

Jon Egerton
  • 3,083
  • 2
  • 22
  • 32