Mar. Mar 5th, 2024

Lighttpd is a lightweight web server, which had long been following and I decided to install in an instance of Amazon EC2 micro to verify their low consumption of resources.

The installation described below is tested under AMZN-v0.9, operating system adapted Amazon by default in their bodies based on micro and CentOS.

To install you must perform the following steps:

– Installing Lighttpd typing in the terminal:

yum install lighttpd
After this we have installed lighttpd.

– Now we can start the service by typing in terminal:

service lighttpd start
To be able to serve pages written in PHP, you need to install the fastcgi module and do some extra settings.

– Install the packages lighttpd-fastcgi and php-cli

yum install lighttpd-fastcgi php-cli
The next step is to configure lighttpd to support php, open the file /etc/php.ini by typing in terminal:

vim /etc/php.ini
and added to the end of this line:

cgi.fix_pathinfo = 1
The following is edit /etc/lighttpd/lighttpd.conf typing in the terminal:

vi /etc/lighttpd/lighttpd.conf
and uncomment the line that says mod_fastcgi and mod_alias (remove the #) so it is like this:

server.modules = (
«mod_alias»
«mod_access»
«mod_fastcgi»
«mod_accesslog»)
The next thing is to edit the file /etc/lighttpd/cond.f/fastcgi.conf and uncomment the following lines:

# # # # Fastcgi module
# # Read fastcgi.txt for more info
# # For PHP do not forget to September cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server = («. php» =>
(«localhost» =>
(
«socket» => «/tmp/php-fastcgi.socket»
«bin-path» => «/usr/bin/php-cgi»
)
)
)
Save the changes and exit the editor.

Only restart Lighttpd is to apply the changes by typing:

service lighttpd restart
After that we have Lighttpd running and serving pages with fastcgi php.

The best way to check for proper operation is through a test file, which we call as you want and contain the following lines:

<?

phpinfo ();

?>

But what would a server without ssl certificates to secure communications?

Ssl configuration is quite simple:

First create a directory where we store the certificate:

mkdir /etc/lighttpd/ssl

And we will create a self signed certificate in

cd /etc/lighttpd/ssl
openssl req -new -x509 -keyout-out lighttpd.pem lighttpd.pem -days 365 -nodes
chmod 400 lighttpd.pem
Then edit /etc/lighttpd/lighttpd.conf and add:

$ SERVER [«socket»] == «443» {
ssl.engine = «enable»
ssl.pemfile = «/etc/lighttpd/ssl/lighttpd.pem»
}
Reboot the server and ready!

In future posts I will continue delving into a more comprehensive and secure setting and prove the basic user authentication and rewriting.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *