LinuxQuestions.org
Review your favorite Linux distribution.
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 09-07-2011, 03:55 PM   #1
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Rep: Reputation: Disabled
Smile Virtual Hosts


hi i have managed to set up my virtual host on cent os but cant seem to make it public can only view the site on local network please help thanks.
 
Old 09-07-2011, 04:02 PM   #2
cheddarcheese
Member
 
Registered: Aug 2011
Location: Massachusetts, USA
Distribution: Fedora; Centos; Puppy
Posts: 82

Rep: Reputation: 5
So, you have assigned a public IP address to this site/domain ... yes?

What happens when you try to view it publicly? Do you get some sort of error code returned?
 
Old 09-07-2011, 04:05 PM   #3
pingu
Senior Member
 
Registered: Jul 2004
Location: Skuttunge SWEDEN
Distribution: Debian preferably
Posts: 1,350

Rep: Reputation: 127Reputation: 127
Might be a dns-problem, hard to tell with almost no info÷
To start with, please post your network layout, VirtualHost-config and dns record for the domain.
 
Old 09-07-2011, 04:42 PM   #4
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
sorry for lack of info

yes i have only 1 public ip and trying to run 2 sites on different ports
this is my VH setup.....

# Virtual host Bm-Filehost
<VirtualHost 192.168.0.56>
DocumentRoot /var/www/html/BM-Filehost
ServerAdmin dean-s@live.co.uk
ServerName localhost.localdomain
DirectoryIndex index.php index.html index.htm index.shtml
<Directory "/var/www/html/BM-Filehost">
Options all
AllowOverride All
Allow from all
</Directory>

LogLevel debug
HostNameLookups off

</VirtualHost>


# Virtual host Bassline-Madness
<VirtualHost 192.168.0.55>
DocumentRoot /var/www/html/Bassline-Madness
ServerAdmin dean-s@live.co.uk
ServerName localhost.localdomain
DirectoryIndex index.html index.htm index.php index.shtml
<Directory "/var/www/html/Bassline-Madness/">
Options all

AllowOverride All
Allow from all
</Directory>
</VirtualHost>
 
Old 09-07-2011, 04:48 PM   #5
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Virtual Hosts in Apache

I suggest you change to name based virtual hosts. Check the Apache site for instructions.

Also, have you opened the correct ports on your firewall? I assume you have a router as your IP address is private (internal). If you are behind a firewall you will need to open port 80 on your router which is the HTTP service. Once you have confirmed this setting go to IP Chicken and try to access the site via the returned IP address.

Last edited by bskrakes; 09-07-2011 at 04:50 PM.
 
Old 09-07-2011, 04:52 PM   #6
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
i have my main site running already wanted to run another site on different port ill take a look thanks
 
Old 09-07-2011, 04:55 PM   #7
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Based on the configuration you showed us you are running the two sites on different IP addresses, not ports. How is your host configured, do you have multiple NICs or are you using virtual interfaces?

Can you do the following and display post the results:
Quote:
netstat -l

Last edited by bskrakes; 09-07-2011 at 04:57 PM.
 
Old 09-07-2011, 05:06 PM   #8
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
result

