nixCraft Linux / UNIX / Shell Scripting Forum

nixCraft

Linux / UNIX Tech Support Forum

Configuring IPs on apache

This is a discussion on Configuring IPs on apache within the Web servers forums, part of the Mastering Servers category; Hi, First post here. I have a dedicated server which I use to run a number of domains. The server ...


Register free or login to your account to remove all advertisements.

Go Back   nixCraft Linux / UNIX / Shell Scripting Forum > Mastering Servers > Web servers

Linux answers from nixCraft.


Web servers Discussion on Apache, Nginx and Lighttpd HTTP/web server and configuration issues.

Reply

 

Thread Tools Display Modes
  #1 (permalink)  
Old 29th November 2009, 03:21 PM
Junior Member
 
Join Date: Nov 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
TommyBs is on a distinguished road
Default Configuring IPs on apache

Hi,

First post here.

I have a dedicated server which I use to run a number of domains. The server had 1 ip and 1 ssl cert. Recently I've had need to add another ssl cert. To do this I have had to purchase a new IP. For the site that I wish to use this new IP I have set this up correctly in my control panel. However when I try to navigate to the site now, I am presented with a standard default page when there should be an entire site there. When I connect via SCP to the new IP I am shown all the files I would expect to see.

Is there something obvious that I need to do in my httpd.conf file to allow this to work? What seems weird is that sometimes the site does appear to show and then goes again. I'm not sure if I've therefore if I've done something that gets it working or whether caching is affecting it, though it doesn't matter if I refresh with f5 or ctrl+f5.

Elsewhere I've been told the issue may relate to the following:

  1. Define a new IP-based virtual server.
  2. Point that virtual server to a "DocumentRoot" defining the filespace for that virtual server.
  3. Point the DNS record for that virtual server's domain to the new IP address.
most likely points 1 and 2. I'm just not 100% sure what I need to do and would greatly appreciate any help.
Reply With Quote
  #2 (permalink)  
Old 29th November 2009, 08:13 PM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: Red Hat Linux
Scripting language: bash awk sed
Posts: 793
Thanks: 116
Thanked 107 Times in 97 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default

You have been told correctly. Here are some links that may help. These vhosts can be defined in the httpd.conf file.


Quote:
Define a new IP-based virtual server.
Apache IP-based Virtual Host Support

Code:
<VirtualHost www.smallco.com>
    ServerAdmin webmaster@mail.smallco.com
   DocumentRoot /groups/smallco/www
    ServerName www.smallco.com
    ErrorLog /groups/smallco/logs/error_log
    TransferLog /groups/smallco/logs/access_log
    </VirtualHost>
Quote:
Point that virtual server to a "DocumentRoot" defining the filespace for that virtual server.
This is the document root section of the vhost. You would change this to the document root that your html files live. I highlighted that in red in the vhost example. Also be sure to create the log directories from the above example to what ever your site name is.

Quote:
Point the DNS record for that virtual server's domain to the new IP address.
This is handled with your web hosting dns control panel. You would need to define your site in there and point this dns record to the IP of the apache server containing the vhost.

Also upon making any changes to the httpd.conf file you will need to restart the daemon.

Feel free to post some of your attempts if you are a bit lost. I will try to assist.

HTH,

Jaysunn
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #3 (permalink)  
Old 29th November 2009, 09:09 PM
Junior Member
 
Join Date: Nov 2009
OS: Debian
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
TommyBs is on a distinguished road
Default

Hi,

Thanks for getting back,so at the top of httpd.conf file I have 2 listen directives (changes ips here for generalisation):

Code:
Listen 192.168.0.1:80
Listen 192.168.0.2:80
Then in the virtualhost section I have got something similar to the following:

Code:
<VirtualHost 192.168.0.2:80>
    DocumentRoot /var/www/vhosts/example.com/httpdocs/
    ServerName www.example.com
    Errorlog     /var/www/vhosts/example.com/logs/error_log
    TransferLog /var/www/vhosts/example.com/logs/access_log
</VirtualHost>
What's weird is that sometimes my site will load and other times I get a 404 error, and this will happen without changing any settings. It's only happening with this one site which is hosted on the new ip.

The DNS is all setup correctly and using $_SERVER['SERVER_ADDR'] displays the correct IP (when the page loads of course)
Reply With Quote
  #4 (permalink)  
Old 29th November 2009, 09:27 PM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: Red Hat Linux
Scripting language: bash awk sed
Posts: 793
Thanks: 116
Thanked 107 Times in 97 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default

Hmm,

Please try this.

Attempt to gather the logging information from this location when you 404:

Code:
Errorlog     /var/www/vhosts/example.com/logs/error_log
You may be able to pick up the configuration error. Also the way that our production vhosts are setup are like below. We use the same servers IP address however there is a wild card in the vhost. I will show you an example:

Code:
<virtualhost *>
ServerName	www.sitename.com
DocumentRoot	/export/home/phpuser/docrootx/directory
DirectoryIndex	index.php
<Directory 	/export/home/phpuser/docrootx/kgmi>  
RewriteEngine On  
RewriteBase /  
Options +FollowSymLinks -Indexes  
</Directory>  
ErrorDocument 404 /stn_page_server.php  
ErrorDocument 403 /stn_page_server.php  
CustomLog logs/directory/access_log combined 
ErrorLog  logs/directory/error_log 
</virtualhost>
__________________
Have a look at what I have been working on
http://www.shellasaurus.com
Reply With Quote
  #5 (permalink)  
Old 29th November 2009, 09:31 PM
jaysunn's Avatar
Contributors
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: Red Hat Linux
Scripting language: bash awk sed
Posts: 793
Thanks: 116
Thanked 107 Times in 97 Posts
Rep Power: 14
jaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud ofjaysunn has much to be proud of
Default

Also we use the * as the bind address.


Code:
# BindAddress: You can support virtual hosts with this option. This directive
# is used to tell the server which IP address to listen to. It can either
# contain "*", an IP address, or a fully qualified Internet domain name.
# See also the <VirtualHost> and Listen directives.
#
BindAddress *

jaysunn
__________________
Have a look at what I have been working on
http://www.shellasaurus.com

Last edited by jaysunn; 29th November 2009 at 09:33 PM. Reason: changed the Bind Address to a * that we use
Reply With Quote
Reply

Tags
apache, debian httpd, httpd, httpd.conf, redhat httpd, rhel httpd


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
[Solved] Configuring Yum Server knvpavan CentOS / RHEL / Fedora 5 20th May 2009 03:16 PM
configuring DNS on Solaris 10 pappu08 Solaris/OpenSolaris 2 7th April 2009 04:39 AM
Configuring linux to windows sumit Networking, Firewalls and Security 1 3rd March 2009 05:53 PM
Error while configuring Yum linux_sym Getting started tutorials 3 3rd July 2008 11:44 AM
Configuring iscsi RHEL raj CentOS / RHEL / Fedora 1 26th November 2007 08:27 AM


All times are GMT +5.5. The time now is 08:57 AM.


Powered by vBulletin® Version 3.8.6 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40