LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 10-10-2012, 10:19 AM   #1
gunnarflax
LQ Newbie
 
Registered: Nov 2010
Posts: 20

Rep: Reputation: 4
Having trouble setting up Apache virtual hosts on Ubuntu 12.04


Hello everyone! I'm having some trouble configuring apache to properly serve my two websites which I have on a personal server. I'm running Ubuntu 12.04.1 x64 Server Edition.

I have two sites in /var/www/ which I'll refer to as site1.com and site2.com. It all started out with me being able to view both site1 and site2 perfectly but when attempting to access my phpmyadmin installation through http://localhost/phpmyadmin I got permission denied errors.

I'm not entirely sure that my configuration is correct since I haven't configured this before, I've just dived into all the documentation I've been able to find. This is how it looks like today.

/var/www/:
Code:
--site1.com
----web -> /usr/share/wordpress
----uploads
--site2.com
----web -> /usr/share/wordpress
----uploads
with the permissions for each directory:
Code:
drwxrwxr-x 3 root www-data uploads
lrwxrwxrwx 1 root www-data web
I have set up a global configuration in httpd.conf (correct me if this is wrong) with basically the settings that were in the default-site bundled with lampp:
Code:
ServerSignature Off
ServerTokens Prod

NameVirtualHost *:80

<ifmodule mod_ssl.c>
	NameVirtualHost *:443
</ifmodule>

<Directory />
	Options -Indexes FollowSymLinks
	AllowOverride None
	Order deny,allow
	Deny from all
</Directory>

<Directory /var/www/>
	Options -Indexes FollowSymLinks MultiViews
	AllowOverride None
	Order allow,deny
	Allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin/>
	AllowOverride None
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	Order allow,deny
	Allow from all
</Directory>

Alias /doc/ /usr/share/doc/
<Directory /usr/share/doc/>
	Options -Indexes MultiViews FollowSymLinks
	AllowOverride None
	Order deny,allow
	Deny from all
	Allow from 127.0.0.0/255.0.0.0 ::1/128 	
</Directory>
The NameVirtualHost setting gives me an error on startup of apache but I don't know if it matters:
Code:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Wed Oct 10 16:52:28] [warn] NameVirtualHost *:80 has no Virtualhosts
and the site specific configuration (the same for both sites except for the FQDN):
Code:
<VirtualHost *:80>
	ServerAdmin site1@gmail.com
	ServerName site1.com
	ServerAlias www.site1.com

	LogLevel warn
	ErrorLog /var/log/apache2/site1.com/error.log
	CustomLog /var/log/apache2/site1.com/access.log combined

	DocumentRoot /var/www/site1.com/web
</VirtualHost>
(Do the <Directory> options, like -Indexes, need to be specified here as well?)

My /etc/hosts configuration looks like this:
Code:
127.0.0.1	localhost
127.0.1.1	servername

#Virtualhosts
127.0.0.1	www.site1.com
127.0.0.1	site1.com
127.0.0.1	www.site2.com
127.0.0.1	site2.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
All help is welcome, I look forward to learning how I can secure the server better!
 
Old 10-10-2012, 11:40 AM   #2
gunnarflax
LQ Newbie
 
Registered: Nov 2010
Posts: 20

Original Poster
Rep: Reputation: 4
Nevermind, I got it working! I removed all the configuration done in httpd.conf and just set the standard parameters in /etc/apache2/conf.d/security which seemed to be best practice. Then I added the <Directory> configurations from /etc/apache2/sites-available/default to each site's configuration but changed <Directory /var/www/> to <Directory /var/www/site1.com/web/> which I hadn't done before and now both my sites + phpmyadmin works! Huzzah!
 
  


Reply

Tags
apache, configuration, server, ubuntu 12.04, virtual host


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
[SOLVED] Setting up Apache 2.2 virtual hosts WetDreams Slackware 3 12-11-2011 05:40 AM
[SOLVED] Apache Virtual Hosts - Ubuntu Desktop Macnux Linux - Server 7 07-15-2011 06:26 PM
LXer: Setting Up Subversion And Trac As Virtual Hosts On An Ubuntu Server LXer Syndicated Linux News 0 01-13-2008 09:20 AM
About setting up virtual hosts raymond Linux - General 7 09-21-2004 09:14 AM
Setting up virtual hosts in Apache using Webmin Spudley Linux - Software 2 09-25-2003 08:50 PM


All times are GMT -5. The time now is 01:50 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