On a Mac, if you’ve installed PHP locally, the method to restart it depends on how you installed and are running PHP. Here are some general instructions based on common setups:
- Using macOS’s Built-in PHP with Apache: If you’re using the built-in version of PHP that comes with macOS along with Apache, you’ll need to restart Apache:
sudo apachectl restart
- Using Homebrew: If you installed PHP via Homebrew, it’s likely you’re using PHP-FPM. To restart PHP-FPM using Homebrew:
brew services restart php
If you have a specific version of PHP installed, the service might be named like
[email protected](for PHP 7.4 as an example). You can list all the services you have to see the exact name:
brew services list
Then restart the specific version:
brew services restart [email protected]
- Using MAMP: If you’re using MAMP, you can restart the servers through the MAMP GUI:
- Open the MAMP application.
- Click “Stop Servers” and then “Start Servers.”
Alternatively, you can use the terminal:
And to stop:
- Other Solutions: If you’re using another solution like XAMPP or a different local development environment, you’d need to consult its documentation or use its interface to restart PHP.
Remember, whenever you make changes to the PHP configuration, you must restart the PHP process for those changes to take effect.