"Reprint" How to install Lighttpd Web Server in Ubuntu 15.04/centos 7

Source: Internet
Author: User
Tags intl mcrypt pear phpinfo

LIGHTTPD is an open source Web server software. The LIGHTTPD is safe, fast, industry-standard, adaptable and optimized for high-configuration environments. LIGHTTPD consumes less memory than other Web servers, and stands out from many Web servers in terms of efficiency and speed because of its small CPU footprint and optimized processing speed. Advanced features such as FastCGI, CGI, authentication, output compression, URL rewriting, and so on, are the Lighttpd of servers that face performance stress.

Here is a brief process for installing the LIGHTTPD WEB Server on a machine running Ubuntu 15.04 or CentOS 7 Linux distributions.

Installing LIGHTTPD using the Package Manager installation

Here we install LIGHTTPD by using the Package Manager as the simplest method. Simply enter the instructions below in the terminal or console in sudo mode.

CentOS 7

Since LIGHTTPD is not available in the CentOS 7.0 official warehouse, we need to install additional software source Epel repositories in the system. Use the following Yum instructions to install Epel.

# yum install epel-release

Then we need to update the system and prepare for the LIGHTTPD installation.

# yum update
# yum install lighttpd

Install Lighttpd Centos

Ubuntu 15.04

LIGHTTPD is included in the Ubuntu 15.04 official warehouse, so just update the local warehouse index and use the Apt-get directive to install LIGHTTPD.

# apt-get update
# apt-get install lighttpd

Install lighttpd Ubuntu

Installing LIGHTTPD from source code

If you want to install the latest version from LIGHTTPD source (e.g. 1.4.39), we need to compile the source code locally and install it. First, we need to install the dependent packages required to compile the source code.

# cd /tmp/
# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz

After the download is complete, perform the following instructions to unzip it.

# tar -zxvf lighttpd-1.4.39.tar.gz

Then use the following instructions to compile.

# cd lighttpd-1.4.39
# ./configure
# make

Note: In this tutorial, we installed the default configuration of LIGHTTPD. Other expansion functions, such as support for SSL, modrewrite,modRedirect, etc., need to be configured on their own.

When the compilation is complete, we can install it into the system.

# make install


If there is a higher demand, we can further set the LIGHTTPD by modifying the default settings file, for example/etc/lighttpd/lighttpd.conf. In this tutorial we will use the default settings and do not modify the settings file. If you have made changes and want to check the settings file for errors, you can execute the instructions below.

# lighttpd -t -f /etc/lighttpd/lighttpd.conf

Using CentOS 7

In CentOS 7, we need to create a Webroot folder that is set in the LIGHTTPD default profile, for example/src/www/htdocs.

# mkdir -p /srv/www/htdocs/

The default welcome page is then/var/www/lighttpdcopied from the newly created directory:

# cp -r /var/www/lighttpd/* /srv/www/htdocs/

Open service

Now, restart the Web service by executing the SYSTEMCTL directive.

# systemctl start lighttpd

Then we set it up to accompany the system startup Autorun.

# systemctl enable lighttpd

Set up a firewall

To make the Web page or website we run on LIGHTTPD accessible on the Internet or within the same network, we need to set open port 80 in the firewall program. Since CentOS 7 and Ubuntu15.04 both come with SYSTEMD as the default initialization system, we use the default FIREWALLD. If you want to open the 80 port or HTTP service, we just need to execute the following command:

# firewall-cmd --permanent --add-service=http
# firewall-cmd --reload

Connect to a WEB server

After setting port 80 as the default port, we have direct access to the default welcome page for LIGHTTPD. We need to set the IP address and domain name of the browser according to the device running LIGHTTPD. In this tutorial, we make the browser access the http://lighttpd.linoxide.com/and point the subdomain to the above IP address. In this way, we can see the following welcome page in the browser.

LIGHTTPD Welcome Page

