PHP Cheat Sheet
The only paths that matter (Homebrew PHP 8.5 + Apache)
PHP binary
- /opt/homebrew/bin/php
PHP 8.5 config folder
- /opt/homebrew/etc/php/8.5/
Extra scanned INI files
- /opt/homebrew/etc/php/8.5/conf.d/
PHP-FPM main config
- /opt/homebrew/etc/php/8.5/php-fpm.conf
PHP-FPM pool configs
-
/opt/homebrew/etc/php/8.5/php-fpm.d/
- yours: /opt/homebrew/etc/php/8.5/php-fpm.d/sandbox.conf
Apache vhost file (your php sandbox site)
- /private/etc/apache2/extra/php-sandbox.local.conf
Apache main config
- /etc/apache2/httpd.conf
Apache logs (your sandbox vhost)
- /private/var/log/apache2/php-sandbox-error_log
- /private/var/log/apache2/php-sandbox-access_log
Your docroot
- /Users/shawneee/PHP_Sandbox/public
The only commands you need next time
A) Verify PHP and version
php -v
php --ini
B) Start / stop / restart PHP-FPM (this is the big one)
brew services list | grep php
brew services restart php@8.5
C) Confirm PHP-FPM is listening on your port (9001)
lsof -nP -iTCP:9001 -sTCP:LISTEN
D) Restart Apache + verify config
sudo apachectl -t
sudo apachectl restart
apachectl -S | sed -n '1,120p'
E) If something breaks: check the 2 logs
tail -n 80 /private/var/log/apache2/php-sandbox-error_log
tail -n 80 /opt/homebrew/var/log/php-fpm.log 2>/dev/null || true
The two config lines that “make it work”
1) Apache → PHP-FPM handoff (in
php-sandbox.local.conf
)
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
2) PHP-FPM pool is listening (in
sandbox.conf
)
listen = 127.0.0.1:9001
If those two agree on the same host/port, you’re golden.
Your “don’t screw me later” rule
If you upgrade PHP again (8.5 → 8.6 someday), the paths change from /opt/homebrew/etc/php/8.5/… to /opt/homebrew/etc/php/8.6/….
So the fastest way to “re-find everything” is always:
php --ini
brew services list | grep php
That tells you the active config paths and which service is running.
If you want, I can compress this into a 10-line ~/bin/php-sandbox-status script you can run anytime (no magic, just prints status + the key paths).
Need to restart php on restart?
Nope! Because you used the
brew services start command, PHP will start automatically every time you log in or restart your Mac. Homebrew Services creates a background agent (that .plist file we fixed the permissions for) that handles this for you.
How to check if it’s running:
If you ever feel like it’s acting up after a reboot, just run:
bash
brew services list
Use code with caution.
You should see php@8.5 listed as started.
When you WOULD need to run a command:
You only need to manually restart the service if you:
-
Edit your
php.ini: Changes to your config file won’t take effect until you restart.bash
brew services restart php@8.5Use code with caution.
-
Manually stop it: If you use
brew services stop php@8.5, it won’t start on the next reboot until you “start” it again.
Quick Tip for Next Time
If you decide to upgrade to PHP 8.6 later, you’ll need to stop the 8.5 service and start the 8.6 one. They can’t both use the same port (usually 9000) at the same time!
Do you want to know where your php.ini file is located so you can tweak your memory or upload limits, or are you ready to start coding?