Изборник Затворити

How to setup multiple domains for projects on local Uniform Server (WAMP platform)

Скраћена веза: https://pedja.supurovic.net/veza/9618

I just installed Uniform Server and I am delighted. First impression is that it is easy to set, efficient and clean. Great Work and completely Open Source and free!

I am in web stuff for decades and none of the tools I used for local development environment seems so nice. Kudos to developers.

In my workflow I use separate local domains for each project. There is number of reasons I never embraced default local www site with each project in subdirectory as it is widely proposed by all WAMP platforms. I usually just use public domain for the project and add .loc at the end. For soem very picky platforms, like WordPress which does not like to change domains, I use public domain for local development too.

My other requirement is that each project is easily configurable and all configuration is easily shareable among several computers or several developers if they are involved on the same project (by using git,  svn or similar service).

I did this with various WAMP platforms I tried and here I will explain how i did it with Uniform Server, as I guess others can benefit from this approach.


– directory where projects are stored is c:\www_projects

– each project is within this directory as separate directory (usually) named by project domain

– all configuration including Apache config is within this directory for easy sharing, placed in c:\www_projects\_vhosts

– example project domain is example.org

First thing is to set Uniform Server as proposed in setup instructions and make sure it works fine.

Then create directory c:\www_projects\example.org and place project web site files there.

Then we need project local domain in .hosts file to make site accessible in local computer. You can edit .hosts file directly or use Uniform Server option Extra / Edit Win hosts file. Make sure you set both base domain and www domain for the project. As we use example.org as project domain .hosts file should get two additional lines like: example.org.loc www.example.org.loc

Note that I added .loc suffix to domains as I use such domains for local development. That leaves public domain still available. This is very helpful when updating working site. You can access public site and also have access to local development.

If you want to use public domain, feel free to do so. If you want site to be accessible from the internet then you should point public domain to your local network and set local network appropriately. That setting is out of scope of this article.

when domain stuff is settled, we have to edit httpd.conf to make web server handle those domains. You may use Apache / Edit Configuration files menu in Uniform Server. Go to the bottom file and add these lines:

Define projects_www_path c:\www_projects
Include ${projects_www_path}/httpd_projects_www_hosts.conf

This will allow Apache to load additional virtual hosts settings from separate configuration files that you control outside of Uniform Server. This edit is the only one that must be done within Uniform Server configuration. Everything else is within your projects. This means if you set new computer, all you have to do is copy projects directory and add these two lines in httpd.conf. This will work even if you use different WAMP platform.

Now create file D:\www_projects\httpd_projects_www_hosts.conf using text editor and make sure it’s contents is like this

# Virtual Hosts for Custom Projects
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.

AllowOverride All
Order deny,allow
Allow from all
Require all granted

DocumentRoot „${projects_www_path}/default“
ErrorLog „logs/default-error.log“
CustomLog „logs/default-access.log“ common

Include ${projects_www_path}/_vhosts/*.conf

This will instruct Apache to look for virtual host config files in  c:\www_projects\_vhosts\. There you would put virtual host config file for each project.

For our example virtual host file should be named c:\www_projects\_vhosts\test.org.conf and its content might be something like this:

DocumentRoot "${projects_www_path}/example.org"
ServerName example.org.loc
ServerAlias www.example.org.loc
CustomLog "logs/example.org.log" common
ErrorLog "logs/example.org-error.log"

This is the most basic settings and good enough for development. Apache will know where to find project files and will store access and error logs separately for this project.

Now you have to restart Apache for this configuration to be loaded and check if site is visible at domain example.org.loc or www.example.org.loc

Further, if you want to add additional projects you just have to create project directory in c:\www_projects, store project files there and create virtual host configuration file in c:\www_projects\_vhosts. And restart Apache, of course.

Оставите одговор

Ваша адреса е-поште неће бити објављена. Неопходна поља су означена *

Попуните израз тако да буде тачан: *

Ово веб место користи Акисмет како би смањило непожељне. Сазнајте како се ваши коментари обрађују.