Lighttpd – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Sun, 20 Apr 2014 12:07:05 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How to Install Lighttpd with PHP and MariaDB on CentOS/RHEL 6/5 https://tecadmin.net/install-lighttpd-with-php-mariadb-centos-redhat/ https://tecadmin.net/install-lighttpd-with-php-mariadb-centos-redhat/#respond Sun, 20 Apr 2014 12:07:05 +0000 https://tecadmin.net/?p=4811 Lighttpd is an alternative to Apache. It is a opensource web server. Lighttpd is popular for its low memory and cpu uses, This can be best option for high traffic sites. PHP is a programming language used server-side programming. MariaDB is an alternative of MySQL with various of enhancements. Step 1: Add Required Yum Repositories [...]

The post How to Install Lighttpd with PHP and MariaDB on CentOS/RHEL 6/5 appeared first on TecAdmin.

]]>
Lighttpd is an alternative to Apache. It is a opensource web server. Lighttpd is popular for its low memory and cpu uses, This can be best option for high traffic sites. PHP is a programming language used server-side programming. MariaDB is an alternative of MySQL with various of enhancements.

Step 1: Add Required Yum Repositories

Before starting setup, make sure that we have required yum repositories added in our system. We recommend to add MariaDB, EPEL and REMI yum repositories in our system.

https://downloads.mariadb.org/mariadb/repositories/#mirror=nus
https://tecadmin.net/top-5-yum-repositories-for-centos-rhel-systems/#centalt-repo
https://tecadmin.net/top-5-yum-repositories-for-centos-rhel-systems/#remi-repo

Step 2: Install Lighttpd

Lets start with the installation of lighttpd web server with fastcgi support using following command

# yum install lighttpd lighttpd-fastcgi

Now edit Lighttpd configuration file /etc/lighttpd/lighttpd.conf and update following values.

server.use-ipv6 = "disable"
server.max-fds = 2048

Now start Lighttpd service

# service lighttpd start

Step 3: Install MariaDB

Assuming that you have already added MariaDB yum repositories, Let’s use the following command to install MariaDB on your system

# yum install MariaDB-server MariaDB-client

Start MaraiDB service

# service mysql start

Complete the post installation setup to secure your MariaDB

# mysql_secure_installation

Step 4: Install PHP and PHP-FPM

Install PHP, PHP-FPM and php-mysql packages using below command

# yum --enablerepo=epel,remi install php php-fpm php-mysql

Edit configuration file /etc/php-fpm.d/www.conf an update following values

 listen = 127.0.0.1:9000
 user = lighttpd
 group = lighttpd

Step 5: Configure FASTCGI and PHP-FPM

Enable PHP5 in Lighttpd, Edit the php configuration file /etc/php.ini and uncomment following line

 cgi.fix_pathinfo=1

Now edit Lighttpd modules configuration /etc/lighttpd/modules.conf and uncomment following line to enable fastcgi support

 include "conf.d/fastcgi.conf"

Now edit Lighttpd fastcgi configuration file /etc/lighttpd/conf.d/fastcgi.conf and add following values

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

Restart all services using following commands and enable them to auto start on system boot

# service lighttpd restart
# service php-fpm restart

# chkconfig lighttpd on
# chkconfig php-fpm on

Step 6: Verify Setup

At this point we have successfully completed all the configuration. Lets create an info.php file in your document root with following content.

<?php
phpinfo();
?>

php-with-lighttpd

The post How to Install Lighttpd with PHP and MariaDB on CentOS/RHEL 6/5 appeared first on TecAdmin.

]]>
https://tecadmin.net/install-lighttpd-with-php-mariadb-centos-redhat/feed/ 0
Install Lighttpd Web Server on CentOS/RHEL 6/5 using Yum https://tecadmin.net/install-lighttpd-web-server-centos-rhel/ https://tecadmin.net/install-lighttpd-web-server-centos-rhel/#comments Fri, 18 Apr 2014 09:34:01 +0000 https://tecadmin.net/?p=4770 Lighttpd is high performance web server created suitable for running on production environment. It is highly optimize, secure and very flexible web server. Lighttpd utilize very low Memory and CPU than other web servers. Its event-driven architecture is optimized for a large number of parallel connections (keep-alive) Lighttpd powers several popular Web 2.0 sites. It [...]

The post Install Lighttpd Web Server on CentOS/RHEL 6/5 using Yum appeared first on TecAdmin.

]]>
Lighttpd is high performance web server created suitable for running on production environment. It is highly optimize, secure and very flexible web server. Lighttpd utilize very low Memory and CPU than other web servers. Its event-driven architecture is optimized for a large number of parallel connections (keep-alive)

Lighttpd powers several popular Web 2.0 sites. It provides high speed io-infrastructure which allows them to scale several times better with the same hardware. This is developed with keeping future web in mind like:

    • Faster FastCGI
    • COMET meets mod_mailbox
    • Async IO

Follow the steps below to install Lighttpd on RHEL based systems.

Step 1: Add EPEL Repository

At the time of writing article EPEL yum repository have the latest package of Lighttpd, First add EPEL yum repository your system.

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Step 2: Install Lighttpd Server

