Closed frederickjh closed 5 years ago
Yes. Pretty much, phpenv uses your $HOME/.phpenv/versions
as a directory containing all your versions of php. So if you symlink a directory to there phpenv can use it.
ln -sv /opt/cpanel/ea-php56/root/usr/bin/php $HOME/.phpenv/versions/5.6
ln -sv /opt/cpanel/ea-php71/root/usr/bin/php $HOME/.phpenv/versions/7.1
ln -sv /opt/cpanel/ea-php72/root/usr/bin/php $HOME/.phpenv/versions/7.2
Note however, that since this is a system directory, you won't be able to run commands like pear / pecl as a regular user.
Thanks @madumlao ! Maybe this should be added to the documentation.
ok. btw @frederickjh , the official phpenv repo has been reclaimed (I'm the maintainer) so you can post further issues there.
Thanks for pointing that out @madumlao. Sorry, I some how didn't realize that your repository was a fork of the main project, as for the most part people turn the issue queue off for forks. Was this repository the main one for a while?
Yes. For a while, the official repo was inactive and everyone pointed to my fork, which eventually got merged back.
New developments can go through here though.
The commands above do not put the php binaries where phpenv
expects them to be. From the install instructions it says that phpenv rehash
looks for php versions in: ~/.phpenv/versions/*/bin/*
.
So to setup the three version above one would need to run the following to:
mkdir -p $HOME/.phpenv/versions/5.6/bin
mkdir -p $HOME/.phpenv/versions/7.1/bin
mkdir -p $HOME/.phpenv/versions/7.2/bin
ln -sv /opt/cpanel/ea-php56/root/usr/bin/php $HOME/.phpenv/versions/5.6/bin/
ln -sv /opt/cpanel/ea-php70/root/usr/bin/php $HOME/.phpenv/versions/7.0/bin/
ln -sv /opt/cpanel/ea-php71/root/usr/bin/php $HOME/.phpenv/versions/7.1/bin/
phpenv rehash
@frederickjh, not that familiar with the directory structure of PHP versions within cpanel, but ideally the versions directory contains links to the PHP prefixes of each version.
If you run php -i
using the full path of the binary, you should be able to see the install prefix:
madumlao@lezard ~ $ php -i|grep Configure
Configure Command => './configure' '--with-config-file-path=/home/madumlao/.phpenv/versions/7.0.32/etc' '--with-config-file-scan-dir=/home/madumlao/.phpenv/versions/7.0.32/etc/conf.d' '--prefix=/home/madumlao/.phpenv/versions/7.0.32' '--libexecdir=/home/madumlao/.phpenv/versions/7.0.32/libexec' '--without-pear' '--with-gd' '--enable-sockets' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--enable-exif' '--enable-zip' '--with-zlib' '--with-zlib-dir=/usr' '--with-bz2' '--enable-intl' '--with-kerberos' '--with-openssl' '--with-mcrypt=/usr' '--enable-soap' '--enable-xmlreader' '--with-xsl' '--enable-ftp' '--enable-cgi' '--with-curl=/usr' '--with-tidy' '--with-xmlrpc' '--enable-sysvsem' '--enable-sysvshm' '--enable-shmop' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-pdo-sqlite' '--enable-pcntl' '--with-readline' '--enable-mbstring' '--disable-debug' '--enable-fpm' '--enable-bcmath' '--enable-phpdbg' '--with-libdir=lib64'
In the above, the --prefix=/home/madumlao/.phpenv/versions/7.0.32
means that PHP and all its support libraries, docs, extensions, etc are installed in the above directory.
If you run /opt/cpanel/ea-php56/root/usr/bin/php -i
, the prefix directory you should see should be the path you should link to your phpenv versions directory.
The prefix is:
--prefix=/opt/cpanel/ea-php56/root/usr
So to setup the versions ran:
ln -sv /opt/cpanel/ea-php56/root/usr $HOME/.phpenv/versions/5.6
ln -sv /opt/cpanel/ea-php70/root/usr $HOME/.phpenv/versions/7.0
ln -sv /opt/cpanel/ea-php71/root/usr $HOME/.phpenv/versions/7.1
This works as you pointed out there is no need to link directly to the php binary.
Hi! I have a VPS Web Hosting that uses Cpanel with multiple versions of PHP already available. Cpanel does a good job of switching the versions for the web server but not on the command line, where it just uses the default. This causes issues when using command line tools to work with web applications. The Cpanel versions of php are located at:
PHP 5.6
/opt/cpanel/ea-php56/root/usr/bin/php
PHP 7.1/opt/cpanel/ea-php71/root/usr/bin/php
PHP 7.2/opt/cpanel/ea-php72/root/usr/bin/php
etc.Is there a way to configure
phpenv
to use these versions of PHP instead of building? Thanks in advance for any advice you can give! Frederick