[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do i create my own VHOST

Posted on 2009-02-23
14
Medium Priority
?
348 Views
Last Modified: 2013-12-16
Hi Experts,

I have few HTML pages and i am  trying to define this web site
inside my Linux server (RedHat 5).

I thought i define all fine but when i try to browse my site i get the Apache test page.

can someone direct me to the right source in order me to check step by step that i didn't miss something during the procces.

Many Thanks.
0
Comment
Question by:yarshw
  • 6
  • 4
  • 3
  • +1
14 Comments
 
LVL 13

Expert Comment

by:Rowley
ID: 23710271
post your VirtualHost config.

Failing that ensure that you've set up your DocumentRoot to point to the directory containing your files and that you've defined DirectoryIndex to point to the file that serves as your home page.
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23710280
in Redhat

cd /var/www/html/

put your index.html in side this html directory now if you browse it will show your index.html

Now,
if you want to configure you apache for a domain

then you need to create virtualhost



like this
enable  NameVirtualHost *:80
 

then

<VirtualHost *:80>
ServerAdmin fosiul@yourdomain.com
DocumentRoot /var/www/html/yourdomain   -------------- in this yourdomain directory you will put all your htmlpage
ServerName www.yourdomain.com
ServerAlias www.yordomain.com
ServerAlias yorudomain.com
ErrorLog logs/yourdomain_log
CustomLog logs/yorudomain_log combined
</VirtualHost>


then restart the apache
it will wokr
0
 

Author Comment

by:yarshw
ID: 23710342
/etc/httpd/vhosts/site1.conf
-----------------------------------
<VirtualHost *:80>
  ServerName site1.test.com
  DocumentRoot /home/www/site1.test.com
  ErrorLog logs/site1.test.com-error.log
  CustomLog logs/site1.test.com-access.log combined
  <Directory /home/www/site1.test.com>
      AllowOverride All
      Order allow,deny
      Allow from all
  </Directory>
</VirtualHost>


my html files locate here:  /home/www/site1.test.com

when i type on my browser: site1.test.com , i get the Apache test page
when i type on my browser: site1.test.com/index.html , i get the page could not be display.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 23

Expert Comment

by:Maciej S
ID: 23710412
Do you have "NameVirtualHost *:80" directive in your apache config file (fosiul01 wrote about it)?
0
 

Author Comment

by:yarshw
ID: 23710424
I think i found the problem, should i must have index.html file, can't i define other file name
as a start up page?
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23710540
You can define anything you want as an index with DirectoryIndex directive.
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23710553
...but I don't think that this is an issue. You wrote, that you are getting apache test page, so you are pointed to some other directory than /home/www/site1.test.com

Can you attach your complete httpd.conf file?
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23710562
Oh, and one more. You have your vhost configuration in /etc/httpd/vhosts/site1.conf file. Does your apache is aware of that? :) Do you have any "include" directives in your apache config file? (As I wrote in previous comment - attach your complete httpd.conf file).
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23710586
(Correcting my english only... "is your apache aware...".)
0
 

Author Comment

by:yarshw
ID: 23710591
I don't know why but i got the test page, when i changed the name of my main html to "index.html"
i got the first page but of cause this is not good to me because it mess all the links.

can you send me specific instructions how do i changed the start up page with : DirectoryIndex directive?
0
 
LVL 23

Accepted Solution

by:
Maciej S earned 1000 total points
ID: 23710696
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex

Just add in your vhost environment:
DirectoryIndex your_index_page

Where your_index_page can be any page you want to set as 'startup'. Remember, that if you set it to for example startup.html, that apache will search for 'startup.html' in every directory of your website. If it doesn't find it, you will get "permission denied" or directory listing - depending on your apache configuration.
You may define DirectoryIndex per server, vhost, or directory (with <Directory> environment, or .htaccess files).
You may define more than one file as index files (in one line: DirectoryIndex file1.html file2.php) - order does matter - first match wins.
Refer to link to documentation in the beginning of this comment.
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23710721
Hi

in your httpd.conf you will see a line like this

DirectoryIndex index.html index.html.var   -------------------------

suppose if you want to put , index.php or main.php

just add that one with this line

adn then restart your httpd

it will work
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23710815
also one more :

what the directory setup in this line in your httpd.conf


DocumentRoot "/var/www/html"

The folder it will link to, by default apache will try to grab page when no virutal host is defined

suppose if you dont have <VirtualHost *:80> define

now if you type : www.mydomain.com

it will to to show you page from DocumentRoot Directory,

so check that one aswell



0
 

Author Comment

by:yarshw
ID: 23720416
Oklit, thanks.
it's work.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 6 hours left to enroll

831 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