'How to change PHP-FPM port on Mac

I'm not using php or php-fpm, but it's hogging port 9000. I need port 9000. I'd like to change the port. I changed it in /etc/php-fpm.conf and /etc/php-fpm.d/www.conf. listen = 127.0.0.1:9005. Still listening on 9000. If I kill it it just loads back up instantly with a different PID.

I'm ok uninstalling it too, but I can't figure out how to do that either. Any ideas?



Solution 1:[1]

which php version do you have and did you install it via homebrew?

I was having this problem today and solved it by changing the configuration of the listening port:

in the config file in: /usr/local/etc/php/7.2/php-fpm.d/www.conf

change the line listen = 127.0.0.1:9000 to whatever port you want

If you don't have the config file it might have been a brew problem when copying files. You have to do something like this before attempting to change www.conf:

cd $(brew --prefix [email protected]) cp -R .bottle/* /usr/local/

All the credits go to this blogpost: https://www.dionysopoulos.me/custom-apache-and-php-server-on-macos-the-definitive-2019-edition/

Solution 2:[2]

Update for Apple Silicon Chips

Although the current answer is correct for Mac's on Intel chips it's not correct for changing the PHP-FPM Port on Mac with Apple Silicon chips.

If following the blogpost https://www.dionysopoulos.me/custom-apache-and-php-server-on-macos-the-definitive-2019-edition/

Do Not copy the brew files to /usr/local/ as this is for intel chips. Instead, after installing php with brew, the file should already exist in:

/opt/homebrew/etc/php/8.0/php-fpm.d/www.conf

Or for php 5.6: /opt/homebrew/etc/php/5.6/php-fpm.conf

Where you can then change listen = 127.0.0.1:9000 to the port you like.

Remember to then restart apache.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Felipe Ignacio Noriega Alcaraz
Solution 2 Jonathan Clark