php version install issues for terminal and phpinfo() - php

In my terminal put that command
# php -v
i am getting
PHP 5.6.23-2+deb.sury.org~trusty+1 (cli)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
but in my localhost phpinfo();
i am getting 5.5.9
PHP Version 5.5.9-1ubuntu4.14
how can i got 5.6 in locahost phpinfo();
i am using localhost wamp server in ubundu os..

The PHP application and the Apache server will load different php.ini files,
wamp provides one in the apache directory and php itself will use the one in it's own php directory (where the apps are located)
To check that, you can do php -i | grep php.ini and compare it to the loaded Configuration File you get from your browser when using phpinfo()
To work around this issue, either install LAMP yourself, or try to link the two files together somehow.
Reference to another Stack Overflow question on the same topic

Related

upgrade server php version in Cpanel

I have to run composer in cpanel terminal to install and host laravel project. But however, it gives this error This package requires php ^7.2.5 but your PHP version (5.6.40) does not satisfy that requirement.
I go Settings >> MultiPHP Manager and select my domain and upgrade PHP version to 7.3
I check my PHP version in ~
[myuser#server ~]$ php -v
PHP 5.6.40 (cli) (built: May 5 2020 19:25:18)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I go to public_html/www (where my laravel project is placed)
[myuser#server www]$ php -v
PHP 7.3.18 (cli) (built: May 21 2020 03:33:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.18, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.18, Copyright (c) 1999-2018, by Zend Technologies
I go to server_information under General Information and the PHP version is 5.6,
so my question is
How to upgrade server PHP version from 5.6 to 7.3
Please note that I don't have root access, and also ApacheEasy4 is also not accessible by my user in Server.
My MultiPHP Manager Image
if in "phpversion" function you see the version of php is 7.x, but in composer is 5.x: it's because your server manager has set default php path in its envirnoment variables to php5 folder. so you need to use "/php/version/php composer" instead of "php composer"
example:
/usr/bin/local/php/7.3/php composer update
for find the path of php binary file, you can use "php --ini" command to see where is "php.ini" location. when you execute this command it tell you the ini configuration file (php.ini) path. actually in the parent of your ini file location is a direction with bin name that its your php binary file location. for example in my server output "php --ini" is:
Configuration File (php.ini) Path: /usr/local/php72/lib
Loaded Configuration File: /usr/local/php72/lib/php.ini
Scan for additional .ini files in: /usr/local/php72/lib/php.conf.d
Additional .ini files parsed: /usr/local/php72/lib/php.conf.d/10-directadmin.ini,
/usr/local/php72/lib/php.conf.d/50-webapps.ini
so is my configuration file (php.ini) path:
/usr/local/php72/lib
and my php binary file is:
/usr/local/php72/bin
and my needed command is:
/usr/local/php72/bin/php composer update
Note: please pay attention don't use "which php". because its show you the global envirnoment value of php path that in your case it has set on php 5.x so you need to call binary file from php 7.x folder. and for do it, you should follow my guide to find your php 7.x binary file path
This command worked for me in CLOUDLINUX 7.9 and cPanel v94.0.4:
/opt/cpanel/ea-php73/root/usr/bin/php /opt/cpanel/composer/bin/composer update
Click on manage on the right and update the server version.

PHP version Conflict between 5.5 and 7.1 in ubuntu 14.04 LTS

When I want to know my php version by terminal using
#php -v
I am getting
PHP 7.1.4-1+deb.sury.org~trusty+1 (cli) (built: Apr 11 2017 22:45:20) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.4-1+deb.sury.org~trusty+1,
Copyright (c) 1999-2017, by Zend Technologies
But when I am trying to run info.php written with php code
<?php phpinfo(); ?>
O/P
PHP Version 5.5.9-1ubuntu4.21
Please let me clear what is happening exactly with my php version.
I installed the full LAMP on my system freshly after un-install APACHE2, PHP & My-Sql.
Also, I recommend check Loaded Configuration File item at phpinfo() output.
Here I got /etc/php/7.0/apache2/php.ini using Ubuntu 16.04 LTS and PHP 7.0.15 with Apache.
Then at the terminal, run php --ini and check the same item Loaded Configuration File: to see if got any difference.

error upgrading php in mac

I am running OSX El Capitan (version 10.11.6).
I had php 5.5 installed.
Phpunit requires php5.6 and more so I tried to upgrade my php to 5.6. I couldn't do it so I gave php7 a try.
I followed these guides:
https://coolestguidesontheplanet.com/upgrade-php-on-osx/
https://php-osx.liip.ch/
Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28?
My current output with php -v is :
PHP 7.0.12 (cli) (built: Nov 1 2016 10:21:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
Funny thing, my output with a phpinfo(); when called from somewhere inside a Symfony project, is still PHP Version 5.5.36
Any ideas??
Terminal uses a different PHP than a HTTP server in browser. You can check what PHP you're using in CLI (command line interface) by this terminal command:
$ which php
I don't know if you use any AMP stack (like MAMP). They include their own PHP, so you need to update them in order to have a different PHP version in browser.
Maybe you can use this trick to determine what PHP versions you use in browser / CLI: Find the php.ini path in your phpinfo() output and compare it with this terminal command:
$ php -i | grep php.ini
It's always a good idea to use the debug URL to troubleshoot your Symfony projects; to use this, simply append:
app_dev.php
For example if your route was like http://myhome/, then you would use:
http://myhome/app_dev.php
Then on the bottom of your browser you will have the Symfony debug bar. In the bottom right corner, the version of Symofny is shown, an if you move your mouse over it, you will see the version of PHP; plus also a link to "View phpinfo()". You can click on it to view the full PHP information, including where the PHP file is located.
The PHP config file used (shown on the phpinfo() page) is shown by:
Loaded Configuration File
Hope that helps!

installed php, but there is nothing in /etc/init.d/php

I read a lot of posts about php problems and ect. They all say to install php, restart apache server and so on..
But the problem is that after I run:
sudo apt-get install php
and even if I check the version:
justas#justas-Lenovo-M490s ~ $ php -v
PHP 7.0.8-0ubuntu0.16.04.3 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.8-0ubuntu0.16.04.3, Copyright (c) 1999-2016, by Zend Technologies
there is nothing about php in my /etc/init.d/ folder. So for example:
if I create something in /var/www/html/ folder, like file info.php with:
<?php phpinfo(); ?>
and then I open localhost/info.php. I get raw data ( ). My php is not firing and not doing anything.
Could someone please give me some info about what is happening?
I've been using Homestead and vagrant setup in the past, but for this project I would love to configure local lamp. Mby homestead, phpadmin is somehow interfering with my vanila setup? :/
I purged apache/php/mysql. Redid everything and it seems that that fixed my problem. I still don't know what caused the issue and why php was not running properly. Because I had configured and installed all necessary models. Mby there were some problems with my old phpadmin configuration that caused some misunderstandings.

Netbeans PHP Project Apache Setup -

I've set up a project called testphp in Netbeans PHP. It has one file called Index.php. I've added to the html and have tried both run and debug.
I receive the following message from Firefox:
(URL:
http://localhost/TestPHP/index.php?XDEBUG_SESSION_START=netbeans-xdebug)
Not Found: The requested URL /TestPHP/index.php was not found on this
server. http://localhost returns "It Works!"
The virtual directory "TestPHP" does not appear to exist either. Can
someone suggest some pointers for tracking down the problem?
Ubuntu : 10.10 Apache : 2.2.16 (Ubuntu) PHP : PHP 5.3.3-1ubuntu9.3
with Suhosin-Patch Copyright (c) 1997-2009 The PHP Group Zend Engine
v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Your project isn't actually being served by your local server. The "It Works!" output is a default page your server is outputting because there are no actual files for it to serve.
The NetBeans "Local Web Site" project configuration assumes that your PHP sources will be stored in your local server's Web documents directory.
If you look at the NetBeans docs, you'll see there's an option to make NetBeans automatically copy your project's files to the appropriate web server directory when you "Run" your project.

Categories