How to integrate php with hiawatha webserver?[solved]

Using applications, configuring, problems
Post Reply
Message
Author
selvam
Posts: 145
Joined: Tue 03 Dec 2013, 12:29

How to integrate php with hiawatha webserver?[solved]

#1 Post by selvam »

Please help me integrate php with hiawatha webserver
my hiawatha.conf,php-fcgi.conf ,error.log,i.php is below
my hiawatha.conf is
*********************************************************************
# Hiawatha main configuration file
#


# GENERAL SETTINGS
#
ServerId = webuser
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log
ErrorLogfile = /var/log/hiawatha/error.log
PIDFile = /var/run/hiawatha.pid
ExploitLogfile = /var/log/hiawatha/exploit.log


# BINDING SETTINGS
# A binding is where a client can connect to.
#
Binding {
Port = 80
MaxRequestSize = 512
# Interface = 127.0.0.1
# MaxKeepAlive = 30
# TimeForRequest = 3,20
}
#
#Binding {
# Port = 443
# Interface = ::1
# MaxKeepAlive = 30
# TimeForRequest = 3,20
# ServerKey = hiawatha.pem
# UseSSL = yes
#}


# BANNING SETTINGS
# Deny service to clients who misbehave.
#
#BanOnGarbage = 300
#BanOnMaxPerIP = 60
#BanOnMaxReqSize = 300
#KickOnBan = yes
#RebanDuringBan = yes
MimetypeConfig = /etc/mime.types

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications. Use the 'php-fcgi'
# tool to start PHP as a FastCGI daemon.
#
CGIhandler = /usr/sbin/php-fcgi:php
#CGIhandler = /usr/bin/perl:pl
#CGIhandler = /usr/bin/python:py
#CGIextension = cgi
#CGIextension = pl
CGIextension = php
TimeForCGI = 60
#
#FastCGIserver {
# FastCGIid = PHP4
# ConnectTo = 127.0.0.1:2004
# Extension = php, php4
#}
#
FastCGIserver {
FastCGIid = PHP-fpm
ConnectTo = 127.0.0.1:9000
Extension = php
SessionTimeout = 60
}


# URL REWRITING
# These URL rewriting rules are made for the Skeleton PHP framework,
# which can be downloaded from: http://skeleton.leisink.org/
#
#UrlRewrite {
# RewriteID = skeleton
# Match ^/$ Return
# RequestURI isfile Exit
# Match (.*)\?(.*) Rewrite $1&$2
# Match /(.*) Rewrite /index.php?page=$1
#}


# DEFAULT WEBSITE
# It is wise to use your IP address as the hostname of the default website
# and give it a blank webpage. By doing so, automated webscanners won't find
# your possible vulnerable website.
#
Hostname = 127.0.0.1
WebsiteRoot = /root/Web-Server
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
#ErrorHandler = 404:/error.cgi
ExecuteCGI = yes


# VIRTUAL HOSTS
# Use a VirtualHost section to declare the websites you want to host.
#

VirtualHost {
Hostname = localhost
WebsiteRoot = /root/Web-Server
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
UseFastCGI = PHP5
UseXSLT = yes
}
# DIRECTORY SETTINGS
# You can specify some settings per directory.
#
**********************************************************
my php-fcgi.conf is
************************************************************
# PHP FastCGI configuration

# PidFile = <path to PID-file>
#
#PidFile = /var/run/php-fcgi.pid

# Forks = <number of forks per server>
#
#Forks = 3

# Setenv <key> = <value>
#

# Server = <php-cgi executable>;<binding>;<UID>[:<GIDs>][;<PHP configuration file>]
#
#Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data
#Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; 1000:100,101
Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data ; /etc/php5/cgi/php.ini
#Server = /usr/chroot|usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data
****************************************************
my error.log is
******************************************************
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|/root/Web-Server/i.php: line 1: ?php: No such file or directory
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|/root/Web-Server/i.php: line 3: //: is a directory
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|/root/Web-Server/i.php: line 6: syntax error near unexpected token `newline'|/root/Web-Server/i.php: line 6: `?>'
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|CGI only printed a HTTP header, no content
***********************************************************
my i.php is
******************
<?php

// Show all information, defaults to INFO_ALL
echo "selvam";

?>
**********************
Please help me
i have some wrong cgi settings
Last edited by selvam on Mon 06 Jan 2014, 12:32, edited 1 time in total.

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#2 Post by npierce »

