SHARE

With this tutorial, we are going to take a look at the best way to configure a local web server to serve fake domain/subdomains (or virtual hosts) accessible via our browser of choice. Using virtual hosts is a really useful solution to isolate configurations for each virtual host–and it’s easier to migrate code.

We are using Windows 7 as our OS and AppServ v2.5.10

Step 1: Enable the vhost_alias_module in our Apache configuration file:

Open file httpd.conf file located in D:\AppServ\Apache2.2\conf ( or C:\AppServ\Apache2.2\conf)

Change line 203:
#LoadModule vhost_alias_module modules/mod_vhost_alias.so

To this:
LoadModule vhost_alias_module modules/mod_vhost_alias.so

In the same file, we change line 561:
#Include conf/extra/httpd-vhosts.conf

To this:
Include conf/extra/httpd-vhosts.conf

Save the changes and close the file.

Step 2: Edit the vhosts configuration file (httpd-vhosts.conf) in order to define our virtual hosts:

We open the file (located in D:\AppServ\Apache2.2\conf\extra or C:\AppServ\Apache2.2\conf\extra)

Change line 27-34:

ServerAdmin webmaster@dummy-host.x
DocumentRoot "C:/Apache2.2/docs/dummy-host.x"
ServerName dummy-host.x
ServerAlias www.dummy-host.x
ErrorLog "logs/dummy-host.x-error.log"
CustomLog "logs/dummy-host.x-access.log" common

To this:

ServerAdmin webmaster@localhost
DocumentRoot "D:/AppServ/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common

Now our localhost vhost is setup. Next, we will setup a custom vhost for our webapp project. To do this, let’s create a new folder called ex: “s3” in D:\AppServ\www . We can create some file in that folder like index.php.
Ex: we need create virtual host “s3.localhost”:

In the same file, we change lines 36-42


ServerAdmin webmaster@dummy-host2.x
DocumentRoot "C:/Apache2.2/docs/dummy-host2.x"
ServerName dummy-host2.x
ErrorLog "logs/dummy-host2.x-error.log"
CustomLog "logs/dummy-host2.x-access.log" common

To this:

ServerAdmin webmaster@s3.localhost
DocumentRoot "D:/AppServ/www/s3"
ServerName s3.localhost
ErrorLog "logs/s3-error.log"
CustomLog "logs/s3-access.log" common

Now, we save the changes and close the file.

Step 3: Open file C:\Windows\System32\drives\etc\hosts

We add 2 lines to the end of file:

127.0.0.1 localhost
127.0.0.1 s3.localhost

Step 4: restart your machine.

Now, open our browser and go to our newly created virtual host “s3.localhost”

Recent search terms:

  • créé le hostvirtual sur appserver
  • add virtual host appserv
  • appserv hosting
  • how to domain your site in appser
  • how to make domain on appserv

NO COMMENTS