Saya mencoba membuat host virtual untuk pengembangan PHP, jadi saya tidak pergi ke http://localhost/new_website
, tetapi untuk new_website.dev
dan mendapatkan situs web.
Saya telah membuat direktori di folder / Situs dan mengedit /etc/apache2/extra/httpd-vhosts.conf
file dan /private/etc/hosts
file 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_website
direktori, tetapi saya mendapatkan index.php dari Sites
direktori. Jadi root server bisa dikatakan. Apa yang saya lakukan salah?