Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to create a virtual host for PHP developement, so I don't go to http://localhost/new_website, but to new_website.dev and get the website.

I've created the directory in the /Sites folder and edited the /etc/apache2/extra/httpd-vhosts.conf file and the /private/etc/hosts file.

The content of my vhosts file:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites"
    ServerName localhost
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "/Users/Rob/Sites/new_website"
    ServerName new_website.dev
</VirtualHost>

And the content of my hosts file:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

127.0.0.1 new_website.dev

And from what I found on the internet, this should to the trick, but somehow, I don't get the index.php from the new_website directory, but I get the index.php from the Sites directory. So the root of the server so to say. What am I doing wrong?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.