Apache - Virtual Server Setup
By Sergey Skudaev
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Here we learn how to configure Apache to setup virtual servers. If you do not install Apache and PHP then first read tutorial about installation and configuration Apache and PHP under Windows.
If you develop several web sites on your local PC it is convenient to create separate virtual server for each web site.
On my PC, Apache installed in c:/Apache2.2 directory. On your PC it may be different. Anyway find conf directory inside the Apache directory and open httpd.conf file in notepad. Scroll down to the end of the file and type a directive for a virtual server. I give you example of two vertual servers with IP address of 127.0.0.2 and 127.0.0.3. You can create as many virtual servers as you want using this excample as a template.
NameVirtualHost 127.0.0.2
<VirtualHost 127.0.0.2>
<directory /sitea/htdocs>
allow from all
</directory>
ServerAdmin admin@sitea
ServerName 127.0.0.2
DocumentRoot "/sitea/htdocs"
ScriptAlias /cgi-bin/ "sitea/cgi-bin/"
ErrorLog /sitea/error.log
CustomLog /sitea/access.log common
</VirtualHost>
NameVirtualHost 127.0.0.3
<VirtualHost 127.0.0.3>
<directory /siteb/htdocs>
allow from all
</directory>
ServerAdmin admin@siteb
ServerName 127.0.0.3
DocumentRoot "/siteb/htdocs"
ScriptAlias /cgi-bin/ "siteb/cgi-bin/"
ErrorLog /siteb/error.log
CustomLog /siteb/access.log common
</VirtualHost>
In my case, on C drive I created directory sitea/htdocs and siteb/htdocs. Place index.html file in each hdocs directory.
For site A, I type in index.html the following line of html code: <h1>Site A</h1>
In index.html for site b I typed the following line of html code: <h1>Site B</h1>
Restart Apache, open browser and type in url http://127.0.0.2 and press enter.
The browser displays text: Site A.
Type http://127.0.0.3 and press enter. The browser display text: Site B
You can place PHP file in each root (htdocs) directory and try to run it. It will be running.
Now you can develop two separate web sites.
Did you find information useful?
Send to your friend a link to this page
If you like this page click +1 button.
Please rate the tutorial
How to Build Your Own Web Site from Scratch [Kindle Edition] $2.99
Earn Money on Internet as an Affiliate [Kindle Edition] $0.99
| Comments | |
|---|---|
- Home
- virtual_server
- Batch Files
- Environment Variables
- Delete Trojan horse
- Java Properties
- Form Validation
- Display Image PHP
- Upload File PHP
- phpMyAdmin
- Domain Name
- Name Servers
- CPanel: Mail
- CPanel: MySQL
- CPanel: File Manager
- User_Auth. Demo
- Affordable Hosting
- Hosting Expenses
- Modeless Popup
- Read Screen Resolution
- 301 Redirect
- PHP + Oracle 1
- PHP + Oracle 2
- Hosting Tips
- Monitor Site
- Create Gallery
- Authentication Script
- Display from file
- CSS Fixed Layout
- CSS Float Layout
- CSS Tables
- Loading Speed
- Set Shopping Cart
- My Best CSS Layout
- Using Twitter
- SEO tips
- Database Design
- Password Keeper
- MySQL and Excel
- Learn MySQL
- Learn SQL
- Learn PHP
- Learn C++
- Learn Java
- Learn Visual Basic
- Site map
- Registration
Web programming Tips