So, wee relatively quick experiment ...
I tried Ubuntu Server first, figuring it probably already had Apache
installed by default, but it wants to install the operating system, no
readily apparent "Live" ("Try Ubuntu") mode, and don't have
Kubuntu 14.04 handy, but do have Ubnuntu 14.04 handy, but Apache ought
be quite similar enough on Ubuntu 14.04, and have that handy, so ...
I create virtual machine to run it on:
# virt-install --name=ubuntu1404amd64 \
--cdrom=/var/tmp/ISOs/ubuntu-14.04-desktop-amd64.iso --nodisks \
--livecd --network=network=default --ram=1024 --wait=-1 \
--os-type=linux --os-variant=ubuntuoneiric --virt-type kvm --hvm
...
Try Ubuntu
Ctrl-Alt-F1
And off to do rootly things ...
ubuntu@ubuntu:~$ cd / && exec sudo su -
I enable login on ttyS0 (serial port) ...
root@ubuntu:~# (cd /etc/init && cp -p tty1.conf ttyS0.conf &&
<tty1.conf >ttyS0.conf sed -e 's/tty1/ttyS0/g')
root@ubuntu:~# telinit q
root@ubuntu:~# start ttyS0
I then login via that (virtual machine) serial port (that makes saving
and showing the relevant text bits much more convenient for me).
# virsh console ubuntu1404amd64
Connected to domain ubuntu1404amd64
Escape character is ^]
Apache installed? No, ... install it ...
ubuntu@ubuntu:~$ dpkg -l | fgrep -i -e apache -e httpd
ubuntu@ubuntu:~$ cd / && exec sudo su -
root@ubuntu:~# apt-get install apache2
Now let's configure for Name VirtualHost siteB ...
The default template and default main web page also turn out to be both
very handy and informative ...
root@ubuntu:~# cd /etc/apache2
root@ubuntu:/etc/apache2# ed apache2.conf
7115
/Dir.*\/srv
#<Directory /srv/>
.=
170
/Dir
#</Directory>
.=
174
170,174p
#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>
170,174s/^#//
w
7110
q
root@ubuntu:/etc/apache2# cd sites-available
root@ubuntu:/etc/apache2/sites-available# cp -p 000-default.conf siteB.conf
root@ubuntu:/etc/apache2/sites-available# ed siteB.conf
1332
/^[ ]*#ServerName
#ServerName www.example.com
s/#.*/ServerName siteB
ServerName siteB
s/var.*/srv\/www
DocumentRoot /srv/www
w
1316
q
root@ubuntu:/etc/apache2/sites-available# cd ../sites-enabled
root@ubuntu:/etc/apache2/sites-enabled# ln -s \
../sites-available/siteB.conf siteB.conf
root@ubuntu:/etc/apache2/sites-enabled# cd
root@ubuntu:~# echo siteA > /var/www/html/siteA.txt
root@ubuntu:~# mkdir /srv/www
root@ubuntu:~# echo siteB > /srv/www/siteB.txt
root@ubuntu:~# echo 127.0.0.1 siteB >> /etc/hosts
root@ubuntu:~# service apache2 reload
And then we test:
root@ubuntu:~# wget -q -O - http://127.0.0.1/siteA.txt || echo ERROR
siteA
root@ubuntu:~# wget -q -O - http://127.0.0.1/siteB.txt || echo ERROR
ERROR
root@ubuntu:~# wget -q -O - http://siteB/siteB.txt || echo ERROR
siteB
root@ubuntu:~# wget -q -O - http://siteB/siteA.txt || echo ERROR
ERROR
root@ubuntu:~#
So, notable Apache and related bits, in short, installed Apache,
edited /etc/apache2/apache2.conf so we also had this directory section:
<Directory /srv/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
... we uncommented it, as it was otherwise already there (could have
also changed that /srv/ to /srv/www/ - but this was just quick
test/demo, so /srv/ was close enough).
Then we created:
/etc/apache2/sites-available/siteB.conf
based upon:
/etc/apache2/sites-available/000-default.conf
And in it we set:
ServerName siteB
DocumentRoot /srv/www
We then symlinked it to
/etc/apache2/sites-enabled/siteB.conf
We then created files to be able to test against:
/var/www/html/siteA.txt
/srv/www/siteB.txt
and added:
127.0.0.1 siteB
to:
/etc/hosts
(just test/demo, so we weren't going to bother with DNS)
We then reloaded the Apache server.
We then tested, using wget, showing we got our expected test files on
our expected sites, and also that those same files weren't present on
the sites where they weren't supposed to be present.
After that, we tear down our test - bring the host down, then get rid of
that virtual machine:
root@ubuntu:~# cd / && exec shutdown -h -P now
... and it's still running, Ubuntu displays on the console:
Please remove installation media and close the tray (if any) then press ENTER:
... so I hit ENTER on the console ...
# virsh list --all | sed -ne '1,2p;/ubuntu/p'
Id Name State
----------------------------------------------------
- ubuntu1404amd64 shut off
# virsh undefine ubuntu1404amd64
references/excerpts:
https://lists.ubuntu.com/archives/ubuntu-us-ca/2014-July/date.html
https://lists.ubuntu.com/archives/ubuntu-us-ca/2014-July/002480.html
https://lists.ubuntu.com/archives/ubuntu-us-ca/2014-July/002484.html
https://lists.ubuntu.com/archives/ubuntu-us-ca/2014-July/002486.html
https://lists.ubuntu.com/archives/ubuntu-us-ca/2014-July/002494.html
From: "Scott DuBois" <sdub...@linux.com>
Subject: Re: [Ubuntu-US-CA] Server 14.04 new VirtualHost -- [SOLVED]
Date: Sat, 19 Jul 2014 13:50:16 -0700
On 07/18/2014 06:33 PM, Sander van Zoest wrote:
In apache 2.4 by default you need to whitelist the directories you want
to allow access to outside of the default server root. You can do that
by adding a directory block as follows:
<Directory "/srv/www">
Require all granted
</Directory>
The full details are at
http://httpd.apache.org/docs/2.4/upgrading.html
Linode has a good summary for common issues at
https://library.linode.com/web-servers/apache/2.2-2.4-upgrade#sph_virtual-host-settings-updates
I hope that helps,
-- Sander
On Jul 18, 2014 9:37 AM, "Scott DuBois" <sdub...@linux.com
<mailto:sdub...@linux.com>> wrote:
Hi All,
Over the last few days I've been working on setting up a new VirtualHost
inside Kubuntu 14.04 and been having difficulty getting any results
outside of the /var/www directory.
I've been playing around with LAMP stacks for a number of years as
simple development platforms for HTML, CSS and MySQL projects but as I'm
starting to learn Perl and thought I would set up CGI scripting to
/var/www which is working great then got a "wild hair" and thought I
would try setting up a new VirtualHost pointed to /srv for practice in
going through the motions of getting this to work but I'm still getting
permission errors.
I did a2ensite which resolved just fine and chmod /srv to 755
recursively as well as insuring all the files below are executable. My
file inside /etc/apache2/sites-enabled (sym'd to sites-available) is set
as such:
<VirtualHost *:80>
ServerName roguehorse
ServerAdmin webmaster@localhost
DocumentRoot /srv
#ScriptAlias /cgi-bin/ /srv/cgi-bin/
<Directory "/srv/cgi-bin">
AllowOverride All
Options ExecCGI Multiviews FollowSymLinks
AddHandler cgi-script .cgi .pl .py
Allow from all
</Directory>
</VirtualHost>
This file was copied from the 000-default.conf file as per the
instructions at https://help.ubuntu.com/14.04/serverguide/httpd.html
I have definitely remembered to reset the server multiple times as well
to make sure the changes have taken effect.
If someone could help me out with what I'm doing wrong to get access to
/srv through my loopback I would most grateful!
Also, this is simply a localhost installation that doesn't see the
outside but simply a platform for learning so strict permissions is not
a big priority as much as just getting the process to work then go from
there.
--
Scott DuBois
President EBLUG
BSIT Software Engineering
Freenode: Roguehorse
--
Ubuntu-us-ca mailing list
Ubuntu-us-ca@lists.ubuntu.com <mailto:Ubuntu-us-ca@lists.ubuntu.com>
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-us-ca
As this was the last message in the thread, I just wanted to take this
moment and thank everyone who tried to help and let all those who
subscribe to the list know that I have finally solved the problem I was
trying for.
After reading the following article, it made sense that I was trying to
establish a second DocumentRoot and access as a separate server location
when what I really wanted to do was serve a website from a location
separate from /var/www/html being /srv/www. While not intentionally
trying to escape sudo to my webdocs, the concept was parallel to my goal.
After successfully establishing two separate VirtualHost documents, thus
being able to establish two separate addresses the documents could be
retrieved from, I was still unable to force feed from /srv/www. however,
after creating a link:
ln -sT /srv/www to /var/www/html/srv
webdocs(/srv/www) -----> DocumentRoot(/var/www/html) -----> Browser
This provided the results I was essentially looking for and as such, can
move projects outside sudo and organize as desired. Such a simple fix
once approached from a different perspective. :)
http://askubuntu.com/questions/46331/how-to-avoid-using-sudo-when-working-in-var-www
Thanks again to everyone who tried to help as each suggestion got me
closer to the solution. ;P
--
Scott DuBois
President EBLUG
BSIT Software Engineering
Freenode: Roguehorse
--
Ubuntu-us-ca mailing list
Ubuntu-us-ca@lists.ubuntu.com
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-us-ca
--
Ubuntu-us-ca mailing list
Ubuntu-us-ca@lists.ubuntu.com
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-us-ca