Install and Setup PHP5-fpm and MariaDB for Hiawatha Webserver on CentOS 7
| |How to install PHP5 (fpm) and MariaDB SQL server on CentOS 7 and how to setup basic configuration for Hiawatha webserver.
I’m currently having great curiosity about Hiawatha (also a bit in love with). Being an alternative webserver for Apache, it is actually not very popular but recently it gets its own increasing numbers of fans. Thanks to its lightweight design, built-in security features and simplicity. There are many reasons to ditch Apache but it needs no reason to switch to Hiawatha. I’ve introduced about it in my previous post and you can read awesome review with great reasons of why you should use Hiawatha here.
This post is the next part of my Hiawatha tutorial series. So I’ll cut the “bla bla bla” part and start with the steps directly.
How to Install PHP5
Just like Nginx, Hiawatha also works nicely with PHP-fpm. And here’s how to get it installed and configured properly:
Step 0 – Install Hiawatha web server.
Step 1 – Login (back) to your VPS as root (or a user with sudo privilege):
Step 2 – Install PHP5 with fpm along with necessary PHP modules you love. Use command below:
yum install php php-fpm php-common php-cli php-devel php-gd php-imap php-intl php-mysql php-process php-xml php-xmlrpc php-zts -y
Once done, you’ll see something similar like this:
Setup PHP5-fpm
Step 3 – As we’ll use php-fpm module, so there are few configuration you have to adjust. First, let’s edit php.ini file using your favorite text editor like Nano:
nano /etc/php.ini
then find and edit ;cgi.fix_pathinfo then change it to look like this:
cgi.fix_pathinfo=0
Before:
After:
Once done, save and exit the editor (Control+O then Control+X).
Step 4 – Now we need to set FastCgi to work, edit php-fpm configuration file:
nano /etc/php-fpm.d/www.conf
and edit the line Listen = 127.0.0.1:9000 replace whit this:
listen = /var/lib/hiawatha/php-fcgi.sock
Step 5 – Scroll down the page a little bit and find pm = dynamic and change that to static.
Step 6 – You may also need to change pm.max_children value to desired lesser value:
Step 7 – Change chdir value to /.
Once done, save changes and exit (Control+O then Control+X).
Setting Server PHP Configuration
Step 8 – Now edit Hiawatha .conf file:
nano /etc/hiawatha/hiawatha.conf
and find this line: #CGIhandler = /usr/bin/php-cgi:php then remove the # part.
Step 9 – Also, replace these lines:
#FastCGIserver { # FastCGIid = PHP5 # ConnectTo = 127.0.0.1:9050 # Extension = php #}
with:
FastCGIserver { FastCGIid = PHP5 ConnectTo = /var/lib/hiawatha/php-fcgi.sock Extension = php }
Step 10 – Again, you have to also edit your Virtual Host setting (still inside the same file). Look for it and remove the # symbol before the UseFastCGI = PHP5 line. It Should look like this:
Now you can save changes (Control+O) then exit (Control+X).
Step 11 – Restart Hiawatha and php-fpm:
service hiawatha stop;service hiawatha start;service php5-fpm restart
How to install MariaDB
Step 1 – Issue command below:
yum install mariadb-server mariadb -y
Step 2 – Start MariaDB service using systemctl command (get used to it):
systemctl start mariadb.service
Also issue this one to make MariaDB run automatically each time your server reboot:
systemctl enable mariadb.service
Step 3 – So its service is now running but there is one thing you should do immediately: configuring MariaDB setup for the very first time like setting up your mysql root password. Issue this command:
mysql_secure_installation
Then you’ll see a series of question, just answer it accordingly. The main important part is to define your root password while everything else is just up to you or you can simply hit the “ENTER” key through each prompt to accept the default values.
You may also need to test your newly installed MariaDB by logging in as root:
mysql -u root -p
That’s it.
p.s: I honestly suggest you not to follow this tutorial in production server. Play with it for a while until you’re in love with it. Enjoy..
Can you make a tutorial for Webuzo panel?
Its the best free panel I’ve ever used, and I’m very pleased with it
You can deploy and install Nginx, PHP 5.6, Memcached, and a lot of other utilities with a single click in the panel
I followed this tutorial, and hiawatha will only open the default success page, I altered the default site to point
to apaches web root, to a site that does work in apache, yet it will not open the site, I get the error,
Service Unavailable 503
I assume php is working as apache can serve the site no problem.
I create a virtual domain, and same problems exist.
Could I be running two installations of php, I don’t think so, I yum installed php and a few modules, then found this tutorial and followed everything, mariadb is ok as it serves the site through apache.
Any help would be much apreciated.
Thank you.