How to Install PHP on a Lighttpd Web Server in Linux


In this article, we show how to install PHP on a lighttpd web server in linux.

Lighttpd server is a type of server that is useful in different occasions.

In some ways, lighttpd is superior to the apache web server in that it is able to deliver static content such as videos and images with much higher speed than apache can. lighttpd is optimized for sending static content (videos, images,...)

So using the lighttpd web server can be very advantageous for media content.

Therefore, with these advantages that lighttpd offers, we can use it as a web server.

While using lighttpd as a web server, you would configure just as any other web server such as an apache web server. You can do things such as install PHP on a lighttpd web server. Therefore, we can use the scripting, server-side language of PHP on the lighttpd web server.

So we will now go over how to install PHP on a linux web server, particularly on Ubuntu linux.

So before we perform the installation of lighttpd, we should do all necessary updates and upgrades.

This is accomplished with the lines shown below.

These two lines perform the necessary updates and upgrades to the linux system.

Now we are ready to install PHP on the lighttpd web server on our linux server.

This is done by the following line shown below.

So we will see the installation process of PHP after running this line of code.

Once the whole process is completed and PHP has been successfully installed, we can now run PHP code on the lighttpd web server.

So all you have to do to test PHP now is to create a PHP file in the /var/www/html directory.

I'll call this file, hello.php

To create this file, from the / directory, I specify the following line of code.

So now we've created a file called hello.php

Just to test out PHP, we will create a simple PHP script. This is shown below.

So now we save this file in the nano editor by pressing Ctrl+X and saving when prompted to.

Next, go to your web browser and type in the IP address of your server followed by /hello.php

This should create the following page below.

Running PHP on a lighttpd server

And this is all that is necessary in order to install PHP on a lighttpd web server using Ubuntu linux.

Related Resources

How to Randomly Select From or Shuffle a List in Python

HTML Comment Box is loading comments...