PHP 7 and Apache on macOS Sierra
PHP 7.1.2 running on macOS Sierra |
I posted several talks about compiling PHP from source, but everyone was trying to convince me that a package manager like Homebrew was a more convenient way to install.
The purpose of Homebrew is simple: a package manager for macOS that will allow you to set up and install common packages easily and allows you to update frequently using simple commands.
I used a clean installation of macOS Sierra to ensure all steps could be recorded and tested. In most cases you already have done work on your Mac, so chances are you can skip a few steps in this tutorial.
APACHE AND PHP WITH HOMEBREW
I’ve made this according to the installation instructions given on GetGrav.
The installation procedures
These installation procedures will set up your macOS Sierra with PHP 7.1 and Apache 2.4.
Install Xcode command line tools (if not done yet)
Install Homebrew
Set up for installation of PHP and Apache
Unload the provisioned Apache from macOS Sierra
Install Homebrew Apache
Set up Apache for autostart at macOS Sierra (re)boot
Check to see Apache is running
You should see something similar as output
Uninstall previous versions of PHP
We assume you had PHP 7.0 installed
Install latest PHP version (PHP 7.1.2 at the time of writing)
Time to install latest PHP with the apache web server
Don’t forget to set
date.timezone
in /usr/local/etc/php/7.1/php.ini
!!!Configure Apache for PHP usage
Also make sure to set the following line in
/usr/local/etc/apache2/2.4/httpd.conf
(You might need to disable others):
Also make sure you have set the following lines correctly:
Time to restart apache
Test your setup
Create a
phpinfo.php
in /usr/local/var/www/htdocs
with the following contents:
You should see the famous PHP information page!
Next steps
Now you can set up your virtual hosts like you normally would do.
works perfectly, (y)
ReplyDeletenice post
ReplyDelete