Tidak dapat mengatur virtual host di OS X


1

Saya mencoba membuat host virtual untuk pengembangan PHP, jadi saya tidak pergi ke http://localhost/new_website, tetapi untuk new_website.devdan mendapatkan situs web.

Saya telah membuat direktori di folder / Situs dan mengedit /etc/apache2/extra/httpd-vhosts.conffile dan /private/etc/hostsfile tersebut.

Konten file vhosts saya:

#
# 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>

Dan konten file host saya:

##
# 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

Dan dari apa yang saya temukan di internet, ini seharusnya untuk trik, tetapi entah bagaimana, saya tidak mendapatkan index.php dari new_websitedirektori, tetapi saya mendapatkan index.php dari Sitesdirektori. Jadi root server bisa dikatakan. Apa yang saya lakukan salah?

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.