We previously showed you how to install Nginx and Apache2 on Ubuntu 14.04 and now, this brief tutorial is going to show you how to install Lighttpd web server in Ubuntu 14.04 with PHP5, MySQL support.
Most webmasters know a lot about Apache2 and Nginx web servers, but only few know about Lighttpd or how to install and use it. For those who don’t know about Lighttpd web server, here’s an overview.
Lighttpd is a very light, very secure and flexible web server that’s trusted by millions of webmasters. This opensource web server has a small CUP footprint and very efficient memory management for high traffic websites. If your website is suffering from high traffic with resources being overloaded, then you may want to try Lighttpd.
There are more to be said about Lighttpd and you can find more information about this web server by searching online. But if you need to get in installed on your Ubuntu 14.04 machine, then continue below to learn how.
Lighttpd is also a perfect solution for WordPress hosting that many webmasters don’t know about. If you want to improve your WordPress blog performance, then take a peek and try Lighttpd.
When you’re ready to try Lighttpd, continue below to learn how to install and use it in Ubuntu 14.04.
- Installing Lighttpd on Ubuntu 14.04
To install Lighttpd on Ubuntu 14.04, all one has to do is run the commands below.
sudo apt-get update && sudo apt-get install lighttpd
After running the above commands, Ubuntu will download and install the webserver. After installing server continue below.
- Installing MySQL Database Server on Ubuntu 14.04
The next step is installing a database server. The most popular database server on Ubuntu is MySQL. To install it on Ubuntu 14.04, run the commands below.
sudo apt-get install mysql-server mysql-client
When you run the commands above to install MySQL database server, it should prompted you to create a root password during the installation. Create and confirm a root password to continue.
You’ll need this root password to connect to the database server later.
- Installing PHP and other PHP5 modules
Next, run the commands below to install PHP5 and other PHP modules.
sudo apt-get install php5 php5-fpm php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
After that , continue below to begin configuring the installed servers and services. First open the file below and change the value of cgi.fix_pathinfo to 1
sudo vi /etc/php5/fpm/php.ini
[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=1
[...]
|
If you open your browser and browse to your the host IP or name, you should see the default test page for Lighttpd web server as shown below.
The default site configure file for Lighttpd on Ubuntu is at /etc/lighttpd/lighttpd.conf
In that file, you can change any perimeters to match your environment. For example, the default document root is /var/www/.
You could change it to something else if your environment has a different location.
The default username and groupname for Lighttpd is www-data.
That’s it!
You can now add your WordPress site to the default document root directory, configure a database and you’re done. Search on this site for help creating databases on MySQL. We’ve written a lot on it.
Since most webmasters agree that using socket for PHP-FPM is better than TCP, here’ show to configure Lighttpd to use PHP-FPM to speed things up a bit.
Open Lighttpd configuration file for FastCGI and make the changes below.
sudo vi /etc/lighttpd/conf-available/15-fastcgi-php.conf
Then change the highlighted line to reference PHP-FPM socket.
[...]
# http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions#mod_fastcgi-fastcgi
## Start an FastCGI server for php (needs the php5-cgi package)
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php5-fpm.sock",
"broken-scriptfilename" => "enable"
))
)[...]
The default location for PHP-FPM socket on Ubuntu 154.04 is /var/run/php-fpm.sock
Then enable Lighttpd FastCGI module.
sudo lighttpd-enable-mod fastcgi
sudo lighttpd-enable-mod fastcgi-php
Restart both Lighttpd and PHP5-FPM
sudo service lighttpd restart
sudo service php5-fpm restart
Enjoy!
Frequently Asked Questions
How to install Lighttpd web server on Ubuntu 14.04?
To install Lighttpd on Ubuntu 14.04, you can run the command 'sudo apt-get update && sudo apt-get install lighttpd'.
What are the benefits of using Lighttpd over Apache2 or Nginx?
Lighttpd is known for its lightness, security, and efficient memory management, making it a great choice for high-traffic websites.
Is Lighttpd suitable for hosting WordPress websites?
Yes, Lighttpd is a perfect solution for hosting WordPress websites as it can help improve performance and handle high traffic efficiently.
How does Lighttpd compare to Apache2 and Nginx?
Lighttpd has a smaller CPU footprint and efficient memory management compared to Apache2 and Nginx, making it ideal for high-traffic websites.
Can Lighttpd be used to alleviate server resource overload issues?
Yes, Lighttpd's efficient resource management makes it a good choice for websites experiencing server resource overload issues.
What makes Lighttpd a trusted web server among webmasters?
Webmasters trust Lighttpd due to its security, efficiency, and small footprint, making it a reliable choice for handling web traffic.
How can Lighttpd benefit websites suffering from high traffic?
Lighttpd's efficient memory management and performance make it an ideal solution for websites struggling with high traffic loads.
Where can I find more information about Lighttpd web server?
You can find more information about Lighttpd web server by searching online for resources and documentation available for this open-source web server.