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?

  • 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 0: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 1:11
  • Intent of installing all this staff on your mac, try to use vagrant. – c4f4t0r Aug 18 '18 at 1: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 1:21
  • Are you running chrome or safari on the server itself or on another system? – Gerard H. Pille Aug 18 '18 at 1:35
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.