This article has detailed steps on doing clean install of PHP 7.2 (latest PHP version as of August 2018). If you already have PHP installed via homebrew, then it requires you to first remove those PHP installations and then do the fresh PHP install. Reason of doing so, is to avoid conflicts that arise because of Homebrew March 2018 updates. Further details within blog!
Recently, I wanted to include a new module (visualception) in my test automation project that is built on top of codeception. In order to successfully make it work, there was a requirement to have php-imagick
extension already installed in your system.
Initial search showed that, in past you could have installed php-imagick
extension using command like brew install php71-imagick
, but this does not work any more of Homebrew updates. With the migration to Homebrew-core
, the php formula has stopped taking over the role of PECL. So now for installation of php extensions (like imagick or x-debug) you have to use PECL.
- I installed php 7.2, even though it's not the latest, simply because my hosting site and wordpress uses php 7.2 and I want to integrate my php application with my wordpress site. $ brew install php@7.2 Once php is installed, go back to your httpd.conf file and add the following line.
- I found good gist how to install PHP 5.4 and 5.3 side by side on Max OSX via MacPorts. I suppose, it is applicable for PHP 5.5 too. (Re)installing PHP on Mac OS X.
- Mac users have a choice of either a binary or a source installation. In fact, your OS X probably came with Apache and PHP preinstalled. This is likely to be quite an old build, and it probably lacks many of the less common extensions. However, if all you want is a quick Apache + PHP + MySQL.
Linux and macOS Installation Tutorial for the Microsoft Drivers for PHP for SQL Server.; 11 minutes to read +3; In this article. The following instructions assume a clean environment and show how to install PHP 7.x, the Microsoft ODBC driver, the Apache web server, and the Microsoft Drivers for PHP for SQL Server on Ubuntu 16.04, 18.04, and 20.04, RedHat 7 and 8, Debian 8, 9, and 10.
Due to older php installations, I was getting lot of issues while trying to install php-imagick extension. Ultimately, I was able to resolve all the problems by installing PHP from scratch. In below, I have listed all the steps for fresh PHP installation.
1. Prerequisite Steps For First Time PHP-Installation
1.1 First install xcode-command-line tools by running below command in terminal. If any popup message appears during installation, that needs to be confirmed. For further details on xcode tools, you may check this link.
1.2 As we are going to do all PHP related installations through macOS package manager Homebrew. So next we need to set it up by running below command:
Installation process will will show several prompts and may also ask for mac password. This may take a few minutes. Once it is done, you can verify the installation was successful by running below commands:
2. Remove EXISTING PHP (homeBREW) INSTALLATIONS
2.1 Removing all PHP-Homebrew related installations
First run below brew commands to make sure brew is updated and has no configuration issues.
If brew doctor or cleanup throws any errors then fix them as per instructions returned by brew-doctor or ask google
🙂
Now onto removing existing PHP-related installations (that were done by homebrew).
After above, again run brew cleanup
and brew doctor
to ensure everything working fine.
3. FINALLY… sTART WITH PHP INSTALLATION !
3.1 Run PHP Installation commands
Install Php For Mac Shortcut
Once done with above, now verify thatyou are running the correct homebrew–PHP by running type php
command. If it returns /usr/local/...anything.../php
then it means you are running homebrew-PHP. If it returns something like /usr/bin/php
then it means you are running apple-supplied-PHP. In that case you need to fix paths, as we want to use homebrew-PHP! Finally run brew doctor
to make sure everything is fine and no configuration errors are thrown.
3.2 Switching between PHP versions
If you have multiple php versions and want to switch between them, then you can do so by using brew link
and brew unlink
commands.
3.3 Install PHP extensions
As mentioned in start, php extensions such as php-imagick or php-xdebug which were previously installed by commands like (brew install php53-imagick
) now should be installed by PECL (for details on PECL check this link). Below are example commands for installation of xdebug and imagick extension.
Now you may run php -v
to verify php version and php -m
to check enabled extensions.
- PHP 7 Tutorial
- PHP 7 Useful Resources
- Selected Reading
Mac users have a choice of either a binary or a source installation. In fact, your OS X probably came with Apache and PHP preinstalled. This is likely to be quite an old build, and it probably lacks many of the less common extensions.
Install Php For Mac Catalina
However, if all you want is a quick Apache + PHP + MySQL/PostgreSQL setup on your laptop, this is certainly the easiest way to fly. All you need to do is edit your Apache configuration file and turn on the Web server.
Just follow the steps given below −
Step 1
Open the Apache config file in a text editor as root.
Step 2
Edit the file. Uncomment the following lines −
Step 3
You may also want to uncomment the <Directory /home/*/Sites> block or otherwise tell Apache which directory to serve. Restart the Web server.
Php On Mac
Step 4
Install Php For Mac
Open a text editor. Type: <?php phpinfo(); ?>. Save this file in your Web server's document root as info.php. Start any Web browser and browse the file. You must always use an HTTP request (http://www.testdomain.com/info.php or http://localhost/info.php or http://127.0.0.1/info.php) rather than a filename (/home/httpd/info.php) for the file to be parsed correctly
You will see a long table of information about your new PHP installation message Congratulations!