[root@localhost ~]# netstat -l
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:mysql *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 localhost.localdomain:http *:* LISTEN
tcp 0 0 localhost.localdo:hosts2-ns *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost.localdomain:ipp *:* LISTEN
tcp 0 0 localhost.localdomain:smtp *:* LISTEN
tcp 0 0 *:https *:* LISTEN
tcp 0 0 *:nas *:* LISTEN
udp 0 0 *:37401 *:*
udp 0 0 *:985 *:*
udp 0 0 *:988 *:*
udp 0 0 *:mdns *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 5816 @ISCSIADM_ABSTRACT_NAMESPACE
unix 2 [ ACC ] STREAM LISTENING 8175 /var/lib/mysql/mysql.sock
unix 2 [ ACC ] STREAM LISTENING 9248 @/tmp/fam-root-
unix 2 [ ACC ] STREAM LISTENING 6076 /var/run/audispd_events
unix 2 [ ACC ] STREAM LISTENING 6519 /var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 6602 /var/run/sdp
unix 2 [ ACC ] STREAM LISTENING 6683 /var/run/pcscd.comm
unix 2 [ ACC ] STREAM LISTENING 6708 /var/run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 8065 /var/run/cups/cups.sock
unix 2 [ ACC ] STREAM LISTENING 8558 /var/run/avahi-daemon/socket
unix 2 [ ACC ] STREAM LISTENING 5802 @ISCSID_UIP_ABSTRACT_NAMESPACE
unix 2 [ ACC ] STREAM LISTENING 6743 @/var/run/hald/dbus-e9tEkuGGlh
unix 2 [ ACC ] STREAM LISTENING 8309 /dev/gpmctl
unix 2 [ ACC ] STREAM LISTENING 8423 /tmp/.font-unix/fs7100
unix 2 [ ACC ] STREAM LISTENING 8942 /tmp/.gdm_socket
unix 2 [ ACC ] STREAM LISTENING 8970 /tmp/.X11-unix/X0
unix 2 [ ACC ] STREAM LISTENING 9341 /tmp/ssh-tRdsKP3011/agent.3011
unix 2 [ ACC ] STREAM LISTENING 9398 /tmp/orbit-root/linc-c0b-0-47b76b8b63d13
unix 2 [ ACC ] STREAM LISTENING 9407 /tmp/orbit-root/linc-bc3-0-359f9ee76e886
unix 2 [ ACC ] STREAM LISTENING 9597 /tmp/.ICE-unix/3011
unix 2 [ ACC ] STREAM LISTENING 9606 /tmp/keyring-rQZZfM/socket
unix 2 [ ACC ] STREAM LISTENING 9625 /tmp/orbit-root/linc-c10-0-39ff8e92c6d0e
unix 2 [ ACC ] STREAM LISTENING 9695 /tmp/orbit-root/linc-c24-0-64bbc7e04c53b
unix 2 [ ACC ] STREAM LISTENING 9747 /tmp/orbit-root/linc-c28-0-6ab77e6a88d73
unix 2 [ ACC ] STREAM LISTENING 9767 /tmp/orbit-root/linc-c2c-0-6ab77e6a8e95c
unix 2 [ ACC ] STREAM LISTENING 9793 /tmp/orbit-root/linc-c2a-0-6ab77e6aa6be4
unix 2 [ ACC ] STREAM LISTENING 10285 /tmp/mapping-root
unix 2 [ ACC ] STREAM LISTENING 9814 /tmp/orbit-root/linc-c36-0-67d3b432ae16f
unix 2 [ ACC ] STREAM LISTENING 10104 /tmp/orbit-root/linc-c40-0-73e03f2039245
unix 2 [ ACC ] STREAM LISTENING 10113 /tmp/orbit-root/linc-c2e-0-2b14531c46793
unix 2 [ ACC ] STREAM LISTENING 10192 /tmp/orbit-root/linc-c32-0-6ab77e69c31c6
unix 2 [ ACC ] STREAM LISTENING 10181 /tmp/orbit-root/linc-c38-0-5c9ccd07b4d9f
unix 2 [ ACC ] STREAM LISTENING 10203 /tmp/orbit-root/linc-c5a-0-5c9ccd07cd873
unix 2 [ ACC ] STREAM LISTENING 10226 /tmp/orbit-root/linc-c49-0-70b920a8c4c6
unix 2 [ ACC ] STREAM LISTENING 10245 /tmp/orbit-root/linc-c58-0-4edd8e671ef5f
unix 2 [ ACC ] STREAM LISTENING 10319 /tmp/orbit-root/linc-c4c-0-6c053434838e
unix 2 [ ACC ] STREAM LISTENING 10354 /tmp/orbit-root/linc-c7a-0-1208068e93293
unix 2 [ ACC ] STREAM LISTENING 10373 /tmp/orbit-root/linc-c7c-0-1208068ea5863
unix 2 [ ACC ] STREAM LISTENING 10392 /tmp/orbit-root/linc-c7e-0-1208068ebe9c4
unix 2 [ ACC ] STREAM LISTENING 10585 /tmp/orbit-root/linc-ca6-0-375911c612edd
unix 2 [ ACC ] STREAM LISTENING 138139 /tmp/orbit-root/linc-3c21-0-3c4dc3cc3d0fa
unix 2 [ ACC ] STREAM LISTENING 138143 /tmp/gedit.root.3259071906
unix 2 [ ACC ] STREAM LISTENING 138259 /tmp/orbit-root/linc-3c49-0-2835920b8b69b
unix 2 [ ACC ] STREAM LISTENING 142934 /tmp/orbit-root/linc-3db7-0-7198f37a7f3cd
unix 2 [ ACC ] STREAM LISTENING 147014 /tmp/orbit-root/linc-405b-0-45b0848ae9dcf
unix 2 [ ACC ] STREAM LISTENING 6744 @/var/run/hald/dbus-Ga9eSRmhbX
unix 2 [ ACC ] STREAM LISTENING 9377 @/tmp/dbus-gGPb7XRMwT
 
