LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 01-29-2008, 04:44 PM   #1
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
Apache virtual hosts problem


Apache2 in Slackware 12 refuses to work for me. I have a file /etc/koha-httpd.conf with virtual host definitions like this:

Code:
<VirtualHost koha.xxx:80>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/opac/htdocs
   ServerName koha.xxx:80
   ScriptAlias /cgi-bin/koha/ /usr/local/koha/opac/cgi-bin/
   Redirect permanent index.html http://koha.xxx:80/cgi-bin/koha/opac-main.pl
   ErrorLog /usr/local/koha/log/opac-error_log
   TransferLog /usr/local/koha/log/opac-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"
   
</VirtualHost>

<VirtualHost koha.xxx:8080>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/intranet/htdocs
   ServerName koha.xxx:8080
   ScriptAlias /cgi-bin/koha/ "/usr/local/koha/intranet/cgi-bin/"
   Redirect permanent index.html http://koha.xxx:8080/cgi-bin/koha/mainpage.pl
   ErrorLog /usr/local/koha/log/koha-error_log
   TransferLog /usr/local/koha/log/koha-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"
   
</VirtualHost>
This file is included in apache configuration, there is 'Include /etc/koha-httpd.conf' at the end of /etc/httpd/httpd.conf. This used to work fine in Slackware 11 with Apache 1.3, but I can't get it to work in Slackware 12 with Apache2.

