PHP Extension Not Loading - php

I am receiving the following error when trying to use the PHP shared memory function shm_attach():
PHP Fatal error: Call to undefined function shm_attach().
I have looked at my php.ini configure command via phpinfo(), and it seems to contain the necessary extensions enabled:
Configure Command => './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu'
...
'--enable-sysvmsg=shared' '--enable-sysvshm=shared' '--enable-sysvsem=shared'
...
I do not see a reference in my php.ini file to any lines like these:
extension=sysvmsg.so
extension=sysvsem.so
extension=sysvshm.so,
so when I added these to my php.ini file in the hopes that it would possibly do something, it merely threw an error.
In my PHP version on my localhost (Ubuntu), I didn't need to download and install any extensions for these type of functions to work, they were installed be default and worked out of the box.
PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch (cli) (built: Feb 11 2012 02:17:16)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
The server I am having the issue on is using a different configuration:
Linux version 2.6.35.6-45.fc14.x86_64 (mockbuild#x86-02.phx2.fedoraproject.org) (gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC) ) #1 SMP Mon Oct 18 23:57:44 UTC 2010
and PHP:
PHP 5.3.8 (cli) (built: Sep 28 2011 17:34:42)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
Any suggestions as to what might have caused the extension to have been installed incorrectly?
Any solutions?

Related

Change CLI PHP version on Mac

I using Mac BigSur lastest update.
I have install Bitnami MAPP with PHP version 8.0.8.
But in CLI still PHP 7.3.24
I try create PATH to Bitnami PHP8.0.8 but have warning like below
WARNING: PHP is not recommended
PHP is included in macOS for compatibility with legacy software.
Future versions of macOS will not include PHP.
PHP 7.3.24-(to be removed in future macOS) (cli) (built: Dec 21 2020 21:33:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.24, Copyright (c) 1998-2018 Zend Technologies
How to switch PHP CLI to PHP8.0.8 of Bitnami?
Bitnami engineer here!
The output you are seeing is produced by the PHP binary that comes preinstalled in macOS. When you install Bitnami MAMP, a standalone, updated version of PHP will also be installed in your system. In order to use it instead of the default one, you have two options:
Use the full path to the binary (installdir/php/bin/php)
$ /Applications/mampstack-8.0.9-0/php/bin/php --version
PHP 8.0.9 (cli) (built: Jul 30 2021 07:59:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
Add the directory containing the PHP binary to your path
$ export PATH=/Applications/mampstack-8.0.9-0/php/bin:$PATH
$php --version
PHP 8.0.9 (cli) (built: Jul 30 2021 07:59:45) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies
For the examples above, /Applications/mampstack-8.0.9-0 was the installation directory (installdir) of the stack.

php -v shows cgi-fcgi

I was following instructions to install get to clone a repository and then all of the sudden I started getting "bin/magento must be run as a CLI application" error.
When I did php -v, it shows:
ea-php-cli Copyright 2016 cPanel, Inc.
PHP 7.0.17 (cgi-fcgi) (built: Apr 5 2017 23:22:19)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.17, Copyright (c) 1999-2017, by Zend Technologies
I've sincerely searched for hours to change this back to show (cli), but so far no luck.
I've reinstalled ea-php-cli via yum but nothing has changed.
When I stopped and restarted the httpd, I get a bunch of errors like this one:
[alias:warn] [pid 31484] AH00671: The ScriptAlias directive in
/etc/apache2/conf/httpd.conf at line 645 will probably never match
because it overlaps an earlier ScriptAlias.
Does anyone know the command to change the php mode to cli mode rather than cgi-fcgi mode? If not, do I need to uninstall and reinstall php?
Update
so after some research I realized that it has to do with the Server API where it's set up as FPM/FAstCGI rather than Apache 2.0 Handler. I will have to research this and then find out how to switch the server API back to Apache Handler... I'm running Centos 6.9 so if anyone has an easy solution, I'd greatly appreciate your input.
More Update
The only thing I can think of that may have affected the Server API to switch is a few of the patches I have made. Here's a list of all the patches and changes made to the server today:
Apr 15 12:47:02 Installed: kernel-2.6.32-696.1.1.el6.x86_64
Apr 15 13:14:02 Installed: 1:perl-Error-0.17015-4.el6.noarch
Apr 15 13:14:02 Installed: perl-Git-1.7.1-8.el6.noarch
Apr 15 13:14:03 Installed: git-1.7.1-8.el6.x86_64
Apr 15 19:21:49 Erased: epel-release
Apr 15 20:33:45 Installed: ea-php-cli-0.2.0-1.1.1.cpanel.x86_64
Apr 15 21:00:58 Installed: ea-php-cli-0.2.0-1.1.1.cpanel.x86_64
Apr 15 22:32:44 Installed: ea-php-cli-0.2.0-1.1.1.cpanel.x86_64
After 15 hours of searching for an answer, I finally got it resolved.
Simply add source /opt/cpanel/ea-php70/enable to /etc/bashrc and php -v results in showing cli.
PHP 7.0.17 (cli) (built: Apr 5 2017 23:21:59) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.17, Copyright (c) 1999-2017, by Zend Technologies

After Google App Engine SDK update not able to run local server through PHPStorm 8?

After updating Google App Engine SDK to 1.9.20 I am unable to run local server through PHPStorm 8. I get the following error:
The PHP interpreter specified with the --php_executable_path flag
("/usr/local/bin/php-cgi") is not compatible with the App Engine PHP development environment.
Unable to load GAE runtime module at /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/php55/gae_runtime_module.so
I am running following versions locally
php --version
PHP 5.5.22 (cli) (built: Mar 10 2015 14:17:46)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
php-cgi --version
PHP 5.5.22 (cgi-fcgi) (built: Mar 10 2015 14:17:49)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans
Here is the error I am getting through PHPStorm:
ERROR 2015-05-18 11:30:04,783 php_runtime.py:353] The PHP runtime is not
available
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 349, in new_instance
self._check_binaries(php_executable_path, gae_extension_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 290, in _check_binaries
cls._check_gae_extension(php_executable_path, gae_extension_path, env)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 252, in _check_gae_extension
gae_extension_path)
_PHPEnvironmentError: Unable to load GAE runtime module at /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/php55/gae_runtime_module.so
To my understanding, PHP version 5.5 should be supported, where is the problem?
Assuming you're running on Mac, simply remove the "Path to php-cgi executable" setting in PHPStorm should fix the problem.

how to update native php 5.3 mac installation with installed brew php 5.4 installation?

I am trying to work on laravel framework, i got an error for which i needed php5.4+. earlier i had installed php, apache and mysql somehow which came with mac.
when i check the versions i get as below:
$ /usr/local/Cellar/php54/5.4.19/bin/php -v
PHP 5.4.19 (cli) (built: Sep 17 2013 21:14:22) (DEBUG)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
$ php -v
PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
right now php5.3 gets displed on phpinfo(), how to make apache use php5.4?
if which php still gives /usr/bin/php, add this line to the end of your ~/.bashrc (or ~/.zshrc if you use ZSH)
export PATH="$(brew --prefix)/bin:$PATH"
Also see https://github.com/josegonzalez/homebrew-php#installing-multiple-versions
EDIT
For Apache
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
php5.3, php5.4, php5.5
http://php-osx.liip.ch/
PHP 5.5
http://mac.tutsplus.com/tutorials/server/upgrading-the-native-php-installation-on-os-x-mountain-lion/

How to update PHP CLI OSX?

I just updated to php 5.4 using http://php-osx.liip.ch/ on osx lion.
when i type:
php -v
i still see:
PHP 5.3.15 with Suhosin-Patch (cli) (built: Jul 31 2012 14:49:18)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
But phpinfo() shows 5.4.
How do i update this?
Just Export installed PHP path ,type this on Terminal
export PATH=/usr/local/php5/bin:$PATH
I checked that /usr/local/php5/bin/php existed. It did, so I added /usr/local/php5/bin to my PATH.
Thank you #AD7six
The answer shared by both Chutipong Roobklom and user1168427 helped, if you want to update to the latest php cli which is 7.2.7 (most current and stable release as of 2018 when this post was created originally so check the latest php version, methods for switching versions may vary) then just use this instead of the php5 command. export PATH=/usr/local/php7/bin:$PATH then type php -v and you should have something that reads like this(on MACOSX by the way):
PHP 7.2.7 (cli) (built: Jun 22 2018 06:27:50) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.7, Copyright (c) 1999-2018, by Zend Technologies
so you shouldn't be getting any errors. Hope this helps and for Kamel, that is how it is installed. You're kind of 'exposing' it in a way for your machine to now recognize which php version you are using.

Categories