I've recently upgraded to Big Sur (11.6.1) and after running:
php -v
It returns:
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
So I decided to install PHP 7.3 via Homebrew. Via these instructions: https://gist.github.com/karlhillx/791babda83495eab6fbf64f8a3270f86
Everything was working fine untill I run:
sudo apachectl configtest
Which returns:
Syntax error on line 182 of /usr/local/etc/httpd/httpd.conf: Can't locate API module structure `php_module' in file /usr/local/Cellar/php#7.3/7.3.33/lib/httpd/modules/libphp7.so: dlsym(0x7f9547f05530, php_module): symbol not found
Which is in my httpconf file:
LoadModule php_module /usr/local/Cellar/php#7.3/7.3.33/lib/httpd/modules/libphp7.so
If I run:
find /usr -name "libphp7.so"
It returns:
/usr/libexec/apache2/libphp7.so
find: /usr/sbin/authserver: Permission denied
find: /usr/local/mysql-8.0.21-macos10.15-x86_64/keyring: Permission denied
find: /usr/local/mysql-8.0.21-macos10.15-x86_64/data: Permission denied
/usr/local/Cellar/php#7.2/7.2.34_4.reinstall/lib/httpd/modules/libphp7.so
/usr/local/Cellar/php#7.3/7.3.33/lib/httpd/modules/libphp7.so
/usr/local/php5-7.2.21-20190811-210031/libphp7.so
So the module is there but why can't it see it? Help.....
I found the solution:
I removed the install then reinstalled
brew list | grep php
then
brew uninstall --force {the php version returned from above}
then
brew install php#7.3
Related
I try to install xdebug on MacOs Mojave but get this error
/private/tmp/pear/install/xdebug/xdebug.c:25:10: fatal error: 'php.h' file not found
Command Line Tools are installed.
I ran into this trying to compile xdebug on my system, I had to do the following to get it to work
0) Check that you have the file /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg on your system.
1) If not, install the command line tools (I had installed them at one point, but the files under /Library/Developer/CommandLineTools/ were missing so I must have deleted it...)
xcode-select --install
2) Reinstall the header files
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Credit to #donatJ - https://stackoverflow.com/a/52612102/649915
brew doctor
and then
brew link --overwrite php
helped me.
Headers aren't installed for Mojave.
To install the headers:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
I was having the same issue and this fixed it for me.
How can I install intl PHP extension in PHP 7.1.7, which is delivered with osx high sierra?
So I had the exact same issue. As noted by other folks commenting here, High Sierra comes with PHP 7.1 installed and this PHP version has intl compiled with it
In my case, I followed part of Neodork comment's in the following Valet+ issue:
"Install" PHP 7.1 (so it comes from brew itself, not the one installed by High Sierra)
brew install php#7.1
Upgrade it to latest version
brew upgrade php#7.1
Symlinks for references in Cellar:
brew link --overwrite --force php#7.1
Change PHP path in my bash profile
echo 'export PATH="/usr/local/opt/php#7.1/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.1/sbin:$PATH"' >> ~/.bash_profile
Reload your bash profile (you can close the terminal and open it again)
. ~/.bash_profile
Check for Intl
php -m | grep intl
Note: If you come across with warnings like:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php71-intl/intl.so'
Then you have to disable the previous intl:
mv /usr/local/etc/php/7.1/conf.d/ext-intl.ini /usr/local/etc/php/7.1/conf.d/ext-intl.ini.disabled
Hope it helps!
After the integration from brew/php to brew/core, the intl extension is included by the default installation. I also had the same problem the intl extension wasn't working. The problem I had was the command-line environment was not using the installed version of PHP but the default version from macOS system.
To enable the installed version, you need to do this:
After
brew install php#7.1
You need to link the installed PHP version by
brew link php#7.1
Then you need to OPEN A NEW TERMINAL to make it effective.
Then double check the PHP binary path,
which php
make sure it's
/usr/local/bin/php
instead of
/usr/bin/php
Then check if the intl extension is enabled,
php -m | grep intl
It works for me.
open a terminal then type:
brew search intl
you should be able to see php71-intl, then run
brew install homebrew/php/php71-intl
then restart apache
sudo apachectl restart
then type:
php -i | grep intl
you should be able to see something like this:
Additional .ini files parsed => /usr/local/etc/php/7.1/conf.d/ext-intl.ini
intl
intl.default_locale => no value => no value
intl.error_level => 0 => 0
intl.use_exceptions => 0 => 0
Enjoy!
I'm running the brew 1.6.2, on OS High Sierra. The intl extension is not available in brew packages so far.
The #Mondy solution worked fine for me. After run the
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
The packages will be available in /usr/local/php5 or /usr/local/php5-7.0.27-20180201-135220.
So in your /usr/local/etc/php/7.0/php.ini you can place the following lines to enable the intl extension:
[intl]
extension="/usr/local/php5/lib/php/extensions/no-debug-non-zts-20151012/intl.so"
In my case I prefered to create a file 'ext-intl.ini' in /usr/local/etc/php/7.0/conf.d/, just for a better organization.
try this on Mac
php -v
sudo port install php7*-intl
More information
You can find port packages by this page https://www.macports.org/ports.php?by=name&substr=intl
And you can install port through these steps: https://guide.macports.org/chunked/installing.macports.html
curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.5.4.tar.bz2
tar xf MacPorts-2.5.4.tar.bz2
cd MacPorts-2.5.4/
./configure
make
sudo make install
And change ~/.bash_profile
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
If there is error, check following steps:
check port
sudo port list
sudo port selfupdate
sudo port search --name --glob 'php*'
sudo port install php**-intl
This page has more info about port usage: https://guide.macports.org/chunked/using.html
In addition to what L. Grolleau says (run brew install php71-intl), paste the int.so path to the /php.ini at the end of the file:
extension=/usr/local/Cellar/php71-intl/7.1.11_20/intl.so
I find a solution.
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
Then I copied intl.so from the installation to my extension directory, which is defined into my php.ini.
I have managed to work this out.
First uninstall any php packages you have completely with brew, then run the brew update and brew doctor commands.
Now install with brew install php#7.1 (changed the version as needed) intl is included in the build for all php-formulae.
To confirm it is working run php -m | grep intl. You will see the intl extension is included. If not check the php.ini file and make sure the extension is being loaded.
Remove the following file with
rm /usr/local/etc/php/7.1/conf.d/ext-intl.ini
Worked for me, thanks to homebrew-core Issue
I installed php7.2 with brew and linked with that version on Mac, but cannot see even the version number 7.2 in phpinfo().
It always showed the last version(7.1) even though uninstall with brew, so the intl extension.
I found we have to modify httpd.conf file(in my case in /etc/apache2/httpd.conf), in that file you can find the
LoadModule php7_module libexec/apache2/libphp7.so
in that line you have to override with your new php72 path: in my case it was
LoadModule php7_module /usr/local/Cellar/php#7.2/7.2.31_1/lib/httpd/modules/libphp7.so
And restart apache, it works fine.
try this
brew install homebrew/php/php71-intl
I used Homebrew to install apache 2.4 and php 5.4 (also tried 5.6) (using Mac Osx Mavericks). When I try to load the php5 module I get the following error:
httpd: Syntax error on line 157 of /usr/local/apache-2.4.9/conf/httpd.conf: Cannot load /usr/local/opt/php56/libexec/apache2/libphp5.so into server: dlopen(/usr/local/opt/php56/libexec/apache2/libphp5.so, 10): Symbol not found: _unixd_config\n Referenced from: /usr/local/opt/php56/libexec/apache2/libphp5.so\n Expected in: /usr/local/apache-2.4.9/bin/httpd\n in /usr/local/opt/php56/libexec/apache2/libphp5.so
I tried re-installing php a few different ways I saw online with users having the same error, but to no avail:
brew install php55 --homebrew-apxs
brew install php56 --with-mysql --with-homebrew-apache
brew install -s php56
Anyone know how I could resolve this issue? Thanks in advance!
I was able to fix the issue by running the following:
brew install 56 --with-apache
I'm not sure if that's ideal way to fix and am still having an issue rendering the php page (which might be related to a separate issue), but hopefully this helps someone.
My operating system is:Mac OSX 10.11
I'm trying to install Phabricator on my Mac, when I execute the command of
phabricator cpopt$ ./bin/phd start
I got an error:
"ERROR: The PHP extension 'pcntl' is not installed. You must install it to run daemons on this machine."
I've search this problem on google and I got lots of solutions,but they all don't work to me,I'm almost in despair.
How can I achieve that?
Do you have brew installed (read here to install http://brew.sh/)?
Try:
brew install php
or if you need to install PHP 5.6 with brew you could do this:
brew install php#5.6
Then to include it in your PATH (if it is not automatically added), it may be necessary to run the commands in the CLI you may need to update your path, e.g. (this is the case if you were to brew install php#7.1 but was not the case when I just tested with brew install php - if you are using bash instead of zsh, change .zshrc to .bashrc.
echo 'export PATH="/usr/local/opt/php#7.1/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php#7.1/sbin:$PATH"' >> ~/.zshrc
If that doesn't work, I wonder if phabricator is calling the right version of php.
Out of curiosity, what is the output you get from this? That is what phabricator is using to determine your php version.
/usr/bin/env php -v
Also... is your php.ini updated to have the pcntl extension? Run this to see your modules and look for pcntl:
php -i | grep pcntl
Double-check the php.ini that the php-cli is running:
php -i | grep php.ini
I had to do this to install the platform.sh command line tool. This was the top hit in Google so I'm adding this information. The process I followed was as below.
In Terminal:
Add yourself to the 'wheel' user group.
sudo dscl . append /Groups/wheel GroupMembership <username>
Grant group write access to /usr/local/bin
sudo chmod -R g+w /usr/local/bin
Link libpng for brew
brew link libpng
Install pcntl for php (5.6 in my case)
brew install homebrew/php/php56-pcntl
Just in case anyone else uses MAMP, I recently updated it to the latest version. Then I was getting the error
"ERROR: The PHP extension 'pcntl' is not installed. You must install it to run daemons on this machine."
I had not restarted my terminal since I updated it. After reloading the session everything worked fine.
I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report.
I've gone into my php.ini file and added
extension=pgsql.so
But, I'm met with the following error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pg_connect() in... (blah file here)
When running phpinfo(), I see nothing about PostgreSQL, so what is my issue here?
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
Find your version of PHP: php -v.
Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
Type phpize.
Type ./configure.
Type make.
Type sudo make install.
Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
Type sudo chown -R $USER /usr/local/Cellar.
Type brew update.
Type brew install autoconf.
That should install autoconf and allow you to install the module using the instructions above.
If you use home brew, you can solve this with a command as simple as:
brew install php55-pdo-pgsql
for other php version, search with:
brew search pgsql
This worked for me with OSX 10.9.4 «Mavericks»
Install sources
Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:
tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP
cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module
I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:
cd ext/pdo_pgsql
In my case I had the following error:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. ERROR:
`phpize' failed
So I had to use this command:
brew install autoconf
Then:
phpize
After that I tried to do:
./configure
but I had the next problem:
checking for pg_config... not found configure: error: Cannot find
libpq-fe.h. Please specify correct PostgreSQL installation path
So the solution was to specify correct PostgreSQL installation path:
./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.
Then simply add
extension=pdo_pgsql.so to /etc/php.ini
Run php -m to confirm everything went to plan.
For those who installed php7/ngix/postgres with homebrew
You can install the PostgreSQL module with:
brew install php70-pdo-pgsql
After that, you have to restart the php service:
brew services restart php70
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
For php56 via brew:
brew install php56-pdo-pgsql
PostgreSQL by default is installed in a unusual place on MAC OS X:
/Library/PostgreSQL/9.3
Given the location above you can type this:
./configure --with-pgsql=/Library/PostgreSQL/9.3
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so.
Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.
For those of you having openssl error while make here is the solution
OSX uses openssl 0.98 while installer is searching for 1.0.0
refer this link for instructions
psycopg2 installation error - Library not loaded: libssl.dylib
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.
To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.