Old 09-07-2011, 05:10 PM   #9
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
How have you setup the two IP addresses, do you have two physical NICs (network interface cards)?
 
Old 09-07-2011, 05:12 PM   #10
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
i have 1 network card and i have added a second ip to this so both on same connection im getting the feeling this cannot be done without 2 ethernet connection :s
 
Old 09-07-2011, 05:16 PM   #11
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Virtual Hosts in Apache

I'd have to try this as I've never done virtual hosts the way you are attempting but if you had the proper NIC configuration you could do the following:

Quote:
first site ip address: 192.168.0.55:80
The above is your main website listening on the default HTTP port. Your second site could be configured like this:

Quote:
second site ip address: 192.168.0.56:8080
But in order to get the second site working you will have to open port 8080 on your server and then your router. To access the site publicly you'd have to append the address with :8080. For example:

Quote:
mydomain.com:8080
The traffic will also have to be setup for port forwarding since you are most likely behind a router.

And yes you are correct, without a virtual interface or second physical NIC you cannot do that - at least not to my knowledge.
 
Old 09-07-2011, 05:21 PM   #12
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
ok i have a second nic i will install the try again thankyou for your help by the way the
Quote:
mydomain.com:8080
would i still have to do this through 2 nics?
 
Old 09-07-2011, 05:27 PM   #13
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Configuring Name Based Virtual Hosts in Apache

Here is what I would do:

1) Configure Apache for Name Based Virtual Hosts (depending on your Linux/UNIX OS) edit the following file: /etc/httpd/conf/httpd.conf

2) Find Section 3 in the configuration file, uncomment or copy the line down like I did to use name based hosting:
Quote:
### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
NameVirtualHost *:80
3) At the end of the configuration file modify your sites, for example:

Quote:
<VirtualHost *:80>
ServerAdmin webmaster@abc.com
DocumentRoot /var/www/vhosts/abc.com
ServerName abc.com
ErrorLog logs/abc.com-error_log
CustomLog logs/abc.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
DocumentRoot /var/www/vhosts/mydomain.com
ServerName mydomain.com
ErrorLog logs/mydomain.com-error_log
CustomLog logs/mydomain.com-access_log common
</VirtualHost>
4) test the configuration file: (keeping in mind this command may be different based on your Linux/UNIX OS)
Quote:
[root@your-server-name ~]# apachectl configtest
5) if the test says ok then restart apache: (keeping in mind this command may be different based on your Linux/UNIX OS)
Quote:
service restart apache
 
Old 09-07-2011, 05:30 PM   #14
deanspink1986
Member
 
Registered: Sep 2011
Posts: 32

Original Poster
Rep: Reputation: Disabled
ok i will try this thankyou again for your help
 
Old 09-07-2011, 05:35 PM   #15
bskrakes
Member
 
Registered: Sep 2006
Location: Canada, Alberta
Distribution: RHEL 4 and up, CentOS 5.x, Fedora Core 5 and up, Ubuntu 8 and up
Posts: 251

Rep: Reputation: 32
Before you muck around with that file
Quote:
/etc/httpd/conf/httpd.conf
PLEASE be sure to back it up. I should have mentioned that first!!! What distribution are you using?

No problem, I am happy to help... you are very welcome!

Honestly the name based is MUCH easier than multiple NICs. There is also several pros to configure it this way as you don't have to configure your router, firewall, etc for the second IP address/NIC interface.

If at the end of the day together we have solved your problem don't forget to mark your post as "SOLVED" =)
 
  


Reply


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
debian lenny - all virtual hosts lead to first virtual host rantastic Linux - Server 2 04-21-2010 10:32 PM
Virtual Hosts ayomacro Linux - Server 1 02-29-2008 07:00 PM
virtual hosts Four Ubuntu 1 03-12-2007 02:30 AM
vsftpd, web uploads, vsftpd virtual users, apache virtual hosts, home directories jerryasher Linux - Software 7 02-18-2007 07:29 AM
virtual hosts... Digital_Err0r Linux - Newbie 25 03-25-2004 04:58 PM


All times are GMT -5. The time now is 10:40 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration