Forum

Virtualhost setup

René
13 June 2011, 15:38
Hiawatha version: 7.5
Operating System: Ubuntu 11.04

Hi Hugo,

I want to enable virtualhosts in Hiawatha but somehow I can't work around a permission problem (403). I've read most of the documentation that is available on your website but I am unable to find a solution

# Hiawatha main configuration file

ServerId = www-data
ConnectionsTotal = 150
ConnectionsPerIP = 10
SystemLogfile = /var/log/hiawatha/system.log
GarbageLogfile = /var/log/hiawatha/garbage.log


Binding
{
Port = 80
}

#CGIhandler = /usr/bin/perl:pl
CGIhandler = /usr/bin/php-cgi:php
#CGIhandler = /usr/bin/python:py
#CGIhandler = /usr/bin/ruby:rb
#CGIhandler = /usr/bin/ssi-cgi:shtml
CGIextension = cgi
#
FastCGIserver
{
FastCGIid = PHP5
ConnectTo = 127.0.0.1:2005
Extension = php, php5
SessionTimeout = 30
}

Hostname = 127.0.0.1
WebsiteRoot = /var/www/hiawatha
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
#ErrorHandler = 404:/error.cgi

UserWebsites = yes
UserDirectory = public

VirtualHost
{
Hostname = localhost
WebsiteRoot = /home/user/public
StartFile = index.php
AccessLogfile = /var/log/hiawatha/user_access.log
ErrorLogfile = /var/log/hiawatha/user_error.log
ExecuteCGI = yes
UserWebsites = yes
TimeForCGI = 5
UseFastCGI = PHP5

}


Maybe I missed something very simple...

Cheers
Hugo Leisink
13 June 2011, 22:02
If you change to user www-data, are you able to read the files in /home/user/public?
René
13 June 2011, 22:28
Change the permissions on /home/user/public?
Hugo Leisink
13 June 2011, 22:36
If you are not able to read the files in that directory when changed to used www-data, yes, you could try that as a possible solution.
René
13 June 2011, 23:00
Played with a few permissions like eg:
sudo chown -R www-data:www-data public, user:www-data public and www-data:user 

but no progress.

da_jojo
14 June 2011, 10:08
i think its because you use localhost as a domain name. the linux system dont like that.
Hugo Leisink
14 June 2011, 11:52
What URL are you using in your browser?
What does the error logfile say?
René
14 June 2011, 15:09
Thanks for the support, guys!

Let me try to explain a few things. I have a working setup
on my FreeBSD box. I can access my public directory with
"http://testcode.local/~user/". I don't have special permissions
on the public directory just the user permissions. I can read and write
my code stuff as a user.

My configuration under FreeBSD:

1) I have a "127.0.0.1 testcode.local" entry in /etc/hosts.
2) In hiawatha.conf I have

Binding {
Port = 80
}

CGIhandler = /usr/local/bin/php-cgi:php
CGIextension = cgi
ExecuteCGI = yes

Hostname = 127.0.0.1
WebsiteRoot = /usr/local/www/hiawatha
StartFile = index.html
AccessLogfile = /var/log/hiawatha/access.log
ErrorLogfile = /var/log/hiawatha/error.log
#ErrorHandler = 404:/error.cgi
UserDirectory = public
UserWebsites = yes

VirtualHost {
Hostname = localhost
WebsiteRoot = /usr/home/user/public
StartFile = index.php
AccessLogfile = /var/log/hiawatha/user_access.log
ErrorLogfile = /var/log/hiawatha/user_error.log
TimeForCGI = 5
UserWebsites = yes
}


Now I am trying this setup under Ubuntu and with "http://testcode.local/" I can
view the welcome page. So far its working but when I add "~user/" at the end of
the url I am denied file access according to my logfile.

Cheers
Hugo Leisink
14 June 2011, 15:18
Note that when you are using testcode.local, it doesn't match the virtual host with hostname 'localhost' and therefor the default host (with hostname '127.0.0.1') will be used.

My guess is that the homedirectory of the user 'user' is /usr/home/user and that the public directory contains a file named index.php. Since the host with hostname '127.0.0.1' does not allow CGI exection, Hiawatha will return the 403 Forbidden.

Changing the hostname of the virtual host from 'localhost' to 'testcode.local' will probably solve the problem.
René
14 June 2011, 16:15
Changing the hostname of the virtual host from 'localhost' to 'testcode.local' will probably solve the problem.


This is where it hits me. It doesn't.
René
14 June 2011, 23:08
My guess is that the homedirectory of the user 'user' is /usr/home/user and that the public directory contains a file named index.php. Since the host with hostname '127.0.0.1' does not allow CGI exection, Hiawatha will return the 403 Forbidden.

So true!

After trying several times with different configurations. I've come to the conclusion that the setup that I am trying to achieve does not work on Ubuntu but works on the old-fart system FreeBSD.
Hugo Leisink
15 June 2011, 00:09
I have no idea what goes wrong on your system, but I've been running Hiawatha on Ubuntu for many years. No problem what so ever. Ubuntu can't be the problem.
René
15 June 2011, 20:59
Since localhost points to 127.0.0.1 and 127.0.0.1 doesn't allow CGI execution. The idea of running UserWebsites on localhost is useless.

Thanks, guys
René
17 June 2011, 05:39
Tsjongejongjonge... Got it working!
Hugo Leisink
17 June 2011, 06:32
Goed zo! Can you tell us what the problem was?
René
17 June 2011, 08:08
In the middle of the battle. Somehow I've managed to change permissions on my home directory and forgot about it! Permissions for group and other on my home directory were set to none. Pffft. Now I have Banshee running under banshee.local
Hugo Leisink
17 June 2011, 08:53
Oke, let me know what you think of Hiawatha and Banshee.
This topic has been closed.