Sunday, September 14, 2008

How to install Lighttpd with PHP and MySQL to Fedora Core

Lighttpd, or light, is a fast, light and secure webserver which is designed and optimized for speed-critical environments. Many huge websites (Youtube, Wikipedia for example) use lighttpd to serve static content. Also many sites that get more than thousand hits / second use lighty.

Compared to Apache HTTPD or nginx, Lighttpd is not as fust as nginx but it is easier to configure and implement. Compared to Apache, it is faster but has less options. You have to consider which httpd server to use. I personally love to use Apache because of its modules, but I wouldn't hesitate to change to lighty!

1) Install MySQL

First thing you need to do - if you don't allready have MySQL installed - is to install MySQL.

You can do this any way you want, but the easiest way is to use YUM:

yum install mysql mysql-server

Make sure you start mysqld. You should also make sure your mysqld starts when your linux starts up:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

I personally install mysql server from binaries but this is the easiest and fastest way to get your mysql server up and running.

When you install your mysql server, there is no password set for mysql root user. Unless you're using some virtual linux running on your personal laptop used only for developing things, change this immediatelly!

mysqladmin -u root password newpassword

Installing Lighttpd

Since we're using Fedora and we're able to use Yum to install applications, we install lighty this way:

yum install lighttpd

Next, start up your lighty and make sure it starts up when restarting your linux server:

chkconfig --levels 235 lighttpd on
/etc/init.d/lighttpd start

You can now test your ligty. Go to and you should get a page like this:

3) Install PHP

Lighttpd can use FastCGI to render PHP pages. This can be also installed with YUM:

yum install lighttpd-fastcgi php-cli

That's it! Restart your lighty and you're all good to go!

No comments: