LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-12-2012, 12:13 PM   #1
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Rep: Reputation: 19
Problem with Apache2 on Ubuntu


Apache 2
Ubuntu 12.04 LTS

Okay, first I should say that I have apache working and is serving pages. My problem is the Alias command does not seem to be working. I've installed Z-Push but it isn't working as expected. If I go to my IPADDR/z-push then it works. I have setup a DNS record (sub.domain.com) which resolves to the correct server and if I go to sub.domain.com/z-push it works.

I want www.domain.com and domain.com not to resolve at all (404) or at worst an blank index.html file. Then I want sub.domain.com to resolve directly to /var/www/z-push.

Can someone please help me set this up. This server will serve 2 functions when I'm complete:

1) Remote samba shares
2) Z-Push / Zimbra sync

Here is what I have so far:

Hostname: sub.domain.com
SET.

/etc/apache2/apache2.conf:
Added: ServerName sub.domain.com

/etc/apache2/sites-available/sub:
<VirtualHost *:80>
ServerAdmin info@sub.domain.com
ServerName sub.domain.com

# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot /var/www/z-push/
Alias /msas /var/www/z-push/index.php

<Directory />
AllowOverride All
</Directory>

php_flag magic_quotes_gpc off
php_flag register_globals off
php_flag magic_quotes_runtime off
php_flag short_open_tag on

# Logfiles
ErrorLog /var/log/apache2/z-push/error.log
CustomLog /var/log/apache2/z-push/access.log combined

</VirtualHost>

Not really sure what is wrong but when I go to IPADDR/msas it doesn't work -- 404 error. I can get to the correct page only by typing /z-push. It will work with sub.domain.com/z-push or IPADDR/z-push.

Any ideas?
 
Old 07-12-2012, 01:55 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
I want www.domain.com and domain.com not to resolve at all (404) or at worst an blank index.html file
Create another vhost (for www.domain.com and aliased to domain.com) before the sub.domain.com vhost, so it will be the default one. Then you can put a blank index page or whatever you want

Quote:
Not really sure what is wrong but when I go to IPADDR/msas it doesn't work -- 404 error. I can get to the correct page only by typing /z-push. It will work with sub.domain.com/z-push or IPADDR/z-push.
You cannot use Alias to alias a file
 
Old 07-12-2012, 02:26 PM   #3
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
Okay... I just made the Alias

Alias /msas /var/www/z-push/

It still gives me a 404 error.

As for the "before" and "after" for the vhosts. I'm a little confused with Ubuntu, maybe you can shed some light on the situation. I've only ever worked with apache under CentOS, so the setup is a little different.

/etc/apache2
on CentOS it's httpd -- not a big deal.

However I have never worked with apache2.conf, always httpd.conf but in my case the httpd.conf is empty and apache2.conf seems to be the configuration file.

Also, on my CentOS box there is an httpd/extras folder in which the vhosts, etc are defined. Here there is /etc/apache2/sites-available and /etc/apache2/sites-enabled.

Not sure which one loads first. In the sites-enabled directory there is 000-default symlink which points to the /etc/apache2/sites-available/default file.

Not sure of the process that is happening here and would appreciate some feedback if you can provide it.
 
Old 07-12-2012, 04:49 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Okay... I just made the Alias

Alias /msas /var/www/z-push/

It still gives me a 404 error.
This is because you already have a default vhost (the one defined by sites-enabled/000-default file), where the Alias above does not exist. Note also that you don't need the trailing slash in the aliased directory.
Quote:
I've only ever worked with apache under CentOS, so the setup is a little different.
You can edit the etc/apache2/sites-available/default to define there the www.domain.com (and its aliased domain.com)
Also since you're using /etc/apache2/sites-available/sub to define sub.domain.com, you should run:
Code:
a2ensite sub
to enable that vhost too. a2ensite is needed in order for the necessary symlinks in sites-enabled to be created.
For more details about apache vhosts in debian/ubuntu, see this

Regards
 
Old 07-13-2012, 01:36 PM   #5
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
Okay, thank you for the information. I read that page and have fixed an warning message that I was getting. I have followed the NameVirtualHost directions but it is still not working.

Here is what I have:
Code:
<VirtualHost *:80>
        ServerAdmin webmaster@domain.com
        ServerName  sub.domain.com

        # Indexes + Directory Root.
        DirectoryIndex index.php
        DocumentRoot /var/www/z-push/

        <Directory />
                AllowOverride All
        </Directory>

        php_flag magic_quotes_gpc off
        php_flag register_globals off
        php_flag magic_quotes_runtime off
        php_flag short_open_tag on

        # Logfiles
        ErrorLog  /var/log/apache2/z-push/error.log
        CustomLog /var/log/apache2/z-push/access.log combined
 </VirtualHost>
When I go to: sub.domain.com it takes me to /var/www (not /var/www/z-push).

Any other suggestions?
 
