How to set an environment variable for installing PHP via XAMPP on Ubuntu

Posted by

To set an environment variable for installing PHP via XAMPP on Ubuntu, you typically don’t need to set specific environment variables for XAMPP itself. However, you might want to adjust your system’s PATH variable to include XAMPP’s PHP binary directory so that you can use PHP commands from the command line without specifying the full path.

Locate XAMPP’s PHP Binary Directory: This is typically located within your XAMPP installation directory. The PHP binary itself is usually found in the bin directory inside the XAMPP folder.

Open your shell configuration file: This could be ~/.bashrc, ~/.bash_profile, or ~/.profile. You can use any text editor to open the file. For example, you can use nano:

nano ~/.bashrc

Add XAMPP’s PHP Binary Directory to PATH: Add the following line at the end of the file, replacing /path/to/xampp/php with the actual path to your XAMPP’s PHP binary directory:

export PATH="/path/to/xampp/php:$PATH"

Make sure to replace /path/to/xampp/php with the actual path. If your XAMPP is installed in the default location, it might look like this:

export PATH="/opt/lampp/bin:$PATH"

Save and Close the File: In nano, you can do this by pressing Ctrl + O to save the file and then Ctrl + X to exit.

Apply the Changes: After saving the file, you need to apply the changes to your current shell session. You can either close and reopen your terminal or run:

source ~/.bashrc

Verify: You can now verify that the changes have taken effect by running:

php -v

This should display the version of PHP installed with XAMPP.

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x