All I get is the apache test-page annoyingly saying "It works!", although it obviously doesn't. I've done several Koha installations (Koha is an open source library system http://www.koha.org), and I clearly remember it being able to do more than just say "It works!" :P

Oh yes, and I have Listen 80 and Listen 8080 in httpd.conf too.

Anyone got any ideas on why it doesn't work?

Last edited by alienDog; 01-29-2008 at 06:29 PM.
 
Old 01-29-2008, 05:22 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
Do you have virtual hosts enabled with the following?
Code:
NameVirtualHost *:80
If you do, is there anything in the logs that provides more info?
 
Old 01-29-2008, 06:26 PM   #3
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Original Poster
Rep: Reputation: 46
Quote:
Originally Posted by gilead View Post
Do you have virtual hosts enabled with the following?
Code:
NameVirtualHost *:80
If you do, is there anything in the logs that provides more info?
I've tried these two lines:

Code:
NameVirtualHost koha.xxx:80
NameVirtualHost koha.xxx:8080
They didn't help any. With your suggestion:

Code:
NameVirtualHost *:80
I get: "[warn] NameVirtualHost *:80 has no VirtualHosts"

Then if I change the existing <VirtualHost> definitions to:

Code:
<VirtualHost *:80>
...
<VirtualHost *:8080>
I get the apache test-page ("It works!") again.

The only thing that draws my attention in apache's error_log is this:

httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

As you see from my original posting, there actually are ServerName definitions in VirtualHosts... At one point I tried addind a line that says:

Code:
ServerName koha.xxx
to /etc/httpd/httpd.conf, and that made the above error dissappear, but didn't have any effect on the actual problem.

Koha's logs in /usr/local/koha/logs are all empty.

Oh, and I've also tried using the ip-address of the server in VirtualHost definitions instead of it's name, but that doesn't work either.

Last edited by alienDog; 01-29-2008 at 06:38 PM.
 
Old 01-29-2008, 06:32 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
I don't think you need the :80 or :8080 on the end of the ServerName values. That may be why it's unable to determine the server's name.

There may be other differences between version 1.3 and 2.0 - have you had a look at the Apache docs at http://httpd.apache.org/docs/2.0/vhosts/?
 
Old 01-29-2008, 06:46 PM   #5
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Original Poster
Rep: Reputation: 46
If I remove the port numbers from ServerName (i.e. :80 and :8080), I get "Forbidden - You don't have permission to access / on this server." instead of "It works!". The access_log says:

xxx.xxx.xxx.xxx - - [29/Jan/2008:18:17:57 -0600] "GET / HTTP/1.1" 200 44
xxx.xxx.xxx.xxx - - [29/Jan/2008:18:18:01 -0600] "GET / HTTP/1.1" 304 -
xxx.xxx.xxx.xxx - - [29/Jan/2008:18:18:05 -0600] "GET / HTTP/1.1" 200 44

koha-httpd.conf is actually generated automatically by koha's installer and it should work fine with apache2.

Could the virtualhost problem be caused by the fact that this is actually a virtual server?

Last edited by alienDog; 01-29-2008 at 06:59 PM.
 
Old 01-29-2008, 08:08 PM   #6
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
It shouldn't matter that you're running on a virtual server. All that needs to happen is that a DNS server resolves the host name to your IP address so that a browser gets to your IP address with a request for one of your virtual hosts.

Once it's there Apache doesn't care how (there are some exceptions, but the Apache docs aren't specific on this). It just checks its virtual hosts config for a matching server name and serves up the content. Have you tried something like this?
Code:
NameVirtualHost *

<VirtualHost *:80>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/opac/htdocs
   ServerName koha.xxx
   ScriptAlias /cgi-bin/koha/ /usr/local/koha/opac/cgi-bin/
   Redirect permanent index.html http://koha.xxx/cgi-bin/koha/opac-main.pl
   ErrorLog /usr/local/koha/log/opac-error_log
   TransferLog /usr/local/koha/log/opac-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"
</VirtualHost>
I can't see why they would clash with each other (the koha docs don't mention any possible problems), but if this gets one of the virtual hosts working, then try adding the second.
 
Old 01-29-2008, 08:43 PM   #7
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Original Poster
Rep: Reputation: 46
No luck, I get:

[Tue Jan 29 20:42:20 2008] [error] VirtualHost *:8080 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
[Tue Jan 29 20:42:20 2008] [error] VirtualHost *:80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results

It seems to me that Apache is simply refusing to believe the DocumentRoot (and/or Redirect) directives inside the VirtualHosts.

Last edited by alienDog; 01-29-2008 at 09:09 PM.
 
Old 01-29-2008, 10:15 PM   #8
LNXman
Member
 
Registered: Jul 2002
Location: California (USA)
Distribution: Slackware
Posts: 97

Rep: Reputation: 15
Edit your virtual host file like the following:

Code:
<VirtualHost koha.xxx:80>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/opac/htdocs
   ServerName koha.xxx:80
   ScriptAlias /cgi-bin/koha/ /usr/local/koha/opac/cgi-bin/
   Redirect permanent index.html http://koha.xxx:80/cgi-bin/koha/opac-main.pl
   ErrorLog /usr/local/koha/log/opac-error_log
   TransferLog /usr/local/koha/log/opac-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"
   
   <Directory "/usr/local/koha/opac/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
   </Directory>
   
</VirtualHost>

<VirtualHost koha.xxx:8080>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/intranet/htdocs
   ServerName koha.xxx:8080
   ScriptAlias /cgi-bin/koha/ "/usr/local/koha/intranet/cgi-bin/"
   Redirect permanent index.html http://koha.xxx:8080/cgi-bin/koha/mainpage.pl
   ErrorLog /usr/local/koha/log/koha-error_log
   TransferLog /usr/local/koha/log/koha-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"
   
   <Directory "/usr/local/koha/intranet/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
   </Directory>
  
</VirtualHost>
If you look at your httpd.conf file you will find the following segment:

Code:
.
.
.
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
.
.
.
The above segment prevents any directory starting from '/' from being read unless you explicitly allow it. You can see the case of the base DocumentRoot entry by searching the httpd.conf file. In it, you will see that the base DocumentRoot entry has a <Directory "<your_root_directory">>. . .</Directory> element entry which allows it to be read.

Code:
.
.
.
<Directory "<your_document_root_directory>">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>
.
.
.
Essentially you need to allow DocumentRoot access for your virtual hosts, just as it was done at the base.

Give it a try, and see if it works.

GL

P.S. Don't forget to add another Listen entry to the httpd.conf file so that apache can listen on port 8080 (i.e. Listen 8080)
 
Old 01-30-2008, 05:41 AM   #9
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Original Poster
Rep: Reputation: 46
Still I only get "It works!". Nothing chaged. The Listen directive for port 8080 has been there all the time. This is really starting annoy me, Exactly how complicated does this has to be. It's a webserver, I'm not trying to run a nuclear power plant or anything like that...

--edit---

Progress! Changing the VirtualHost entries from <VirtualHost koha.xxx:80> to <VirtualHost *:80> along with the matching NameVirtualHost lines and <Directory> entries in VirtualHosts displays "Welcome to Koha!" and then this:

Forbidden

You don't have permission to access /cgi-bin/koha/opac-main.pl on this server.

So obviously the script alias is not working now... How can that be fixed?

--edit--

Adding another <Directory> entry to <VirtualHost> does the trick:

Code:
<Directory "/usr/local/koha/opac/cgi-bin">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny  
    Allow from all    
</Directory>
So, in order for it to work the whole <VirtualHost> entry must be like this:

Code:
<VirtualHost *:80>
   ServerAdmin webmaster@koha.xxx
   DocumentRoot /usr/local/koha/opac/htdocs
   ServerName koha.xxx
   ScriptAlias /cgi-bin/koha/ /usr/local/koha/opac/cgi-bin/
   Redirect permanent index.html http://koha.xxx:80/cgi-bin/koha/opac-main.pl
   TransferLog /usr/local/koha/log/opac-access_log
   SetEnv PERL5LIB "/usr/local/koha/intranet/modules"
   SetEnv KOHA_CONF "/etc/koha.conf"

   <Directory "/usr/local/koha/opac/htdocs">
       Options Indexes FollowSymLinks
       AllowOverride None
       Order allow,deny  
       Allow from all    
   </Directory>   

   <Directory "/usr/local/koha/opac/cgi-bin">
       Options Indexes FollowSymLinks
       AllowOverride None
       Order allow,deny  
       Allow from all    
   </Directory>   
</VirtualHost>
Joy Thank you guys! Me happy.

Last edited by alienDog; 01-30-2008 at 05:57 AM.
 
Old 01-30-2008, 12:54 PM   #10
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
Thanks for posting the changes you had to make to get it working
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 06:29 AM
Apache Virtual Hosts ToothlessRebel Linux - Networking 6 10-06-2006 02:11 PM
Apache virtual hosts and mod_rewrite problem Gyper Debian 3 07-31-2006 11:22 PM
apache virtual hosts smaida Linux - Software 3 06-20-2004 04:28 PM
Problem with Apache Virtual Hosts jaberwooky Linux - Software 4 09-23-2003 01:37 PM


All times are GMT -5. The time now is 02:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration