Hiawatha is a web server that has simplicity, ease of use, and security in mind. It’s the perfect solution for smaller servers, older hardware, or embedded machines – but it also runs great on high powered servers as well. When combining the Hiawatha web server with PHP-FPM and MySQL, you can have a powerful web server that is both light-weight and secure. In this tutorial, I’ll show you how to install Hiawatha, PHP-FPM, and MySQL on Debian. By the end of the tutorial you’ll have a fully functional Hiawatha web server that is able to use PHP-FPM and MySQL to accomplish your needs!
This article was written for Debian Wheezy (64-bit), but may work with other versions of Debian with minor adjustments.
Please note that you need to either be root or have root access via su / sudo to perform all the steps in this tutorial.
Step 1 – Setup repository for pre-compiled Hiawatha Debian binaries
The first thing you’ll need to do is to setup the repository for Hiawatha Webserver. You may also compile it on your own if you wish, but for this tutorial we’ll be using the pre-compiled binaries.
First, get and install the repository’s public key:
apt-key adv --recv-keys --keyserver keys.gnupg.net 79AF54A9
Open up and edit sources.list
with:
nano /etc/apt/sources.list
Add the following to sources.list:
deb http://mirror.tuxhelp.org/debian/ squeeze main
Save the changes that you have made, then exit.
Now, update with:
apt-get update
Step 2 – Install Hiawatha
Install Hiawatha by entering:
apt-get install hiawatha
Make sure that Hiawatha works by opening your web browser and entering:
http://YOURVULTRIPGOESHERE
and you should see an “Installation Successful” webpage on your brand new Hiawatha web server.
Step 3 – Install MySQL
Install MySQL by running the following command:
apt-get install mysql-server
During the install, you’ll be presented with an option to set the root password for MySQL. Make sure to pick a secure password and enter it in, then enter it in again when it asks you to confirm your new root MySQL password.
Once the MySQL installation has finished, run:
mysql_secure_installation
This will go through some simple steps to secure your new MySQL server, which are:
- What is the current MySQL root password? (enter that in)
- Change the root MySQL password? (enter N for no)
- Remove anonymous users? (select Y for yes)
- Disallow root login remotely? (select Y for yes)
- Remove any test databases? (select Y for yes)
- Reload privilege tables? (select Y for yes)
Your MySQL server is now installed and secured!
Step 4 – Install PHP-FPM
Install PHP-FPM and some extra extensions by entering:
apt-get install php5-fpm php5-mysql php5-gd php5-curl
Edit php.ini
…
nano /etc/php5/fpm/php.ini
… and find the line where it says: ;cgi.fix_pathinfo=1
. Uncomment this line and change the value to “0”, so that it matches:
cgi.fix_pathinfo=0
Save and exit.
Edit www.conf
…
nano /etc/php5/fpm/pool.d/www.conf
… and uncomment the line that says ;listen.mode = 0660
, so that it matches:
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
Save and exit.
Restart PHP-FPM so that the changes you have made take effect:
service php5-fpm restart
Step 5 – Configure Hiawatha
In this part, you’ll be configuring Hiawatha and setting it up to serve PHP and/or your website files. First, open up hiawatha.conf
.
nano /etc/hiawatha/hiawatha.conf
Find the line that says #CGIhandler = /usr/bin/php-cgi:php
. Uncomment this line, so that it matches the following:
CGIhandler = /usr/bin/php-cgi:php
Now, uncomment the entire FastCGI lines and replace 127.0.0.1:2005
with /var/run/php5-fpm.sock
so that it looks exactly like this:
FastCGIserver {
FastCGIid = PHP5
ConnectTo = /var/run/php5-fpm.sock
Extension = php
}
Go down to the section that says VIRTUAL HOSTS
and uncomment the entire section. Replace your-domain-goes-here.com
with the website domain that you will be using.
- Change the Hostname field to your domain
www.your-domain-goes-here.com
- Change the WebsiteRoot field to
/var/www/your-domain-goes-here.com/public_html
- Change the AccessLogFile field to
/var/www/your-domain-goes-here.com/logs/access.log
- Change the ErrorLogFile field to
/var/www/your-domain-goes-here.com/logs/error.log
- Remove the line that says
UseToolKit = banshee
It will look like this when you are finished:
VirtualHost {
Hostname = www.your-domain-goes-here.com
WebsiteRoot = /var/www/your-domain-goes-here.com/public_html
StartFile = index.php
AccessLogfile = /var/www/your-domain-goes-here.com/logs/access.log
ErrorLogfile = /var/www/your-domain-goes-here.com/logs/error.log
TimeForCGI = 5
UseFastCGI = PHP5
}
Save and exit.
Create the directories needed for your website files.
mkdir -p /var/www/your-domain-goes-here.com/public_html
mkdir /var/www/your-domain-goes-here.com/logs
Restart Hiawatha.
service hiawatha restart
At this point, you’re ready to begin uploading your PHP files to /var/www/your-domain-goes-here.com/public_html
. Enjoy Hiawatha!
Step 6 – Post-install tips
There are many possible security combinations and tuning commands that you can use with Hiawatha. Visit the Hiawatha manpage (or website) for a list of different commands and additional HOWTOs.
Installing WordPress
Now that you have a working Hiawatha web server with PHP and MySQL – perhaps you would like to install WordPress? To get WordPress working with Hiawatha, you’ll need to make a small change to hiawatha.conf
.
nano /etc/hiawatha/hiawatha.conf
Add the following line to the inside of your virtualhost section (below the UseFastCGI = PHP5
line).
UseToolkit = wordpress
Add this configuration outside of your virtualhost config (preferably in the UrlToolKit section in hiawatha.conf
).
UrlToolkit {
ToolkitID = wordpress
RequestURI exists Return
Match .*/?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}
Save and exit.
With the UrlToolKit rewrites for WordPress in place, you can install WordPress in the same fashion as you would for any other web server. You will want to make sure that the permissions of all WordPress files in /var/www/your-domain-goes-here.com/public_html
are set to www-data:www-data
so that WordPress can make the changes for themes and plugins.
Want to contribute?
You could earn up to $300 by adding new articles
Suggest an update
Request an article