I have spent the last few days setting up a CentOS 6 server on my local network so that I can host multiple projects that I'm currently working on. Everything has been set up so that I access the server by typing and the Apache test page comes up.

What I'm aiming to do is to access different projects by typing in, and then view the project as if it was on it's own standalone server. I have thought about just sticking these sites inside folders on the server then accessing them that way, but a lot of my projects use CakePHP so this isn't feasible.

So what I need to do is create VirtualHosts in Apache to allow me to do this, but without using a domain name. I want to stick to using the IP address of the machine (which is static).

Any ideas?

I've followed Peter's suggestion, but now I have a new problem.

In the httpd.conf file I have entered the following information:

NameVirtualHost *:80

<VirtualHost *:80>
     ServerAdmin admin@local.com
     DocumentRoot /www/html/project1
     ServerName local.project1.com
     ErrorLog logs/local.project1.com-error_log
     CustomLog logs/local.project1.com-access_log common

And now Apache is saying:

Starting httpd: Warning: DocumentRoot [/www/html/project1] does not exist

When it clearly does exist. I've disabled SELinux and I can confirm this isn't turned on. I've also checked the ownership of the folder, and its owned by root. I can also save files to these folders using a guest FTP account (which isn't associated to root), so the folders are being listed and can be written to. But when I try the folder in a web browser it doesn't seem to work either. I've also done a reboot of the server and the problem persists.

What should I change in order to resolve this?

  • you should create a second question for your second problem... and the answer might be that /www/html/project1 does not exist. This should probably be /var/www/html/project1 and before you start the server you should run mkdir /var/www/html/project1 and (possibly chown or chmod). See httpd.apache.org/docs/2.0/mod/core.html#documentroot – Peter Dec 13 '12 at 15:21

You can put your virtual dns names in your hosts file.

eg. in Linux,

vim /etc/hosts

and fill in: project1 project2 project3

In Windows XP (win7, etc. are probably similar), edit the file c:\windows\system32\drivers\etc\hosts

and fill in: project1 project2 project3

And then when you go to http://project2/ in your browser, you will have the project2 web root (if you set up your virtual hosts properly).

Or set up an internal dns server if you have many developers using these aliases or if the aliases change all the time. (This is my preferred choice... I do this for the test website)


You can use multiple ports on the same IP address, multiple IP addresses (if you have them) or multiple domains. If I were you, i'd add some local domains e.g. p1.lan, p2.lan, p3.lan to /etc/hosts (linux) or Windows\System32\drivers\etc\hosts (windows) and point them to

VirtualHost Examples


Inside the apache config use ...

Alias /project /var/projects/project1

or something like that .. can't remember off the top of my head.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.