LHMP- Linux Haiwatha Mysql PHP simplistic new breed!!

hiawathaStep 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

Add some extra extensions-

apt-get install php5 libapache2-mod-php5 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 php-apc phpmyadmin curl unzip htop iftop

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

Do some extra addons-

memory_limit = 512M
upload_max_filesize = 128M
post_max_size = 64M
short_open_tag = On

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.

Enabling phpmyadmin

ln -s /usr/share/phpmyadmin /var/www/phpmyadmin

For more detailed and granular setup, I can refer to this beautiful article-

http://dotbalm.org/hosting-wordpress-with-hiawatha/

Some Important Hiawatha URL-

https://www.hiawatha-webserver.org/howto/url_rewrite_rules

https://www.hiawatha-webserver.org/howto/example_configuration

https://www.hiawatha-webserver.org/howto/websites

https://www.hiawatha-webserver.org/howto

Src:

https://www.vultr.com/docs/install-hiawatha-web-server-with-php-fpm-and-mysql-on-debian

 

Share

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.