Lampp PHP doesn't work like environment in PHP - php

I'm using LAMPP (XAMPP on Linux) to operate my server.
LAMPP has its own php binaries /opt/lampp/bin/php, which is different from the php version I have in /usr/bin/php. That is, when I've installed extensions using the command line, they've been successfully added to the original /usr/bin/php, but the php version which is associated with Lampp didn't recognized these extensions.
The question is, how to get these extensions into work with Lampp?
I can change my original php to the one in Lampp (so I can normally install extensions) or I can change the PHP associated with Lampp to be the original one but I don't know the way to do this.

Related

How to change PHP version in XAMPP?

I've downloaded XAMPP ver. 7.2.10 which supposedly has the PHP ver. 7.2.10.
But when I run a composer update on cmd, it says that my PHP version is 7.0.21. I need to have a PHP 7.1.3 in order to run my frameworks.
Is there a way to change the PHP version without installing a new XAMPP? Because I already have the latest version installed and the PHP versions stated in the XAMPP and CMD are different.
Change you Xampserver you can't change php version inside xampserver
you can download from below link
Download xampserver
You can also do it in another way.
Download your desired version of php here and then go to XAMPP folder (most likely C:\xampp).
There, extract the downloaded php file and name it php (paste it in C:\xampp) Then, copy all files from your old php folder and paste it in the new php folder.
Do not replace any files, just copy missing files and if your php version is less than 7, don't forget to edit your httpd-xampp.conf file.
Restart your Apache server and, hopefully, it will work.
Maybe you are using another version of php, check if you have another version installed and see environment variables and path there should tell you the php path used, or maybe you have an apache running, to stop it enter services and stop apache24.
Your Bash/Terminal runs in it's own PHP world.
You can upgrade it with apt-get on XAMPP VM
see here:
https://die-schwarzwald-werbeagentur.zazudesign.de/internet-programmierung/a-working-typo3-9-4-x-composer-installation-on-xampp-osx-php7-2-imagemagick-mariadb.html
After upgrading PHP to 7.2 composer will work. For some reason composer uses the bash PHP-version and not the Apache2-PHP-Version

It is possible to use different PHP versions in lampp [duplicate]

I'm developing one web application, using PHP eclipse IDE.
For an instance i want to switch from one PHP version to another version which resides in different location.
Below is my working environment :
1) Having Centos OS
2) PHP 5.1.6 have installed already while installing centos OS
3) Above PHP is installed in /usr/bin/ path
4) I have installed LAMPP in /opt/lampp
5) In LAMPP present PHP 5.2.6 version
I want to configure local web server such that lampp should choose PHP 5.1.6 (which resides in /opt/lampp )
I am not aware of this switching of PHP version.
Please suggest me how should i configure this switching of PHP version in my local web server.
Which configuration file should i choose for modifying this change.
Thanks a lot !!!
-Pravin
http://gggeek.altervista.org/2007/07/21/running-multiple-php-versions-on-a-single-apache-install/
This guide is a great guide and will get you started!
Another alternative would be to install Xampp, as I believe they provide a batch file that helps you switch versions of PHP in a second.

PHP (cli) version doesn't match XAMPP version I installed

Recently I installed XAMPP for doing local development on my Windows 7 machine. I honestly didn't think PHP was installed at all before hand. I installed the latest version of XAMPP and configured for php 5.6.24. I created some virtual hosts and everything seemed to work.
I was having an issue and I needed to confirm which version of PHP I was using so I opened up my command line and typed php -v. For some reason it is reporting I'm using PHP 5.4.25. The exact line is PHP 5.4.25 (cli) (built: Feb 5 2014 21:19:58)
I don't recall using this version (I had Visual Studio Community installed recently, is that related?). I don't understand either why my CLI is reporting one version, when XAMPP supposedly installed another version. Am I missing something? I need to run some gpm commands for the latest version of Grav CMS but when I do it says it required at least 5.5.9.
It is possible to have multiple versions of php installed.
You will want to ensure that you are executing the php-cli that came with XAMPP.
It sounds like you have another version of php installed and is in your PATH so that when you run php that version is loaded.
You can use the where command to find out what file is being loaded.
From the terminal type: where php
I am not a windows guy but there is a which command on linux. Apparently this is the command for windows. Here is a SO post about it:
Is there an equivalent of 'which' on the Windows command line?
Anyways, you may want to remove that php file and possibly create a symbolic link in its place for the XAMPP version of php-cli
If you remove/rename the file and the new php-cli is not in your path, you will probably get an error as the system will not know what php is.
The solution to this is to uninstall all the xampp's that are installed and then fresh install xampp with php version > 7.
Everything should work fine then.
What happened to me was that I had installed xampp two times. One
xampp on my C:// (version 5.6) and one xampp on my D:// (version 7.2)
When I did the command on my D:// xampp
php --version
It took the xampp php version from the C:// instead of the D://.

PHP 7.0 installed, but version doesn't change

I'm trying to install PHP 7.0, which works. But when I check my php -v in the cmd, it still says 5.5.36.
I tried it via php-liip, homebrew, install manually and via cmd. Nothing works. When I change version of PHP in MAMP (which I work with to try and install composer in a directory, that I need PHP 5.6 or higher for) i still doesn't matter.
The PHP 5.5 you're seeing was installed by Apple and is a default on your computer. It was installed at /usr/bin/php.
All of the installers you've used will not overwrite Apple's default installation - they will instead opt to create their own directories or use /usr/local/bin/ instead (thus the PHP interrupter would be installed at /usr/local/bin/php). In other words, you almost certainly have multiple php's ready to use right now. The next thing you need to do is tell bash (the default terminal/cmd on a Mac) to use the newly installed PHP interrupter.
When you run $ php on your command line, bash checks for an executable file on each of paths stored in the PATH environment variable. Once it finds one, it decides that that executable is the one you're looking for and runs that program. As of now, it's finding Apple's PHP 5.5 before it finds your fresh install of PHP 7.0 - assuming it finds PHP 7.0 at all.
You can fix this by updating PATH to check wherever PHP 7 is installed first. Instructions to do so can be found on SuperUser.StackExchange:
How should I set the PATH variable on my Mac so the Homebrew-installed tools are found?
To change php version in Ubuntu, try to use this comand
sudo update-alternatives --config php
and then select version what you need

Installing multiple PHP versions on Ubuntu Server

Initial Situation:
I have an Ubuntu 12.04 Server hosting 3 Websites (with Apache 2.2.22)
How can I install a different PHP version for only one of the Websites?
(The other 2 should remain as they are)
Current PHP Version: PHP 5.3.10
Desired PHP Version: PHP 5.6.16
What i have done/understood until now:
I have already tried out PHPBrew:
http://phpbrew.github.io/phpbrew/
I managed to install PHP 5.6.16 for the command line (with PHPBrew) but the Apache still uses PHP 5.3.10.
I understood that i should end up with an *.so file which i need to place in /etc/apache2/httpd.conf file. (this file is empty at the moment)
(via LoadModule...)
But: I don't have any *.so files.
I installed PHPBrew like this:
phpbrew install 5.6.16 +default +mysql +mcrypt
I think I should have added +apxs2=/usr/bin/apxs2 but if I do this i get the error "Exception: apxs binary is not executable: /usr/bin/apxs2".
How can i fix this?
Or is there a better way to run different PHP versions on one Server?
What is the best way?
Double check the .so files, they should be in `/usr/lib/apache2/modules/``
Then you should edit your /etc/apache2/mods-enabled/php5.load and specify the .so file that corresponds to your installation, in your case:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.6.16.so
An alternative solution for running multiple PHP versions on the same box is using Docker, see my answer in another thread: Multiple PHP versions on the same box
Note that with this solution different PHP versions will be available on different ports.

Categories