DevHeads.net

apache2 web server

Sir/Madam

I am trying to setup an Apache2 web server on Ubuntu 12.04

I can get a default web page to work ok

But I cannot get VirtualHosts to work
Well at least that is what I believe to be the case.

When I define my virtual hosts in
/etc/apache2/sites-available

I then run a2ensite on that site-name

In /etc/apache2/sites-enabled it creates the correct link

However when I then try to visit the site I see error messages

File does not exist: /var/www/qwert

But in /etc/apache2/sites-available/qwert there is a line

DocumentRoot /home/qwert

So why does it look in /var/www/qwert

The Default DocumentRoot is /var/www

But I simply do not understand why it wants to look in /var/www/qwert
and not /home/qwert

Any help whould be sincerely appreciated

Thanking you.

Yours sincerely

Ian Taylor
University of St.Andrews,
School of Physics & Astronomy,
North Haugh,
St.Andrews,
Fife KY16 9SS,
Scotland.

e-Mail :- <a href="mailto:iat@st-and.ac.uk">iat@st-and.ac.uk</a>
Tel :- (0)1334-463141
Fax :- (0)1334-463104

The University of St Andrews
is a charity registered in
Scotland : No SC013532.

Comments

Re: apache2 web server

By Kim Briggs at 05/10/2014 - 21:07

On Wed, Apr 23, 2014 at 7:38 AM, Ian A Taylor <iat@st-andrews.ac.uk> wrote:
<a href="http://kimbriggs.com/computers/computer-notes/linux-notes/apache2-public_html-virtual-directories.file" title="http://kimbriggs.com/computers/computer-notes/linux-notes/apache2-public_html-virtual-directories.file">http://kimbriggs.com/computers/computer-notes/linux-notes/apache2-public...</a>

Have fun,

Re: apache2 web server

By Marius Gedminas at 04/23/2014 - 08:50

On Wed, Apr 23, 2014 at 12:38:23PM +0100, Ian A Taylor wrote:
We need some more information to answer that question:

1. What are the contents of /etc/apache2/sites-available/qwert?

2. Do you have anything else in /etc/apache2/sites-enabled?

3. Is there a 'NameVirtualHost *:80' directive (in
/etc/apache2/ports.conf, IIRC)?

Marius Gedminas

Re: apache2 web server

By Ian A Taylor at 04/23/2014 - 11:04

Marius

Thanks for reply

To answer your questions

/etc/apache2/sites-available/qwert

==================================================================
<VirtualHost *:80>
ServerName fffff.st-and.ac.uk/qwert
ServerAdmin A MAIL ADDRESS

DocumentRoot /var/www/qwert

<Directory /var/www/qwert>
Options Indexes FollowSymLinks MultiViews +ExecCGI
AllowOverride None
Order deny,allow
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
====================================================================

2. Do you have anything else in /etc/apache2/sites-enabled?

Yes

000-default -> ../sites-available/default
qwert -> ../sites-available/qwert

3. Is there a 'NameVirtualHost *:80' directive (in
/etc/apache2/ports.conf, IIRC)?

Yes there is

Regards

Ian Taylor

On 23/04/14 13:50, Marius Gedminas wrote:

Re: apache2 web server

By Sajan Parikh at 04/23/2014 - 11:09

On 04/23/2014 10:04 AM, Ian A Taylor wrote:
Sajan Parikh

Re: apache2 web server

By Ian A Taylor at 04/23/2014 - 11:34

Sajan

apachectl configtest

returns

Syntax OK

The server fffff.st-and.ac.uk

works ok

But I want to create a sub-directory
I am not sure if sub-directory is the correct word to utilize here.

But I want the web address

fffff.st-and.ac.uk/qwert

to respond in a different way from fffff.st-and.ac.uk

I am no expert on this - nor do I claim to be
But it seems that virtual hosts was the way to go about this

Which is why I tried it
Nothing I see suggests it shouldn't work but it DOESN'T WORK

Which is why I posted this message in sheer exasperation

Regards

Ian Taylor

On 23/04/14 16:09, Sajan Parikh wrote:

Re: apache2 web server

By Sajan Parikh at 04/23/2014 - 11:47

On 04/23/2014 10:34 AM, Ian A Taylor wrote:
In the main VirtualHost or configuration for fffff.st-and.ac.uk, you
need to use the Alias directive like this;

Alias /qwert /home/qwert/ #(you might need to play with the trailing
slashes)

That line will allow your main configuration to work as expected, but
for /qwert, it will use /home/qwert as the DocumentRoot. Meaning
fffff.st-and.ac.uk/qwert/somefile.jpg will pull from
/home/qwert/somefile.jpg while the rest of fffff.st-and.ac.uk will
operate normally using the standard config, which seems to be what
you're after.

There's actually a whole section in the Apache documentation about URL
mapping, which is what you are trying to do. Creating a separate
VirtualHost for each URL path is not the way to go.

<a href="http://httpd.apache.org/docs/2.2/urlmapping.html" title="http://httpd.apache.org/docs/2.2/urlmapping.html">http://httpd.apache.org/docs/2.2/urlmapping.html</a>

Sajan Parikh