Jump to content

Creating a Domain Using Apache VHost


Fmdpa

Recommended Posts

I'm wanting to create a new domain/subdomain on Apache. Up until now, I've changed the domain name using the Windows HOSTs file. How do I create new domains in Apache? I have a feeling it involves something with name-based virtual hosts.

Link to comment
Share on other sites

<VirtualHost *:80>ServerName www.domain.tldServerAlias domain.tld *.domain.tldDocumentRoot /www/domain</VirtualHost>

Add one of these to your httpd.conf file on Windows. The ServerAlias directive will be whatever domain you want to point to your ip. Create multiple of these when you want to create subdomains etc.When you add the extra domains remember the change wont be reflected untill you update your dns or host file:

  my.domain.com 127.0.0.1

Source

Link to comment
Share on other sites

What's the etc/vhosts.conf file for?
An example of the kind of configuration sansana is talking about. Instead of actually writing it out, you may try to alter those settings instead (and include them from the main httpd.conf of course).
Link to comment
Share on other sites

All the domain name system does is associate domain names with IP addresses. Normally this is done through DNS servers scattered around the Internet, which when given a domain name will return the IP address it has in memory. When you add an entry to the hosts file, this overrides whatever answer the DNS servers give, and the host file's entry is used instead (only for your local computer, though). The DNS is not intrinsically associated with HTTP or other application-layer protocols, and cannot be modified using Apache.

Link to comment
Share on other sites

Ok, I entered this into my hosts file:

127.0.0.1 www.cyberstream.us cyberstream.us project localhost

httpd.conf:

<VirtualHost *:80>ServerName www.cyberstream.usServerAlias cyberstream.us localhostDocumentRoot "C:/PHP/www"</VirtualHost><VirtualHost *:80>ServerName projectDocumentRoot "C:/PHP/www-project"</VirtualHost>

It works just fine, EXCEPT that the htaccess rewrites are not working. The rewrite module is loaded along with the other modules, so why wouldn't this be working?

Link to comment
Share on other sites

The rewrites should be working for the default host. AFAIK, they aren't inhereted in virtual hosts, and you seem to be replacing your default host with a virtual host.Try moving your rewrite rules into the VirtualHost section.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...