Explore BrainMass

Using Apache to create a virtual host

Step 1: Create a Virtual Host

1. Create a new directory "private_club" within the DocumentRoot directory
2. Create a new virtual host on your server with the name "www.private_club.com" that uses the directory you created in (1) as the DocumentRoot for the virtual host

Step 2: Add support for PHP

1. Add support for php files on the www.private_club.com virtual host. (This can be done in more than one way, but you only have to do it one way.) PHP files are a kind of CGI application, so you will have to configure the directory appropriately and add the necessary handlers.)

Step 3: .htaccess

1. Require anyone accessing the directory to login using the login "member" and password "secret"

Step 4: Testing

You can not test the virtual host portion of the project, but you can test the PHP and .htaccess portions. For PHP, you will have to install PHP from http://www.php.net/downloads.php. You will also need a PHP file to test.

PHP files are HTML pages with code embedded in the page itself, similar to a server side include. To create a php file, open a text editor and enter the following:

<head><title>This is a test!</title></head>
print "Hello, world!n";

Save the file as hello.php into the proper directory on your server. When you open the file with a browser, you should get a page that says "Hello world!"