Configuration of PHP on LIGHTTPD

Source: Internet
Author: User
First use php-cgi-v to see if PHP supports fastcgi. The output on my machine is as follows:

PHP 5.2.4-2ubuntu5.1 with Suhosin-patch 0.9.6.2 (cgi-fcgi) (Built:may 9 2008 16:26:18)
Copyright (c) 1997-2007 the PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technol

Then find the location of php-cgi:

Which php-cgi

Output:/usr/bin/php-cgi

For the newer version of the LIGHTTPD, the configuration file made a more reasonable processing, many online tutorials said to modify the/etc/lighttpd/lighttpd.conf. If you are installing a newer version, you have a 10-fastcgi.conf file under/etc/lighttpd/conf-avalible.

First back up:

sudo cp 10-fastcgi.conf bak.10-fastcgi.conf

Then open:

sudo vim 10-fastcgi.conf

The simplest configuration for adding or modifying content is as follows:

Fastcgi.server= (
". php" = (
"Bin-path" = "/usr/bin/php-cgi" #上文中which location found php-cgi
"Socket" = "Tmp/php.socket"
))
)

Of course, you can also configure a lot of other content such as Max-proces/idle-timeout. Restart LIGHTTPD after configuration is complete:

SUDO/ETC/INIT.D/LIGHTTPD restart

-----If you want to enable the. html to. PHP Mapping

It is important to note that the Mod_compress module must be closed first. The initial configuration in the lighttpd.conf file is:

Server.modules = (
"Mod_access",
"Mod_alias",
"Mod_accesslog",
"Mod_compress",
# "Mod_rewrite",
....
....

Compress.cache-dir = "/var/cache/lighttpd/compress/"
Compress.filetype = ("Text/plain", "text/html", "application/x-JavaScript", "Text/css")
....
....

Here are two options: either comment out the mod_compress, or cancel the compression of the. html file. Here to remove text/html from the Compress.filetype.

Then open 10-fastcgi.conf, add

Fastcgi.map-extensons= (". html" = ". php")

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.