2

I've always been using Apache with MAMP successfully, and now I need to tinker around setting up multi-stores with subdirectories in an Nginx environment.

I'm following pretty much the vanilla configurations using "TCP connection upstream fastcgi_backend". I actually don't understand what this means. Magento provides a snippet of configs like this.

upstream fastcgi_backend {
    server  127.0.0.1:9000;
}
server {
    listen 80;
    server_name mage.dev;
    set $MAGE_ROOT /var/www/magento2;
    include /path/to/magento2/nginx.conf;
}

/path/to/magento2/nginx.conf has:

location ~ (index|get|static|report|404|503)\.php$ {
    fastcgi_pass   fastcgi_backend;
}

However, when I try to access mage.dev, I get a 502 bad gateway response with the following error.

*7 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream

I'm reading that I need to "start php-fpm", but what does that mean? I have Nginx and MySQL started already. What else do I need to configure? Do I need to install php-fpm installed on my system separately?

1

Php-fpm is a separate service....when working with Apache the 'traditional' convention was to use mod_php, which would basically inject Php into the Apache process threads....so with that setup, you only needed to start/restart/stop Apache and everything would be good....when working with Php-fpm, the webserver handles the incoming request on port 80/443 (unless you have things in front of that...load balancer, Varnish, etc) ... but the webserver passes off this request to Php-fpm ... without Php-fpm installed your webserver, nginx in this case, won't have anything to pass the request to.

You'll need to configure Php-fpm to listen on either the socket or port...you can pull some of the configuration information from here: Digital Ocean LEMP

In regards to MAMP, I have no clue on how MAMP structures their setup.

Hope that helps.

3
  • MAMP comes with a socket that I can use (just found it), so I just ended up configuring server unix:.../somefile.sock. Does this mean MAMP contains php-fpm? If I want to use server 127.0.0.1:9000, do I still need php-fpm? That guide specifically says to replace server 127.0.0.1:9000 with the php-fpm socket. May 30 '17 at 21:25
  • so if MAMP comes with a socket, that's cool and would be indicative that Php-fpm is available..but you'll still want to look around your MAMP installation to verify that there's php-fpm specific configuration files. For instance, your question about using port 9000 ... that's both a Nginx and Php-fpm configuration change..as you have to tell Php-fpm to use either a socket or port for listing to incoming connections..and then you have to tell Nginx to pass off requests to either a socket/port (the same that Php-fpm is configured to listen on). I would think this means MAMP has Php-fpm.
    – ryanF
    May 31 '17 at 23:17
  • Also, you dont' have to use the port 9000 approach if you don't want to. So if MAMP isn't configured to run Php-fpm on port 9000 by default, and you'd like to just use the socket file, you can do that too.
    – ryanF
    May 31 '17 at 23:23
1

This seems to be an old topic but I stumble over it quite often.

In my case, first I made sure the ports are properly setup : enter image description here

Then make sure PHP mode is switched to CGI mode: enter image description here

Add your domain/host and make sure it is using the nginx web server in general tab, also for additional magento configurations you could use the nginx tab : enter image description here

At this point you should be able to open your local domain in the browser and run a test. The easiest way is to have the phpinfo() function in a php file.

enter image description here

As you can see from screenshoot the php is using the CGI module.

At this point the MAMP configuration to use NginX and PHP CGI (FPM) is done further it's the Magento bits that need to be added.

1
  • it's a good answer, but i'm not sure this enables fastcgi-fpm or this is regular fastcgi which are different Oct 13 '19 at 7:16

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.