0

I'm trying to run a Drupal 7 multi-site install on my Mac (10.12.6).

My directory setup:

~/Sites/index.html
~/Sites/drupal/docroot/sites/site1
~/Sites/drupal/docroot/sites/site2

My /etc/hosts:

127.0.0.1    site1.local
127.0.0.1    site2.local

If I go to http://localhost, I see my index.html file, no problem. If I visit http://site1.local or http://site2.local, I get 502 Bad Gateway.

in /usr/local/etc/httpd/httpd.conf:

  • I'm listening on Port 80
  • DocumentRoot and <Directory are set to /Users/me/Sites/
  • AllowOverride is set to All
  • ServerName is set to localhost, user & group are set to me, staff

And the following are uncommented:

LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule vhost_alias_module lib/httpd/modules/mod_vhost_alias.so
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf

My vhosts file looks like:

<VirtualHost *:80>
    DocumentRoot /Users/me/Sites
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /Users/me/Sites/drupal/docroot
    ServerName site1.local
    ErrorLog /var/log/apache2/site1cms-error.log
  Options ExecCGI FollowSymLinks
  SetEnv APPLICATION_ENVIRONMENT local
  SetEnv AH_SITE_ENVIRONMENT local
  SetEnv AH_SITE_GROUP local
  <Directory /Users/me/Sites/drupal/docroot>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
  </Directory>
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /Users/me/Sites/drupal/docroot
    ServerName site2.local
    ErrorLog /var/log/apache2/site2cms-error.log
  Options ExecCGI FollowSymLinks
  SetEnv APPLICATION_ENVIRONMENT local
  SetEnv AH_SITE_ENVIRONMENT local
  SetEnv AH_SITE_GROUP local
  <Directory /Users/me/Sites/drupal/docroot>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
  </Directory>
</VirtualHost>

If I curl site1.local from terminal the site loads fine, but loading from Chrome or Safari I get the 502.

I tried sudo lsof -t -i tcp:80 -s tcp:listen | sudo xargs kill in case some other apps were listening on port 80 but it didn't help.

I've looked in the Apache logs and the custom logs I created above, nothing is recorded.

Running MySql 5.7, PHP 5.6, Apache 2.4. Tried restarting all services.

Any ideas?

OrdinaryHuman
  • 139
  • 2
  • 9
  • I don't know drupal, but why site1.local doesn't has ~/Sites/drupal/docroot/sites/site1 as document root? – c4f4t0r Aug 18 '18 at 00:59
  • No, docroot handles the routing for both sites. Confirmed because a coworker has it this way and it works on his machine. And I’ve tried it the other way and it doesn’t. – OrdinaryHuman Aug 18 '18 at 01:11
  • Intent of installing all this staff on your mac, try to use vagrant. – c4f4t0r Aug 18 '18 at 01:14
  • Spent several days doing vagrant, only to fail. The db is too large, 50 GB. I was able to resize the box image to accommodate it but all operations inside were glacial. Everyone insisted I give up on vagrant. – OrdinaryHuman Aug 18 '18 at 01:21
  • Are you running chrome or safari on the server itself or on another system? – Gerard H. Pille Aug 18 '18 at 01:35
  • Same system. One Mac. – OrdinaryHuman Aug 18 '18 at 01:36
  • /etc/hosts: one line or two? I don't see localhost in there. – Gerard H. Pille Aug 18 '18 at 01:41
  • I've tried both one line and two. It works either way. I can ping both and get responses, so it's not `/etc/hosts`. Again I can also curl from terminal and get the correct page back, not 502 – OrdinaryHuman Aug 18 '18 at 01:51
  • So, let's have a look at the browsers then. Clear their cache, check their network settings (proxy?). – Gerard H. Pille Aug 18 '18 at 08:20
  • Replace index.php (move it aside) with a simple one that just runs phpinfo(). What do you find? If you're getting a 502, then the application is just being very slow and has timed out. Note that httpd access logs are generated after the request has been served. You don't seem to have any CustomLog set (from what you've posted). Also useful: you can put a LogLevel DEBUG inside the scope (VirtualHost, Directory, Location etc). – Cameron Kerr Aug 18 '18 at 11:45
  • @GerardH.Pille I think you're onto something. I'd cleared my caches and rebooted multiple times to no effect, but I just opened my Mac from a sleep state and the sites are working again...no changes made. Maybe something timed out? Why would browsers say 502 but it curls fine from the terminal on the same machine? – OrdinaryHuman Aug 18 '18 at 14:04
  • For example: a browser can put www in front of the domain you request. Who knows with Google what a browser may be up to? – Gerard H. Pille Aug 18 '18 at 23:46

1 Answers1

0

The problem was I was on a (work-mandated) Cisco VPN. Disconnected from said VPN and 502 error disappears.

An edge-case but FYI for anyone else who encounters this problem in the future.

OrdinaryHuman
  • 139
  • 2
  • 9