V
V
Viktor Yanyshev2017-02-22 23:05:35
Apache HTTP Server
Viktor Yanyshev, 2017-02-22 23:05:35

Why can't Apache see hosts?

After reinstalling Sierra, I decided not to use stock Apache anymore, but to install it from homebrew. If in order:

  1. Installed homebrew
  2. brew install */php70
  3. brew install */mysql
  4. brew install */phpmyadmin
  5. brew install */httpd24

Looked where to lay the config of the new Apache, changed:
Listen 8080

User me_user
Group staff

ServerName localhost:8080

DocumentRoot "/users/me_user/projects"
<Directory "/users/me_user/projects">
......
</Directory>

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

# Virtual hosts
Include /usr/local/etc/apache2/2.4/vhosts/*.conf

Alias /phpmyadmin /usr/local/share/phpmyadmin
  <Directory /usr/local/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
      Require all granted
    </IfModule>
    <IfModule !mod_authz_core.c>
      Order allow,deny
      Allow from all
    </IfModule>
  </Directory>

Created host config and httpd -k restart:
<VirtualHost *:8080>
  ServerName test.dev
  AddDefaultCharset UTF-8
  DirectoryIndex index.php index.html
  DocumentRoot /users/me_user/projects/test
  ServerAlias www.test.dev
  
  # LOGS
  CustomLog /Users/me_user/projects/logs/test.dev/access.log combined
  ErrorLog /Users/me_user/projects/logs/test.dev/error.log
  
  <Directory /users/me_user/projects/test>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
  </Directory>
</VirtualHost>

For the test, I threw index.php to the root directory to check, well, php works, it’s already good. After that, I go to check the host, write test.dev, the root directory /users/me_user/projects/ opens and index.php is launched accordingly, and not /users/me_user/projects/test and its index.php. Okay, I added :8080 to the url and the host worked. But it does not suit me at all to add the port with my hands.
How it is possible to bring to normal habitual logic of access to the local site? i.e. I registered the address test.dev and everything is fine))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question