Solved

Apache - Ubuntu - Virtual hosts

Posted on 2012-12-21
5
360 Views
Last Modified: 2013-02-04
hi,
I have Virtual hosts set up on Ubuntu/Apache.
The domain names for my sites are working fine.
But if I type in the IP address of my server I get the apache default page.
What do I need to put in the apache conf file to direct the IP address of the server to display a site on my server.
Do I need to create a whole new <VirtualHost *.80>  block or do I enter something in the current <VirtualHost *.80> block?
Thanks!
Nacht
0
Comment
Question by:nachtmsk
  • 2
  • 2
5 Comments
 

Expert Comment

by:BeckSCS
ID: 38713200
Your conf file should have something like this for the configuration.

<VirtualHost ipAddress:80>
ServerName domain.com
ServerAlias www.domain.com
ServerAdmin name@domain.com
DocumentRoot /var/www/"file location"
</VirtualHost>

The main important part is the ipAddress and DocumentRoot. If you would like a tool to better help you manage the server webmin is free and works great on ubuntu.

If you plan on running multiple websites from the same server you'll need to look into setting up a MultiSite Layout.
0
 

Author Comment

by:nachtmsk
ID: 38713237
Thanks, but where/how do I put in the IP address of the server so it directs to a virtual site and not the default Apache site?
0
 

Expert Comment

by:BeckSCS
ID: 38713298
It sounds like the issue that you're running into is the document location is wrong. Find where you are saving the web files and add that document location.

Changing the <Directory /var/www/> to your location should work if you're only running one website on the server.

You will have to restart apache or the server when making changes.

sudo service apache2 restart or sudo /etc/init.d/apache2 restart

What kind of access do you have to the server?
0
 

Author Comment

by:nachtmsk
ID: 38714009
I have root access. Think I just solved it. I put in a server alias of the IP address. The problem I was trying to solve is that the IP address was going to the default location while the virtual  hosts (domain names) were going to the correct location. I wanted the IP address (if put into a browswer) to go to one of my virtual hosts.
0
 
LVL 3

Accepted Solution

by:
nam0a earned 500 total points
ID: 38750915
Put the first site in the first virtual host entry
like
NameVirtualHost 192.168.0.1

<VirtualHost 192.168.0.1>   
    DocumentRoot "/var/www/html/site1"
	ServerAlias www.example.com
	ServerAdmin root@example.com
    ServerName example.com
</VirtualHost>

<VirtualHost 192.168.0.1>
    DocumentRoot "/var/www/html/site2"
    ServerName example2.com
	ServerAlias www.example2.com
	ServerAdmin root@example2.com
</VirtualHost>

Open in new window

here site1 is the fist site that is to be redirected when the user type the IP address.
also make sure DocumentRoot is set to the correct site /var/www/html/site1

DocumentRoot "/var/www/html/site1"
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
add some character at the end of line in vi 7 78
mcrypt_create_iv() is deprecated 4 142
installing docker on ubuntu 6 28
Tomcat on Windows.  URL with {curly braces} fails. 1 43
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now