Old 07-13-2012, 02:07 PM   #6
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Can you post the output of
Code:
apache2ctl -S
This will give us a better idea of your current virtualHost/domain set-up
Best,
M
 
Old 07-13-2012, 02:18 PM   #7
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
Code:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server sub.domain.com (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost sub.domain.com (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost sub.domain.com (/etc/apache2/sites-enabled/z-push:1)
Syntax OK
Output of hostname as well:
Code:
> hostname     
sub.domain.com
Maybe I messed it up by setting my hostname as sub.domain.com, honestly, I'm not sure. However, here is my desired setup:

1. domain.com DNS is actually managed on another server completely. I have created an A record in that DNS system for sub.domain.com to point to this particular server (call it 1.2.3.4). As a result when someone goes to domain.com or www.domain.com they are on another server, not this one. So, I don't really need to worry about setting up apache to work with domain.com or www.domain.com.

2. When someone goes to sub.domain.com I want it to resolve to 1.2.3.4 --> which it does.

3. From there, I want apache to server z-push.

4. I would prefer that apache does not server anything if 1.2.3.4 is typed in.
 
Old 07-13-2012, 03:12 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
default server sub.domain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost sub.domain.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost sub.domain.com (/etc/apache2/sites-enabled/z-push:1)
You have defined sub.domain.com in both the default and the sub.domain.com vhosts, that's why it's not working.
Quote:
1. domain.com DNS is actually managed on another server completely. I have created an A record in that DNS system for sub.domain.com to point to this particular server (call it 1.2.3.4). As a result when someone goes to domain.com or www.domain.com they are on another server, not this one. So, I don't really need to worry about setting up apache to work with domain.com or www.domain.com.

2. When someone goes to sub.domain.com I want it to resolve to 1.2.3.4 --> which it does.

3. From there, I want apache to server z-push.

4. I would prefer that apache does not server anything if 1.2.3.4 is typed in.
So named the default vhost 1.2.3.4 and put a blank page as an index page
Leave sub.domain.com definition as in your #5 post
Reload apache and test.
 
Old 07-13-2012, 03:29 PM   #9
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
Okay... I figured out why sub.domain.com is being declared as the default server. I put ServerName sub.domain.com in the apache.conf file.

I just took it out, but now I get this error when restarting apache:

Code:
Restarting web server apache2                                                                  apache2: Could not reliably determine the server's fully qualified domain name, using sub.domain.com for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using sub.domain.com for ServerName
 
Old 07-13-2012, 03:38 PM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
This is just a warning, but you shouldn't get that, if your vhosts are configured correctly
What's in /etc/apache2/sites-enabled/000-default?
 
Old 07-13-2012, 03:48 PM   #11
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
It is the default installation config file.
Code:
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </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>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    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>
</VirtualHost>
 
Old 07-13-2012, 03:58 PM   #12
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
So add a
Code:
ServerName 1.2.3.4
and you'll be ok
 
Old 07-13-2012, 04:07 PM   #13
jim.thornton
Member
 
Registered: May 2007
Posts: 430

Original Poster
Rep: Reputation: 19
Okay, I did that and now the error message is gone.

However, apache is still serving /var/www/ and not /var/www/z-push/

Any ideas why? If I type in sub.domain.com/z-push it goes to the correct place but it is suppose to server /var/www/z-push by going to only sub.domain.com
 
Old 07-13-2012, 04:23 PM   #14
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Are you sure it's not your browser cache?
Because according to the sub.domain.com vhost configuration, the DocumentRoot is /var/www/z-push/ (remove the trailing slash), so using http://sub.domain.com it should give you the index page under /var/www/z-push
 
Old 07-13-2012, 07:22 PM   #15
helptonewbie
Member
 
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518

Rep: Reputation: 39
Agreed with Bathory. There is something we can do here... Check the access_log files, you have set-up separate access log files for each Vhost, see which one the requests appear in, just so we can make sure requests are going to the correct Virtual Host.

Also after any changes, another apache2ctl -S would be good just to check on the progress there too.

If you 'ls -l /etc/apache2/sites-enabled/' - I'd expect you to only see two files, 000-default and z-push? Of which the contents of are the same as the files you've provided in the previous posts.

The only reason it wouldn't work is because your still hitting the default Vhost rather than z-push Vhost, other than certainly checking things like Browser cache as well as already mentioned.
 
  


Reply



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
Ubuntu + Apache2 + Wordpress Silver565 Linux - Server 8 12-15-2011 01:34 AM
Ubuntu + Apache2 + ftp? Silver565 Linux - Software 5 06-15-2009 11:56 PM
ASP w/ Apache2 on Ubuntu 8.10 fackamato Linux - Server 3 03-05-2009 09:00 AM
Help setting up apache2 on ubuntu joe2748 Linux - Server 3 02-04-2008 06:51 PM
Apache2 server on Ubuntu nw504 Linux - Server 2 02-17-2007 05:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration