R
R
romamartynov2014-06-02 17:30:19
Apache HTTP Server
romamartynov, 2014-06-02 17:30:19

How to set up multiple Name-Based Sites in Apache on Mac?

Good evening. I'm new to mac and setting up servers, so I need help from knowledgeable people (sorry if the question seems stupid and your answer is obvious).
I'm setting up Apache for PHP on Mac OS X Mavericks according to the manual , I can't set up several name-based sites.
Contents of /etc/apache2/extra/httpd-vhosts.conf:

NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /Users/tortik/Sites/firstsite.dev
   ServerName firstsite.dev
   ServerAlias firstsite.dev
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot /Users/tortik/Sites/secondsite.dev
   ServerName secondsite.dev
   ServerAlias secondsite.dev
</VirtualHost>

The Include /private/etc/apache2/extra/httpd-vhosts.conf line in the /etc/apache2/httpd.conf file is uncommented. Folders with project files are located in /Users/tortik/Sites/ . I did sudo chmod 755 for the entire folder
. In addition, I open localhost:80 in the browser, and only one folder is displayed in the file list, out of two created in /Users/tortik/Sites/ . I rebooted apache and the computer, the second folder does not appear, for the life of me.
How to be? What to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2014-06-03
@romamartynov

It is written in your config that the first host should be given by the domain name firstsite.dev , and the second by secondsite.dev . Nothing is said about the localhost domain name , which means that it will return the host that is considered default by apache .
Write these domain names in your hosts file :
so that they resolve to your local loop where apache listens.
And try to already access sites by these domain names.
Also try using apachectl -S(if the Mac has one) to see which virtual hosts apache sees and which one is set as default.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question