Quantcast
Channel: Free Web Hosting Community Forum - Host1Free.com
Viewing all articles
Browse latest Browse all 3352

Setting FastCGI and vhost with Hiawatha webserver !

$
0
0
Hi all,


After writing about "How to install Hiawatha web server, PHP5 and MariaDB", here, now i will show you how to set PHP and vhost with Hiawatha webserver. We will start with php settings, but you need to know, and i will explain after, that you may have issues with some settings and you will need to check Hiawatha manual to fix them.


OS: Debian 7
Server Host1Free
Settings in this tutorial are for RainLoop mail client ( i will write about install soon, wordpress install etc.., i can write a book :) )


First we will set php5 config files:


Code:

nano /etc/php5/fpm/php.ini

Find and edit:


Code:

cgi.fix_pathinfo = 0
cgi.rfc2616_headers = 1


If you have any issue with your php script, disable cgi.rfc2616_header s. With RainLoop developer we worked out to resolve this issue this weekend (you can see script was updated 23/11/2013), and now RainLoop will run smoothly with this settings.


This settings are my personal choice, not needed, but compressing files is always good for site load speed:


Code:

# Enable GZip content encoding
zlib.output_compression = On
zlib.output_compression_level = 6


Basic security settings:


Code:

# Security settings
expose_php = Off
display_errors = Off
allow_url_include = Off


Now we need to set FastCgi to work:


Code:

nano /etc/php5/php-fpm.conf

Go all down and add (ctrl+v for faster navigation):


Code:

[www]
user = www-data
group = www-data
listen = /var/lib/hiawatha/php5-fcgi.sock
pm = static
pm.max_children = 3
chdir = /


Next step is setting Hiawatha configuration file to use FastCGI (php-fpm) and setting vhost. Before doing something make hiawatha.conf backup (do same for files above):


Code:

cp /etc/hiawatha/hiawatha.conf bak.hiawatha.conf

Hiawatha configuration file have a lot of options, and for now we will just make server to run php pages. We are going to make out site folder and standard php info page. Just copy and run this command, and you will have you first index.php page inside /var/www/mysite folder.


Code:

cd /var/www/;mkdir -p mysite;chown -R www-data.www-data mysite;cd mysite;touch index.php; echo '<? phpinfo(); ?>' > index.php;chown -R www-data.www-data index.php

Setting server PHP configuration


Code:

nano /etc/hiawatha/hiawatha.conf

Find:


Code:

#CGIhandler = /usr/bin/php-cgi:php

Replace with:


Code:

CGIhandler = /usr/bin/php5-cgi:php,php5

Find:


Code:

#FastCGIserver {
#  FastCGIid = PHP5
#    ConnectTo = 127.0.0.1:9050
#    Extension = php
#}


Replace with:


Code:

FastCGIserver {
        FastCGIid = PHP5
        ConnectTo = /var/lib/hiawatha/php5-fcgi.sock
        Extension = php
}


Setting vhost in hiawatha.conf file


Inside hiawatha.conf file you will see default vhost setting, don't change them just copy them, like that you will always have default setting if you need them.


After:


Code:

# VIRTUAL HOSTS
# Use a VirtualHost section to declare the websites you want to host.
#
#VirtualHost {
#        Hostname = www.my-domain.com
#        WebsiteRoot = /var/www/my-domain/public
#        StartFile = index.php
#        AccessLogfile = /var/www/my-domain/log/access.log
#        ErrorLogfile = /var/www/my-domain/log/error.log
#        TimeForCGI = 5
#        UseFastCGI = PHP5
#        UseToolkit = banshee
#}


Add this (options with # are not active):




Code:

VirtualHost {
      Hostname = www.my-domain.com or server ip if you are doing test
      WebsiteRoot = /var/www/mysite
      StartFile = index.php
#      AccessLogfile = /var/www/my-domain/log/access.log
#      ErrorLogfile = /var/www/my-domain/log/error.log
#      TimeForCGI = 5
      UseFastCGI = PHP5
#      UseToolkit = banshee
}


Now you need to restart php-fpm and Hiawatha server.


Code:

service hiawatha stop;service hiawatha start;service php5-fpm restart



And we are done. Now you can open you first page and you will see:





Have fun, security and speed with Hiawatha !

Viewing all articles
Browse latest Browse all 3352

Trending Articles