chchrist
chchrist

Reputation: 19822

How to setup vhosts for local development

How can I set up Apache 2.2 to load the site from htdocs/example/ when I write in the address bar example.local?

Thanks in advance

Upvotes: 0

Views: 192

Answers (1)

wonk0
wonk0

Reputation: 13972

You have to make sure that example.local resolves to your local machine, easiest way is by adding a line like

127.0.0.1  example.local

to your hosts file (linux: /etc/hosts; win: %SystemRoot%\system32\drivers\etc\hosts). And than you need a vhost in your apache config, like (this is very basic)

<VirtualHost 127.0.0.1:80>
  ServerName    example.local
  DocumentRoot  /path/to/htdocs
  ErrorLog      /path/to/error.log
  CustomLog     /path/to/access.log combined
</VirtualHost>

That way you should be able to to access files in htdocs/example/ via http://example.local/example/

For more details please refer to the fine apache manual

Upvotes: 1

Related Questions