Frontend, wildcard on localhost

Установка dnsmasq

About the App

Install the App

  1. Press Command+Space and type Terminal and press enter/return key.
  2. Run in Terminal app:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
    and press enter/return key. 
    If the screen prompts you to enter a password, please enter your Mac’s user password to continue. When you type the password, it won’t be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
  3. Run:
    brew install dnsmasq

Done! You can now use dnsmasq.

Ичточник: https://macappstore.org/dnsmasq/

 

Настройка dnsmasq

# Create the etc dir if needed
mkdir -p /usr/local/etc

# Create a simple configuration
# This forces the .dev domain to respond with 127.0.0.1
# You can find more information in the default config file:
#   /usr/local/opt/dnsmasq/dnsmasq.conf.example
echo "address=/.dev/127.0.0.1" > /usr/local/etc/dnsmasq.conf

# Install the daemon startup file
sudo cp -fv /usr/local/opt/dnsmasq/*.plist \
  /Library/LaunchDaemons

# Start the daemon
sudo launchctl load \
  /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Configure Mac OS X:

All we need to do is tell the resolver to use Dnsmasq for .dev domains:

# man 5 resolver
sudo mkdir -p /etc/resolver
sudo sh -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'

You can now use any .dev domain and it will always resolve to 127.0.0.1:

ping google.com   # this still works
# PING google.com (74.125.239.38): 56 data bytes

ping foo.dev      # you can use any domain
# PING foo.dev (127.0.0.1): 56 data bytes

ping bar.baz.dev  # or subdomain
# PING foo.dev (127.0.0.1): 56 data bytes

Ичточник: https://asciithoughts.com/posts/2014/02/23/setting-up-a-wildcard-dns-domain-on-mac-os-x/

 

Переезд с .dev to .test

I have the .dev tld routed to my /Users/trysmudford/Sites directory so anything.dev points to /Users/trysmudford/Sites/anything — it’s very handy. So I need to swap to a new TLD and .test seems to do the trick. Here’s how I did it (OSX 10.12, native apache setup, dnsmasq provided by homebrew).

  1. Open Finder
  2. Click ‘Go’ in the top menu bar
  3. Click ‘Go to folder’
  4. Type in: /usr/local/etc/
  5. Hit ‘Go’
  6. Open dnsmasq.conf in your favourite text editor
  7. Copy the line: address=/.dev/127.0.0.1
  8. Change new line to: address=/.test/127.0.0.1
  9. Save this file
  10. Go to your terminal and type the following to restart dnsmasq (type in your password when promted):
    1. sudo launchctl stop homebrew.mxcl.dnsmasq
    2. sudo launchctl start homebrew.mxcl.dnsmasq
  11. Back to Finder
  12. ‘Go’, then ‘Go to folder’
    1. Type in: /etc/resolver/
  13. Copy the file named: dev
  14. Rename the new file to test


Ичточник: https://www.tomango.co.uk/thinks/moving-dev-test-os-x-dnsmasq/

 

Запуск Apache XAMPP

Если проблема с запуском апач, т.к. встроенный (в мак) апач перехватил инициативу.
Отключить встроенный Apache, чтобы освободить порт 80 для XAMPP:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Ичточник: https://qaru.site/questions/179045/xampp-apache-webserver-localhost-not-working-on-mac-os

Кратко:

файл hosts здесь:

/private/etc/

 

файл dnsmasq.conf (настройка dnsmasq) здесь: 

/usr/local/etc/

 

файл httpd-vhosts.conf (настройка XAMPP vhosts) здесь:

/Applications/XAMPP/xamppfiles/etc/extra/

 

Рестарт dnsmasq:

sudo launchctl stop homebrew.mxcl.dnsmasq
sudo launchctl start homebrew.mxcl.dnsmasq