In addition, we can add the file of the website to the Webroot directory and delete the LIGHTTPD default index file so that our static website can be accessed on the Internet.

If you want to run a PHP application in the LIGHTTPD Web server, refer to the following steps:

Installing the PHP5 module

After the successful installation of LIGHTTPD, we need to install PHP and related modules to run the PHP5 script in Lighttpd.

Using Ubuntu 15.04

# apt-get install php5 php5-cgi php5-fpm php5-mysql php5-curl php5-gd php5-intl php5-imagick php5-mcrypt php5-memcache php-pear

Using CentOS 7

# yum install php php-cgi php-fpm php-mysql php-curl php-gd php-intl php-pecl-imagick php-mcrypt php-memcache php-pear lighttpd-fastcgi

Set up PHP services for LIGHTTPD

For PHP to work with LIGHTTPD, we only need to perform the following instructions according to the distribution we are using.

Using CentOS 7

The first thing to do is to use the file editor to edit the PHP settings file (for example/etc/php.ini) and cancel out the comment on thecgi.fix_pathinfo=1line.

# nano /etc/php.ini

After completing the above steps, we need to transfer the ownership of the PHP-FPM process from Apache to LIGHTTPD. To do this, first open the file with the file editor/etc/php-fpm.d/www.conf.

# nano /etc/php-fpm.d/www.conf

Then add the following statement to the file:

user = lighttpd
group = lighttpd

With this done, we save and exit the text editor. Then/etc/lighttpd/modules.confadd the FastCGI module from the settings file.

# nano /etc/lighttpd/modules.conf

Then, remove the comment that precedes the following statement#to uncomment it.

include "conf.d/fastcgi.conf"

Finally, we also need to set the FastCGI settings file in the text editor.

# nano /etc/lighttpd/conf.d/fastcgi.conf

Add the following code to the tail of the file:

fastcgi.server += ( ".php" =>
"host" => "",
"port" => "9000",
"broken-scriptfilename" => "enable"

Save and exit the text editor when you are finished editing.

Using Ubuntu 15.04

If you want to enable LIGHTTPD FastCGI, simply execute the following code:

   # lighttpd-enable-mod fastcgi
Enabling fastcgi: ok
Run /etc/init.d/lighttpd force-reload to enable changes
# lighttpd-enable-mod fastcgi-php
Enabling fastcgi-php: ok
Run `/etc/init.d/lighttpd` force-reload to enable changes

Then, execute the following command to restart LIGHTTPD.

# systemctl force-reload lighttpd

Detecting PHP Working Status

To detect if PHP is working as expected, we need to create a new PHP file in the Lighttpd Webroot directory. In this tutorial, under Ubuntu/var/www/html directory, under CentOS/src/www/htdocs directory, use a text editor to create and open info.php.

Using CentOS 7

# nano  /var/www/info.php

Using Ubuntu 15.04

# nano /srv/www/htdocs/info.php

Then simply add the following statement to the file.

<?php phpinfo(); ?>

Save and eject the text editor when the edits are complete.

Now we need to get our web browser to point to LIGHTTPD running on the system, based on the IP address or domain name of the info.php file under Path http://lighttpd.linoxide.com/info.php. If everything is done as described above, we will see the PHP page information as shown.

Phpinfo lighttpd


At this point, we have successfully installed a lightweight, fast and secure LIGHTTPD Web server on the CentOS 7 and Ubuntu 15.04 Linux distributions. Now we can upload Web site files to the Web site root directory, configure virtual hosts, enable SSL, connect to the database, run Web apps on our Lighttpd Web server, and more. If you have any questions, suggestions or feedback please write down in the comments section below to let us better improve the Lighttpd. Thank you!


Arun Pyasi Translator: Haohongwang proofreading: Wxy

This article was compiled by LCTT original, Linux China honors launched

"Reprint" How to install Lighttpd Web Server in Ubuntu 15.04/centos 7

Related Article

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.