Again on Apache 2

Hello everybody.

I know, I know, another post about Apache 2, but I have looked a lot on
the internet and I haven’t found the answer to my problem.

I have a Linux Fedora Core 5 box, with Apache 2.2.2 (compiled and
installed), Ruby 1.8.4 (compiled and installed), RubyGems 0.8.11
(compiled and installed) and Rails… I don’t know what version as this
one I haven installed with gem.

This is what I want to achieve.

I have a personal website (www.troccoli.it) which contains HTML only. I
want to have another website (spagnolo.troccoli.it) where I use Rails.
Both URL are resolved to the same IP: my Linux box.

I have managed to change httpd.conf to use mod_fcgid as follows


LoadModule fcgid_module modules/mod_fcgid.so
IPCCommTimeout 40
IPCConnectTimeout 10

I have also changed httpd-vhosts.conf (which is include in httpd.conf)
as follows:


NameVirtualHost *

VirtualHost example:

Almost any Apache directive may go into a VirtualHost container.

The first VirtualHost section is used for all requests that do not

match a ServerName or ServerAlias in any block.

<VirtualHost :>
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it
ServerName www.troccoli.it
ErrorLog logs/troccoli.it-error_log
CustomLog logs/troccoli.it-access_log common

<VirtualHost :>
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it/spagnolo
ServerName spagnolo.troccoli.it
ErrorLog logs/spagnolo-error_log
CustomLog logs/spagnolo-access_log common
<Location /journal>
RewriteEngine On
# Let Apache handle purely static files like images by itself.
RewriteCond %{REQUEST_FILENAME} !-f
# Send Everything else to Rails
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

<Directory /home/webmaster/troccoli.it/spagnolo/journal>
# ExecCGI is required for mod_fcgid to work.
Options Indexes FollowSymLinks ExecCGI
# Disable .htaccess files.
AllowOverride None
Order allow,deny
Allow from all
# This tells mod_fcgid to run the dispatch.fcgi script as a
FastCGI
AddHandler fcgid-script .fcgi


Now, while my personal website (www.troccoli.it) works fine, if you go
to the other one (spagnolo.troccoli.it) instead of the expected “Welcome
aboard You’re riding the Rails!” I have the content of my DocumentRoot
directory (which is not a big deal at the moment as I haven’t done
anything yet). Try it yourself, you should be able to see it yourself.

I know that I could run Apache for www.troccoli.it and WEBBrick for
spagnolo.troccoli.it because they can run on different ports (and this
is noather thing I don’t understand, do I have to use port 3000 if I use
Apache???) but I’d like to have only one web server, possibly Apache.

I am also not sure about the journal directory in the httpd-vhosts.conf.
I have copied from a how-to post I found, but
/home/webmaster/troccoli.it/spagnolo/journal does not exist. I have
however tried also with

...

but this time I have an error and the log says

[Thu Jun 22 21:26:08 2006] [error] [client 192.168.69.22] Request
exceeded the limit of 10 internal redirects due to probable
configuration error. Use ‘LimitInternalRecursion’ to increase the limit
if necessary. Use ‘LogLevel debug’ to get a backtrace.

I am really stuck guys, could you help me please?

Thanks
Giulio

<Directory /home/webmaster/troccoli.it/spagnolo/journal>

should be

<Directory /home/webmaster/troccoli.it/spagnolo/journal/public>

Michael G. wrote:

<Directory /home/webmaster/troccoli.it/spagnolo/journal>

should be

<Directory /home/webmaster/troccoli.it/spagnolo/journal/public>

ignore that (accidently hit submit to quick )

DocumentRoot /home/webmaster/troccoli.it/spagnolo

should be

DocumentRoot /home/webmaster/troccoli.it/spagnolo/public

Giulio Troccoli wrote:

Thanks Michael, but why should it?

I mean, the public directory does not exist and I don’t want it. I want
my document root to be spagnolo. Also I don’t understand if I should
still have the <Directory /home/webmaster/troccoli.it/spagnolo/journal>
or if I should change it to something else. Everything is very unclear
to me, could you help me please?

Giulio

Ok Michael, ignore my last comment.

I didn’t notice that the public directory had been created by Rails. I
don’t think it did the first time I used Rails (possibly becuase it
wasn’t the same version).

