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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
07-12-2012, 01:13 PM
|
#1
|
Member
Registered: May 2007
Posts: 430
Rep:
|
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?
|
|
|
07-12-2012, 02:55 PM
|
#2
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
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
|
|
|
07-12-2012, 03:26 PM
|
#3
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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.
|
|
|
07-12-2012, 05:49 PM
|
#4
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
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:
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
|
|
|
07-13-2012, 02:36 PM
|
#5
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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?
|
|
|
07-13-2012, 03:07 PM
|
#6
|
Member
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518
Rep:
|
Can you post the output of
This will give us a better idea of your current virtualHost/domain set-up
Best,
M
|
|
|
07-13-2012, 03:18 PM
|
#7
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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.
|
|
|
07-13-2012, 04:12 PM
|
#8
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
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.
|
|
|
07-13-2012, 04:29 PM
|
#9
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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
|
|
|
07-13-2012, 04:38 PM
|
#10
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
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?
|
|
|
07-13-2012, 04:48 PM
|
#11
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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>
|
|
|
07-13-2012, 04:58 PM
|
#12
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
So add a
and you'll be ok
|
|
|
07-13-2012, 05:07 PM
|
#13
|
Member
Registered: May 2007
Posts: 430
Original Poster
Rep:
|
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
|
|
|
07-13-2012, 05:23 PM
|
#14
|
LQ Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,218
|
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
|
|
|
07-13-2012, 08:22 PM
|
#15
|
Member
Registered: Aug 2006
Location: England Somewhere
Distribution: Mandriva, PCLinuxOS, Karoshi, Suse, Redhat, Ubuntu
Posts: 518
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 05:29 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|