Install Lighttpd using yum package manager

# yum install lighttpd lighttpd-fastcgi
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirror.nbrc.ac.in
 * epel: mirrors.ispros.com.bd
 * extras: mirror.nbrc.ac.in
 * updates: mirror.nhanhoa.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package lighttpd.i686 0:1.4.35-1.el6 will be installed
---> Package lighttpd-fastcgi.i686 0:1.4.35-1.el6 will be installed
--> Processing Dependency: spawn-fcgi for package: lighttpd-fastcgi-1.4.35-1.el6.i686
--> Running transaction check
---> Package spawn-fcgi.i686 0:1.6.3-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================
 Package                       Arch              Version                   Repository         Size
===================================================================================================
Installing:
 lighttpd                      i686              1.4.35-1.el6              epel              300 k
 lighttpd-fastcgi              i686              1.4.35-1.el6              epel               45 k
Installing for dependencies:
 spawn-fcgi                    i686              1.6.3-1.el6               epel               16 k

Transaction Summary
===================================================================================================
Install       3 Package(s)

Total download size: 361 k
Installed size: 818 k
Is this ok [y/N]: y
Downloading Packages:
(1/3): lighttpd-1.4.35-1.el6.i686.rpm                                       | 300 kB     00:00
(2/3): lighttpd-fastcgi-1.4.35-1.el6.i686.rpm                               |  45 kB     00:00
(3/3): spawn-fcgi-1.6.3-1.el6.i686.rpm                                      |  16 kB     00:00
---------------------------------------------------------------------------------------------------
Total                                                              206 kB/s | 361 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
google-chrome-stable-34.0.1847.116-1.i386 has missing requires of libnss3.so(NSS_3.14.3)
  Installing : lighttpd-1.4.35-1.el6.i686                                                      1/3
  Installing : spawn-fcgi-1.6.3-1.el6.i686                                                     2/3
  Installing : lighttpd-fastcgi-1.4.35-1.el6.i686                                              3/3

Installed:
  lighttpd.i686 0:1.4.35-1.el6                 lighttpd-fastcgi.i686 0:1.4.35-1.el6

Dependency Installed:
  spawn-fcgi.i686 0:1.6.3-1.el6

Complete!

Step 3: Configure Lighttpd Server

Before starting Lighttpd configuration, make sure you have selinux disabled in your system.

# getenforece

Now edit Lighttpd configuration file /etc/lighttpd/lighttpd.conf and

server.use-ipv6 = "disable"
server.max-fds = 2048

server.use-ipv6: Set this value ot ‘diable’ will allow server to listen on IPv6 connections and disabled IPv6 connection.

server.max-fds Lighttpd is single-threaded server, its main resource limit is the number of file descriptors, which is set to 1024 by default (on most systems). To handle high traffic site set this to 2048.

Step 4: Start Lighttpd Server

Finally start Lighttpd service using following command.

# service lighttpd start

lighttpd-setup

To stop or restart server use following command.

# service lighttpd stop
# service lighttpd restart

Make Lighttpd to start on server boot

# chkconfig lighttpd on

The post Install Lighttpd Web Server on CentOS/RHEL 6/5 using Yum appeared first on TecAdmin.

]]>
https://tecadmin.net/install-lighttpd-web-server-centos-rhel/feed/ 1
How to Configure SSL in Lighttpd Server https://tecadmin.net/configure-ssl-in-lighttpd-server/ https://tecadmin.net/configure-ssl-in-lighttpd-server/#respond Mon, 24 Mar 2014 07:20:14 +0000 https://tecadmin.net/?p=4797 All the sites running with SSL are used https protocol on default port 443. SSL provides secure data communication by encrypting data between server and client. In our earlier articles we have described about installing lighttpd and creating virtualhosts in CentOS/RHEL systems. This article will help you to configure SSL in Lighttpd server. For this [...]

The post How to Configure SSL in Lighttpd Server appeared first on TecAdmin.

]]>
All the sites running with SSL are used https protocol on default port 443. SSL provides secure data communication by encrypting data between server and client. In our earlier articles we have described about installing lighttpd and creating virtualhosts in CentOS/RHEL systems. This article will help you to configure SSL in Lighttpd server. For this example we are using an self signed certificate.

If you are looking for configure ssl in Apache/HTTPD, then you have to this article.

Step 1: Create Certificate Signing Request (CSR)

For creating SSL certificate, the first requirement is to create private key and CSR. A CSR is an file which have all details about domain including an public key. first create a directory where to create csr and key.

# mkdir /etc/lighttpd/ssl/
# cd /etc/lighttpd/ssl/

Now create CSR and key file with following command. Change name of files example.com.key and example.com.csr as per your domains. This command will ask for enter information about your domain. Read more about creating CSR.

# openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
Generating a 2048 bit RSA private key
....+++
...............+++
writing new private key to 'example.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Delhi
Locality Name (eg, city) [Default City]:Delhi
Organization Name (eg, company) [Default Company Ltd]:TecAdmin Inc.
Organizational Unit Name (eg, section) []:web
Common Name (eg, your name or your server's hostname) []:example.com
Email Address []:user@example.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: [Leave Blank]
An optional company name []: [Leave Blank]

Step 2: Request Certificate from CA

After creating CSR, Request an SSL certificate from any certificate providers like Geotrust, Comodo, Digicert or GoDaddy etc.

or create a self signed certificate for internal use. We do not recommend this for production sites.

# openssl x509 -req -days 365 -in example.com.csr -signkey example.com.key -out example.com.crt

You will get created certificate file in current directory with name example.com.crt. Now create pem file by combining key file and certificate in one file

# cat example.com.key  example.com.crt > example.com.pem

Step 3: Setup VirtualHost with SSL

Edit Lighttpd configuration file /etc/lighttpd/lighttpd.conf and add the following values.

$SERVER["socket"] == ":443" {
        ssl.engine = "enable"
        ssl.pemfile = "/etc/lighttpd/ssl/tecadmin.net.pem"
      # ssl.ca-file = "/etc/lighttpd/ssl/CA_issuing.crt"
        server.name = "site1.tecadmin.net"
        server.document-root = "/sites/vhosts/site1.tecadmin.net/public"
        server.errorlog = "/var/log/lighttpd/site1.tecadmin.net.error.log"
        accesslog.filename = "/var/log/lighttpd/site1.tecadmin.net.access.log"
}

Step 4: Verify Configuration & Restart Lighttpd

Verify syntax of configuration file before starting lighttpd service.

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

Syntax OK

If you found that all syntax is ok, lets restart service

# service lighttpd restart

The post How to Configure SSL in Lighttpd Server appeared first on TecAdmin.

]]>
https://tecadmin.net/configure-ssl-in-lighttpd-server/feed/ 0
How to Setup VirtualHosts in Lighttpd Server https://tecadmin.net/setup-virtualhosts-in-lighttpd-server/ https://tecadmin.net/setup-virtualhosts-in-lighttpd-server/#comments Sun, 23 Mar 2014 13:22:15 +0000 https://tecadmin.net/?p=4787 VirtualHosting is an implementation of hosting multiple domains on single server. It enabled to utilize maximum resources of server and reduces cost. Now a days mostly all web servers supports virtualhosting environment. In our earlier article we describe to install Lighttpd server on CentOS/RHEL. This article will help you to setup VirtualHosts in Lighttpd server. [...]

The post How to Setup VirtualHosts in Lighttpd Server appeared first on TecAdmin.

]]>
VirtualHosting is an implementation of hosting multiple domains on single server. It enabled to utilize maximum resources of server and reduces cost. Now a days mostly all web servers supports virtualhosting environment. In our earlier article we describe to install Lighttpd server on CentOS/RHEL. This article will help you to setup VirtualHosts in Lighttpd server.

For example we are using following domains-

  1. site1.tecadmin.net
  2. site2.tecadmin.net

Step 1: Create Server Document Root

First create folders for both domains (if not exists)

# mkdir -p /sites/vhosts/site1.tecadmin.net/www
# mkdir -p /sites/vhosts/site2.tecadmin.net/www

For testing purpose we are creating an index.html file at both document roots

# echo "Welcome to Site1" > /sites/vhosts/site1.tecadmin.net/www/index.html
# echo "Welcome to Site2" > /sites/vhosts/site2.tecadmin.net/www/index.html

Step 2: Update Main Configuration File

Now edit Lighttpd main configuration file /etc/lighttpd/lighttpd.conf and enable to include virtualhosts files. Uncomment following line by removing starting # symbol.

include_shell "cat /etc/lighttpd/vhosts.d/*.conf"

Step 3: Create VirtualHost Configuration Files

Now start creating virutalhost configuration file for both domains or subdomains, First creating for site1.tecadmin.net

# vim /etc/lighttpd/vhosts.d/site1.tecadmin.net.conf
$HTTP["host"] == "site1.tecadmin.net" {

        server.document-root = "/sites/vhosts/site1.tecadmin.net/public"
        server.errorlog = "/var/log/lighttpd/site1.tecadmin.net.error.log"
        accesslog.filename = "/var/log/lighttpd/site1.tecadmin.net.access.log"
}

Now create configuration file for site2.tecadmin.net

# vim /etc/lighttpd/vhosts.d/site2.tecadmin.net.conf
$HTTP["host"] == "site2.tecadmin.net" {

        server.document-root = "/sites/vhosts/site2.tecadmin.net/public"
        server.errorlog = "/var/log/lighttpd/site2.tecadmin.net.error.log"
        accesslog.filename = "/var/log/lighttpd/site2.tecadmin.net.access.log"
}

Step 4: Verify Configuration and Restart Lighttpd

After making all above configuration, first verify the syntax of all configuration file including main configuration file with

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

Syntax OK

If you found that all syntax is ok, lets restart service

# service lighttpd restart

Now test your both domain in browser and check that you are getting correct content on pages as created in step 1. For more details about VirtualHosts in Lighttpd visit its official site.

The post How to Setup VirtualHosts in Lighttpd Server appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-virtualhosts-in-lighttpd-server/feed/ 1