Anyway, you suggestion solve the puzzle (after I correct a mistype that
was driven me crazy :slight_smile:

Thanks again.

Giulio

Michael G. wrote:

Michael G. wrote:

<Directory /home/webmaster/troccoli.it/spagnolo/journal>
should be
<Directory /home/webmaster/troccoli.it/spagnolo/journal/public>

ignore that (accidently hit submit to quick )
DocumentRoot /home/webmaster/troccoli.it/spagnolo
should be
DocumentRoot /home/webmaster/troccoli.it/spagnolo/public

In addition I would suggest putting rails application in directory
parallel to your other web sites:

DocumentRoot /home/webmaster/spagnolo.troccoli.it/public

When you put Rails application inside your html directory it’s source
files are world-visible like this:

http://www.troccoli.it/spagnolo/config/

Cheers,

Łukasz Piestrzeniewicz

Michael G. wrote:

Michael G. wrote:

<Directory /home/webmaster/troccoli.it/spagnolo/journal>

should be

<Directory /home/webmaster/troccoli.it/spagnolo/journal/public>

ignore that (accidently hit submit to quick )

DocumentRoot /home/webmaster/troccoli.it/spagnolo

should be

DocumentRoot /home/webmaster/troccoli.it/spagnolo/public

Thanks Michael, but why should it?

I mean, the public directory does not exist and I don’t want it. I want
my document root to be spagnolo. Also I don’t understand if I should
still have the <Directory /home/webmaster/troccoli.it/spagnolo/journal>
or if I should change it to something else. Everything is very unclear
to me, could you help me please?

Giulio

Try this in your vhost file:

NameVirtualHost 80.41.94.168:80

#this becomes the default virtual host for clients which do not
#pass the host header properly

<VirtualHost 80.41.94.168:80>
ServerName www.troccoli.it
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it
ErrorLog logs/troccoli.it-error_log
CustomLog logs/troccoli.it-access_log common

this is only seen by clients who pass the host header

spagnolo.troccoli.it
properly
<VirtualHost 80.41.94.168:80>
ServerName spagnolo.troccoli.it
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it/spagnolo/journal
ErrorLog logs/spagnolo-error_log
CustomLog logs/spagnolo-access_log common
RewriteEngine On
# Let Apache handle purely static files like images by itself.
RewriteCond %{REQUEST_FILENAME} !-f
# Send Everything else to Rails
RewriteRule ^(.*)$ /dispatch.fcgi [QSA,L]
<Directory /home/webmaster/troccoli.it/spagnolo/journal>
# ExecCGI is required for mod_fcgid to work.
Options Indexes FollowSymLinks ExecCGI
# Disable .htaccess files.
AllowOverride None
Order allow,deny
Allow from all
# This tells mod_fcgid to run the dispatch.fcgi script as a
FastCGI
AddHandler fcgid-script .fcgi

Steve L. wrote:

Try this in your vhost file:

NameVirtualHost 80.41.94.168:80

#this becomes the default virtual host for clients which do not
#pass the host header properly

<VirtualHost 80.41.94.168:80>
ServerName www.troccoli.it
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it
ErrorLog logs/troccoli.it-error_log
CustomLog logs/troccoli.it-access_log common

this is only seen by clients who pass the host header

spagnolo.troccoli.it
properly
<VirtualHost 80.41.94.168:80>
ServerName spagnolo.troccoli.it
ServerAdmin [email protected]
DocumentRoot /home/webmaster/troccoli.it/spagnolo/journal
ErrorLog logs/spagnolo-error_log
CustomLog logs/spagnolo-access_log common
RewriteEngine On
# Let Apache handle purely static files like images by itself.
RewriteCond %{REQUEST_FILENAME} !-f
# Send Everything else to Rails
RewriteRule ^(.*)$ /dispatch.fcgi [QSA,L]
<Directory /home/webmaster/troccoli.it/spagnolo/journal>
# ExecCGI is required for mod_fcgid to work.
Options Indexes FollowSymLinks ExecCGI
# Disable .htaccess files.
AllowOverride None
Order allow,deny
Allow from all
# This tells mod_fcgid to run the dispatch.fcgi script as a
FastCGI
AddHandler fcgid-script .fcgi

Basically you want me to take the Rewrite stuff out of the Location
directive.
I have tried it and now I don’t even have the “Welcome abroad” page bad
a “Bad Request” page.

Btw, I haven’t used the IP address because I can’t. I don’t want to have
to log in, change the httpd.conf and restart Apache every time my server
got disconnected and connects again to the internet. Was it a crucial
part of your suggestion?

Giulio

Łukasz Piestrzeniewicz wrote:

In addition I would suggest putting rails application in directory
parallel to your other web sites:

DocumentRoot /home/webmaster/spagnolo.troccoli.it/public

When you put Rails application inside your html directory it’s source
files are world-visible like this:

http://www.troccoli.it/spagnolo/config/

Fair enough, thanks, I will do that.

But, actually although I do have the “Welcome aboard” page, that’s all I
can get.

I have created a table (modes) with mysql

CREATE TABLE modes (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
description VARCHAR(45) NOT NULL DEFAULT ‘’,
PRIMARY KEY(id)
)
ENGINE = InnoDB;

Then I have generated the controller and the model for it with

ruby script/generate controller Mode
ruby script/generate model Mode

Then I changed the mode_controller.rb as

class ModeController < ApplicationController
scaffold :mode
end

But, if I go to spagnolo.troccoli.it/mode/new I don’t get what I
expected but a 404 “The page cannot be found” error.

Any idea why?

Giulio

Because the problem is now different from the original one I have
created another post.

http://www.ruby-forum.com/topic/71586#99744

Please, reply to that one from now on.

Giulio