I have just built 3 different versions of PHP from source on an Ubuntu server (alongside NGINX and MySQL 5.7). I am looking for a way to run php --ini
for the currently running version. I know I have to add the location to the file PATH
in .bashrc
so I don't have to add the full path.
I have added this to my .bashrc
which allows me to get the currently running PHP version, which then allows me to run the command:
# parallels@ubuntu:~$ ps aux | grep php
# root 6948 0.0 0.2 153724 4620 ? Ss 16:48 0:00 php-fpm: master process (/opt/php-7.0.0/etc/php-fpm.conf)
PHP_VERSION=$(ps aux | grep -o php-[[:digit:]].[[:digit:]].[[:digit:]])
export PATH="/bin:/usr/bin:/opt/$PHP_VERSION/bin:/sbin"
It works, but I am a bash novice and I'm thinking their might be a different way to do it. Would I be correct?