LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Apache virtual hosts problem (https://www.linuxquestions.org/questions/slackware-14/apache-virtual-hosts-problem-617244/)

alienDog 01-29-2008 04:44 PM

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?

gilead 01-29-2008 05:22 PM

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?

alienDog 01-29-2008 06:26 PM

Quote:

Originally Posted by gilead (Post 3039293)
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.

gilead 01-29-2008 06:32 PM

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/?

alienDog 01-29-2008 06:46 PM

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?

gilead 01-29-2008 08:08 PM

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.

alienDog 01-29-2008 08:43 PM

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.

LNXman 01-29-2008 10:15 PM

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)

alienDog 01-30-2008 05:41 AM

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.

gilead 01-30-2008 12:54 PM

Thanks for posting the changes you had to make to get it working :)

redscience 09-25-2020 09:37 AM

Hello

I saw this tutorial, and I did it step by step but I got this error message:

This page isn’t working.Website didn’t send any data.
ERR_EMPTY_RESPONSE

Log file is:

client denied by server configuration:

I checked my folder and file permissions

how can I resolve that? ( this problem really tired me )

willysr 09-25-2020 09:42 AM

this is 12 years thread. Why not make a new one?


All times are GMT -5. The time now is 04:40 PM.