selvam wrote:my error.log is
******************************************************
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|/root/Web-Server/i.php: line 1: ?php: No such file or directory
192.168.1.5|Fri 03 Jan 2014 18:25:35 +0800|/root/Web-Server/i.php|/root/Web-Server/i.php: line 3: //: is a directory
. . .
Hiawatha thinks that your .php file is an executable script. Since the location of the PHP interpreter is not given in the first line of the file like, for example, this:

Code: Select all

#!/usr/local/bin/php-cgi
the script is assumed to be a shell script. Since it is actually a PHP script, it fails miserably.

You could add such a line to the top of your .php file -- changing the above example to use the actual location of your PHP interpreter.

But most people just define a CGI handler for .php files, so that Hiawatha knows to use the PHP handler for .php files. Then there is no need to give the location of the interpreter in the first line of the .php file.

You have already defined a CGI handler for .php files, with this line in your hiawatha.conf file:

Code: Select all

CGIhandler = /usr/sbin/php-fcgi:php 
(Although, I'm not sure if php-fcgi is a valid PHP handler or not. Maybe not.)

But the main thing that is confusing Hiawatha is this line:

Code: Select all

CGIextension = php
That is what causes Hiawatha to think that a .php file is an executable script. You should remove or comment-out that line.

There may well be other errors in your configuration, but try that first.

selvam
Posts: 145
Joined: Tue 03 Dec 2013, 12:29

#3 Post by selvam »

i get Unknown option. Use '-h' for help.
which is same as i type php-fcgi on the terminal
i have

# COMMON GATEWAY INTERFACE (CGI) SETTINGS
# These settings can be used to run CGI applications. Use the 'php-fcgi'
# tool to start PHP as a FastCGI daemon.
#
#CGIhandler = /usr/sbin/php-fcgi:php
#CGIhandler = /usr/bin/perl:pl
#CGIhandler = /usr/bin/python:py
#CGIextension = cgi
#CGIextension = pl
CGIextension = php
#TimeForCGI = 60


FastCGIserver {
FastCGIid = PHP-fpm
ConnectTo = 127.0.0.1:9000
Extension = php
SessionTimeout = 60
}
the hiawatha howto tells the fastcgiserver extension overrides the cgihandler. but that does not happen. iam using hiawatha 8
i want php-fpm to handle the php calls
i checked by typing php-fpm at terminal it says it is already listening on 127.0.01:9000
but still i get " Unknown option. Use '-h' for help. " emitted by php-fcgi
Please help

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#4 Post by L18L »

selvam wrote:..i checked by typing php-fpm at terminal it says it is already listening on 127.0.01:9000
but
selvam wrote:Server = /usr/bin/php5-cgi ; 127.0.0.1:2005 ; www-data ; /etc/php5/cgi/php.ini
is not port 9000 :roll:

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#5 Post by npierce »

selvam wrote:the hiawatha howto tells the fastcgiserver extension overrides the cgihandler
Yes, that is true. If you choose to use FastCGI, there is no need to define a CGIhandler for PHP files since, in that case, UseFastCGI and FastCGIserver define how PHP files are to be handled.

I don't know if UseFastCGI and FastCGIserver overrides CGIextension.

selvam wrote:i want php-fpm to handle the php calls
Your FastCGIserver section defines FastCGIid as "PHP-fpm":
selvam wrote:FastCGIserver {
FastCGIid = PHP-fpm
ConnectTo = 127.0.0.1:9000
Extension = php
SessionTimeout = 60
}

But your VirtualHost section defines UseFastCGI as "PHP5":
selvam wrote:VirtualHost {
Hostname = localhost
WebsiteRoot = /root/Web-Server
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
UseFastCGI = PHP5
UseXSLT = yes
}
So localhost will try to use the server identified as "PHP5" and fail, since you have no server defined with that identity.

And the definition of your default website has no UseFastCGI line:
selvam wrote:Hostname = 127.0.0.1
WebsiteRoot = /root/Web-Server
StartFile = index.php
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
#ErrorHandler = 404:/error.cgi
ExecuteCGI = yes
So 127.0.0.1 won't use FastCGI.


I've just noticed that you have marked the post subject "[solved]". For the benefit of others, please let us know what you had to do to solve this.

selvam
Posts: 145
Joined: Tue 03 Dec 2013, 12:29

#6 Post by selvam »

i got tired of hiawatha and installed apache instead and solved the problem
thanks for all the help

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#7 Post by L18L »

I am tired, too. :?

selvam
Posts: 145
Joined: Tue 03 Dec 2013, 12:29

#8 Post by selvam »

try trekking or mountaineering
it refreshes you

Post Reply