Use only php from xampp

Use only php from xampp

I am using Ubuntu 18.04.3 LTS and xampp with php 7.4.

I am trying to change the > php path variable.

I tried:

admin@admin:/opt/lampp/bin$ sudo ln -s /opt/lampp/bin/php /usr/bin/php
admin@admin:/opt/lampp/bin$ which php
/usr/bin/php

As you can see my path variable seems to be under /usr/bin/php.

  1. How can I check the current path variable of php?
  2. How can I set xampp's php executable as PATH variable?

I appreciate your replies!

答案1

You created a symlink to /opt/lampp/bin/php in the location /usr/bin/php. At the same time, this file is what is called when launching just php on the command line according to your which output.

How can I check the current path variable of php?

To check the target of a symlink (likely) found using the which command, use readlink -f or realpath.

readlink -f $(which php)

or

realpath $(which php)

How can I set xampp's php executable as PATH variable?

From what you claim to have done, you have set it already! However, to prevent potential conflicts with a php program installed by the Ubuntu’s package management system, you should rather create the symlink in /usr/local/bin instead of /usr/bin. The /usr/local/bin directory should be in your PATH variable before /usr/bin. To check this, run:

echo $PATH

答案2

Just a point to note. You can just install XAMPP only without PHP from Ubuntu PAckage repo and create a symlink to avoid any multiple php conflicts like this

sudo ln -s /opt/lampp/bin/php /usr/bin/php

相关内容