How to install extensions? PHP extensions have been removed and now should be installed from PECL: pecl install xdebug Tags: command line, homebrew, PHP, terminal. Categories: Mac. Updated: November 08, 2018. Share on Twitter Facebook Google+ LinkedIn Previous Next. Leave a comment. You may also enjoy. How to Write to NTFS Drives in macOS Mojave. Troubleshooting PHP on Windows; Installation on old Windows systems; Installation on Cloud Computing platforms. Azure App Services; Amazon EC2; FastCGI Process.
« back — written by Brent on November 28, 2019# Upgrading with Homebrew
Start by making sure brew is up-to-date:
Next, upgrade PHP:
Install Php Mac Terminal
Check the current version by running php -v
:
Restart Nginx or Apache:
And make sure that your local web server also uses PHP 7.4 by visiting this script:
The version should show 7.4.x
.
Note: if you're using Laravel Valet, please keep on reading,you need some extra steps in order for the web server to properly work.
# Valet
If you're using Laravel Valet, you should do the following steps to upgrade it:
Now run valet install
:
# Extensions
Homebrew doesn't support the installation of PHP extensions anymore, you should use pecl instead.I personally use Imagick, Redis and Xdebug.
They can be installed like so:
You can run pecl list
to see which extensions are installed:
You can search for other extensions using pecl search
:
Make sure to restart your web server after installing new packages:
If you're using Laravel Valet, you should restart it as well.
Make sure all extensions are correctly installed and loaded by checking both your PHP webserver and CLI installs:
If extensions aren't properly loaded, there are two easy fixes.
First, make sure the extensions are added in the correct ini file. You can run php --ini
to know which file is loaded:
Now check the ini file:
Note that if you're testing installed extensions via the CLI, you don't need to restart nginx, apache or Valet.
The second thing you can do, if you're updating from an older PHP version which also used pecl to install extension; is to reinstall every extension individually.
# Last step
Finally you should test and upgrade your projects for PHP 7.4 compatibility.
Sommaire
Cette section contient les notes et conseils pour installer PHP sur un système macOS. PHP est inclus avec les Macs, et pour compiler, la procédure est identique à l'installation sous Unix.
chris at spookee dot dePhp Install For Mac Catalina
¶There is a 'One Line Installation' tool to use PHP 5.6/5.5/5.4/5.3 for
OS X 10.6/10.7/10.8/10.9/10.10 with the build-in Apache with lots of extensions included:
http://php-osx.liip.ch
I hope posting this link is allowed, because it helped me a lot to get the latest PHP-Version running...
Included extensions:
bcmath bz2 calendar Core ctype curl date dom dtrace ereg exif fileinfo filter ftp gd gettext hash iconv imap intl json ldap libxml mbstring mcrypt memcache memcached mhash mongo mssql mysql mysqli mysqlnd OAuth odbc openssl pcntl pcre PDO pdo_dblib pdo_mysql pdo_pgsql pdo_sqlite pgsql Phar posix Reflection session shmop SimpleXML soap sockets solr SPL SQLite sqlite3 standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xdebug xhprof xml xmlreader xmlrpc xmlwriter xsl zip zlib Xdebug
available but disabled by default: apc, xslcache, twig, uploadprogress
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.
https://gist.github.com/raphaelstolt/2721719
Php Install For Mac Virtualbox
For those using Homebrew, Justin Hileman maintains a blog post entitled '(Re)installing PHP on Mac OS X', which documents how to build PHP and extensions: http://justinhileman.info/article/reinstalling-php-on-mac-os-x/
Php Install For Mac High Sierra
¶Just a note. The darwinports software is now macports and you can get it at: http://www.macports.org/
If you use macports, be sure to change any refernces you may have in your calling scripts to macports as the file macports now gets installed.
My httpd.conf had some of the lines, but not all of them -- mine was missing the LoadModule and AddModule lines for php. I'm not sure why -- I don't delete any of those; I just comment them out if I'm not using them. Plus, the note above put a space in 'LoadModule'; it has no space. I didn't know about the 'apachectl graceful' trick, though -- since 'httpd -k restart' stopped working (probably around 10.2), I had just been doing it manually -- find the process, kill it, and hit httpd again -- thanks for the tip!
So for those who are missing any of the lines, here are the full lines.
In the section with all the other LoadModules:
LoadModule php4_module libexec/httpd/libphp4.so</div>
Directly below that section should be the AddModules; you need:
AddModule mod_php4.c
And then the AddType lines should be right after the language priorities (so after the AddCharset lines and after the LanguagePriority bit):
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Then restart apache/httpd as described above, and hopefully you should be good.
BTW, the actual module should be at:
/usr/libexec/httpd/libphp4.so
So if things fail, you can check to see if that's there.
Thanks to others who posted here; it definitely helped and got me on the right track. I just had to find the module manually to write my own LoadModule line.
To build on MacOS X 10.3.5 set the environment variable CFLAGS in the following way (depending on your shell)
setenv CFLAGS '-DBIND_8_COMPAT=1 -DEAPI -O3'
export CFLAGS='-DBIND_8_COMPAT=1 -DEAPI -O3'
Then launch configure with the options:
./configure --prefix=/usr --mandir=/usr/share/man ....
The -DBIND_8_COMPAT=1 gets you over a problem in the DNS files because MacOS X has definitions for Bind9 and PHP expects Bind8 definitions. -DEAPI is needed if you build it for Apache 1.3.31. -O3 enables the gcc optimizer.
You can also add one of the following lines to your CFLAGS depending on the CPU you use to further improve speed:
-mcpu=G3 -mtune=G3
-mcpu=G4 -mtune=G4
-mcpu=G5 -mtune=G5
- Installation et configuration