2

I'm running Ubuntu Natty.

I recently installed PHP 5.3.8 from Source and it works ok. However, as part of my installation, I had to install php5-dev so I guess this has installed another PHP on the server (I needed to do this for phpize).

My main PHP binary is at /usr/local/php/bin. However, when I run php from the command line with something like this php --ini I get the following:

$ php --ini
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File:         /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed:      /etc/php5/cli/conf.d/pdo.ini

I can still run PHP from /usr/local/php/bin, but that would mean me having to type the whole path out for all my command line scripts.

Is there a way I can change this behaviour so that when I use the php command, it points to the php binary inside /usr/local/php/bin instead?!

Thanks in advance

2 Answers 2

4

You can edit your .bash_profile file to change your default search path. Or update it using PATH=/usr/local/php/bin:$PATH or somesuch.

Sign up to request clarification or add additional context in comments.

4 Comments

Not familiar with this. Where can I find that file?
It's a usually hidden file, should be in your home ~ folder. Might also be ~/.bashrc
There's a file in my /etc directory called bash.bashrc, I'm thinking this is the one?! But I have no idea what to do here, can you link me to a tutorial or something?
An easier way: #] echo $PATH to see what's the first entry. That's where your computer will search first. In that folder, type: #] sudo ln -s /usr/local/php/bin/php ./php That will create a "simlink" to the version of PHP you really want to use, so using #] php in your folders will execute the one you want.
1

The below code worked for the specific circumstance in my earlier question:

printf "\nexport PATH=/usr/local/php/bin:\${PATH}\n" >> /etc/profile
source /etc/profile

Hope it helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.