2 versions of PHP installed Mac OS X causing xdebug fail - php

Mac OS X 10.8.5. I am trying to get Netbeans running using xdebug. To date I have tried XAMPP and MAMP without success. Apparently there is a native PHP on the Mac that I can't figure out how to remove:
sh-3.2# which php
/usr/bin/php
sh-3.2# php -v
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
However, the PHP in my MAMP installation shows:
sh-3.2# pwd
/Applications/MAMP/bin/php/php5.5.3/bin
sh-3.2# ./php -v
PHP 5.5.3 (cli) (built: Sep 18 2013 14:31:13)
I followed the instructions on this page:
https://netbeans.org/kb/docs/php/configure-php-environment-mac-os.html
but xdebug does not show up in the list of extensions on the phpinfo page. I downloaded the latest xdebug by the way (2.2.3). I've also tried the tailored instructions here: http://xdebug.org/wizard.php with no luck.
I'm certain it's because if the mismatched php's. How do I remove the native PHP to get this working?
Thanks!
Roberto

Related

Make MacPorts PHP 7.3 run on OSX Mojave

I am struggling with linking the newly installed PHP version on macOS Mojave (10.14.6)
I've installed PHP 7.3 via MacPorts (I need that exact version right now, I might update it later). Installation went alright, no errors.
When I run php -v it gives me
PHP 7.1.33 (cli) (built: Jan 26 2020 22:52:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
which, I suppose, is the version shipped with the OS.
My .bash_profile looks like this
PATH=/usr/bin:/bin:/sbin:/opt/bin
PATH=/usr/local/sbin:"$PATH"
PATH=/usr/local/bin:/usr/sbin:"$PATH"
PATH=/opt/local/bin:/opt/local/sbin:"$PATH"
export PATH
export PATH=${PATH}:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
When I run php73 -v it logs
PHP 7.3.33 (cli) (built: Feb 16 2023 20:14:16) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
MacPorts has installed the PHP 7.3 into /opt/local/bin.
So obviously, the php version in use by the OS doesn't know about PHP 7.3
Oh, and using homebrew is not really an option. I've just lost hours trying it to install php 8.2 and it failed with one lib or another, constantly claiming that my XCode command line tools are outdated (duh! – and I am not upgrading those as it would require updating the OS to the latest version which would in turn strain my MBP even further).
Any help is greatly appreciated.

IonCube not loaded with PHP

I am following the instructions here to install the Filerun app on my Nginx server, running on Ubuntu / Raspberry Pi 4.
I downloaded the aarch64 version of IonCube and created a file /etc/php/7.4/fpm/conf.d/00-ioncube.ini with contents
zend_extension = /usr/lib/php/ioncube/ioncube_loader_lin_7.4.so
I verified that the referenced so file exists.
I then ran sudo systemctl restart php7.4-fpm and it shows that the service is running.
But when I do php -v I don't see IonCube mentioned:
$ php --version
PHP 7.4.33 (cli) (built: Nov 8 2022 11:40:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
And when I visit the actual site I get an error saying:
Site error: the ionCube PHP Loader needs to be installed.
I had the wrong version of IonCube. You can run php -i | head -5 to see the architecture:
phpinfo()
PHP Version => 7.4.33
System => Linux raspberrypi 5.15.76-v7l+ #1597 SMP Fri Nov 4 12:14:58 GMT 2022 armv7l
Build Date => Nov 8 2022 11:40:3
In my case it's armv7l (I was wrong to think it was aarch64).
Downloading the correct version from here solved the problem https://www.ioncube.com/loaders.php

Error to use terminal commands on PHP with Mac OS MAMP

I'm using MAMP 6.5 - Build 33813 (Macbook Air M1 2020) to make some Apache hosts.
All everything is ok, except one thing. I can't use terminal commands on my PHP code (exec, copy, and others).
I uninstalled my Brew PHP and using only MAMP PHP 7.2 and 8.0 (CGI).
I receive no errors or logs, just doesn't work. This is my terminal's response when I run php -v:
PHP 7.2.34 (cli) (built: Aug 5 2021 15:20:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Image - PHP MAMP Config

Downgrade from default PHP 7.1 to PHP 7 on macOS High Sierra

I have a fresh installation of macOS High Sierra which comes with PHP 7.1.16 (Build date: Mar 31 2018 02:53:20) installed. I would like to downgrade this to PHP 7.0.27.
PHP 7.1.16 wasn't installed with homebrew, so I assume it's not as easy as removing it and installing PHP 7 with brew.
What is the best and safest way to do this?
There's many resources to upgrade from PHP 7 -> 7.1 or 7 -> 7.2, but nothing to go the other way on macOS.
PHP 7.1.16 (cli) (built: Mar 31 2018 02:59:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
The best solution as far for my purposes was the shell tool "update-alternatives".
With that you should be able to switch between diffrent php versions dependently on your project.
So for example to switch to anohher php version set:
update-alternatives --set php=path to your php

Apache does not compile php

I just installed a fresh ubuntu system from here (mini.iso)
I choosed no extras at all during the installation process.
These are all the commands which I have executed this far:
(Ignore 4 - 8)
Now I wrote a simple PHP test script (/var/www/html/index.php)
<?php
echo "Hello World";
?>
However, after calling this page from another computer, I literally get the output from the file, instead of the compiled php.
Output:
<?php
echo "Hello World";
?>
I have already restarted apache2, no change.
Apache version:
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 15 2016 15:32:47
PHP version:
PHP 7.0.16-4+deb.sury.org~trusty+1 (cli) (built: Mar 2 2017 13:50:00) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.16-4+deb.sury.org~trusty+1, Copyright (c) 1999-2017, by Zend Technologies
Linux version:
Linux linux 3.13.0-110-generic #157-Ubuntu SMP Mon Feb 20 11:55:25 UTC 2017 i686 i686 i686 GNU/Linux
I already searched the internet, some other user sayed to check if the PHP module is loaded by checking the file httpd.conf, but there is no such file. I searched it by using find / -name "httpd.conf" which gave no results.
You need to install PHP apache2 module to work with PHP. You can install libapache2-mod-php from your terminal by typing the command
sudo apt-get install libapache2-mod-php
After that restart your apache. It will solve your problem.

Categories