如何更改brew PHP目录

I've been trying to set up a web application for over 10 hours now

The most difficult part in this was setting up Memcached

I got it working with apache using php found here:

/Applications/XAMPP/xamppfiles/bin/php

but then I found out the routing was broken and needed nginx so I managed to somehow configure the nginx.conf but it is not letting me install Memcached now.

      location ~ \.php$ {
        root           html;
        include        fastcgi.conf;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  SCRIPT_FILENAME  /Applications/XAMPP/htdocs/rc$fastcgi_script_name;
        #include        fastcgi_params;
    }

This is my nginx.conf and the php version that is ran when opening this page localhost is the one that was installed using brew. This php version runs when I use sudo brew services start php71 but this php version doesn't let me install memcached, I have added the memcached.so to the extensions folder found in phpinfo() and added the extension=memcached.so line in php.ini

There are 2 ways to "fix" this issue: one is somehow getting memcached to work on php71 with brew OR somehow making brew use the other php found in XAMPP