Closed mrPsycho closed 6 years ago
for example by @kain-jy: https://gist.github.com/kain-jy/4138784
Hi! I could (and do) use init scripts for php-fpm, but it is an optional part of usage and there's no cross-compatible way to ensure installation.
Here's an init script that I use on Ubuntu 14.04 (systemd units for later than that) https://gist.github.com/madumlao/5150a69e8c214207ea382c5e588bef33
It assumes that phpenv is installed as the user/directories in the variables, and it assumes that you created an etc/ var/run structure as that user. The advantage of this approach is that you can run multiple instances of php-fpm with different versions (listening on different sockets). You have to tell your webserver, though, to pass http connections to those sockets on whatever basis you define...
oh. it would cooul to add this info in readme. for easier finding the solution.
thank you for your product! it is very usefull!
On Wed, Jul 12, 2017 at 12:18 PM, Mark David Dumlao < notifications@github.com> wrote:
Hi! I could (and do) use init scripts for php-fpm, but it is an optional part of usage and there's no cross-compatible way to ensure installation.
Here's an init script that I use on Ubuntu 14.04 (systemd units for later than that) https://gist.github.com/madumlao/5150a69e8c214207ea382c5e588bef33
It assumes that phpenv is installed as the user/directories in the variables, and it assumes that you created an etc/ var/run structure as that user. The advantage of this approach is that you can run multiple instances of php-fpm with different versions (listening on different sockets). You have to tell your webserver, though, to pass http connections to those sockets on whatever basis you define...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/madumlao/phpenv/issues/15#issuecomment-314705169, or mute the thread https://github.com/notifications/unsubscribe-auth/AA18_K5bBdn_9BJ-2d6GNOq0g9mW6BZPks5sNI9agaJpZM4OLVN6 .
-- Yaroslav
README sounds like a good place to put it.
Thanks for the appreciation, but please don't call it my product ;) . phpenv is the culmination of a community effort to create the best environment for installing custom versions of php. It's heavily inspired by rbenv , and I'm only doing a small part in helping keep it updated.
Many thanks to the community at large for the contributions and support, we wouldn't get here without them.
Hi,
I've installed php 7.1.8 via php-build plugin for phpenv. It installed also php-fpm, so a php-fpm executable is located in .phpenv/versions/7.1.8/sbin/php-fpm. All other executables like php itself are located in .phpenv/versions/7.1.8/bin/.
When I type "which php" the command line returns ".phpenv/shims/", so I think there is some kind of redirect in that shims directory that redirects to .phpenv/versions/7.1.8/bin/php. But for any reason there is no redirect in that shims directory that redirects to .phpenv/versions/7.1.8/sbin/php-fpm. Someone an idea how I can use the php-fpm like php? I need it to generate the php-fpm.sock for nginx.
Hi @bes1002t any progress on this? Did you find the solution? I'm facing the same problem, that I want to use phpenv, php-fpm and Nginx. Is there a way to switch the php version with phpenv and then use this version in Nginx?
Hi @sebbaum , I find this very unusual, as in fact the very first commit I had on this project was to add support for sbin/php-fpm
and as best as I can tell it generates the shims today.
Could you possibly have some combination of an outdated phpenv and php-build? Could you try reinstalling phpenv from scratch by renaming your ~/.phpenv
and following this installer? You'll have to rerun phpenv install
on your desired versions though.
(You can revert to your old phpenv by deleting the new ~/.phpenv
directory and renaming your old ~/.phpenv
directory back).
Hi @madumlao, thanks for your reply. I will check it and come back to you.
Cheers Sebastian
So here is some more information and the steps I did:
curl -L https://raw.githubusercontent.com/madumlao/phpenv-installer/master/bin/phpenv-installer \
| bash
Output:
vagrant@phpenv:~$ curl -L https://raw.githubusercontent.com/madumlao/phpenv-installer/master/bin/phpenv-installer \
> | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3650 100 3650 0 0 7440 0 --:--:-- --:--:-- --:--:-- 7448
INFO
| $PHPENV_ROOT is defined as /home/vagrant/.phpenv
Installing phpenv
Cloning into '/home/vagrant/.phpenv'...
remote: Counting objects: 1126, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 1126 (delta 0), reused 0 (delta 0), pack-reused 1121
Receiving objects: 100% (1126/1126), 216.43 KiB | 306.00 KiB/s, done.
Resolving deltas: 100% (695/695), done.
Checking connectivity... done.
| Done.
Installing php-build/php-build
| Done.
Installing madumlao/phpenv-aliases
| Done.
Installing ngyuki/phpenv-composer
| Done.
WARNING
| # Seems you still have not added 'phpenv' to the load path.
|
| # Load phpenv automatically by adding
| # the following to ~/.bash_profile:
export PHPENV_ROOT="/home/vagrant/.phpenv"
if [ -d "${PHPENV_ROOT}" ]; then
export PATH="${PHPENV_ROOT}/bin:${PATH}"
eval "$(phpenv init -)"
fi
Added to .bashrc file:
export PHPENV_ROOT="/home/vagrant/.phpenv"
if [ -d "${PHPENV_ROOT}" ]; then
export PATH="${PHPENV_ROOT}/bin:${PATH}"
eval "$(phpenv init -)"
fi
Disconnect/reconnect
phpenv -v: phpenv v0.0.4-dev
phpenv versions
* system (set by /home/vagrant/.phpenv/version)
php install -l
Install required dependencies:
sudo apt-get install -y pkg-config \
libsslcommon2-dev \
libcurl4-openssl-dev \
libssl-dev \
openssl \
libjpeg-turbo8-dev \
libbz2-dev \
mcrypt \
libmcrypt-dev \
libedit-dev \
libreadline-dev \
libtidy-dev \
libxslt1-dev \
libpng-dev \
autoconf
phpenv install 7.0.32
Output:
vagrant@phpenv:~$ phpenv install 7.0.32
[Info]: Appending build output to /tmp/php-build.7.0.32.20180920120853.log
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.0.32 into /home/vagrant/.phpenv/versions/7.0.32
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.0.32.tar.bz2
[Preparing]: /tmp/php-build/source/7.0.32
[Compiling]: /tmp/php-build/source/7.0.32
[xdebug]: Installing version 2.6.1
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-2.6.1.tgz
[xdebug]: Compiling xdebug in /tmp/php-build/source/xdebug-2.6.1
[xdebug]: Installing xdebug configuration in /home/vagrant/.phpenv/versions/7.0.32/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.0.32.20180920120853.log
[Success]: Built 7.0.32 successfully.
phpenv rehash
Output:
Download composer.phar ...
Move composer.phar to /home/vagrant/.phpenv/versions/7.0/composer
phpenv versions
Output:
* system (set by /home/vagrant/.phpenv/version)
7.0
7.0.32
vagrant@phpenv:~$ php -v
PHP 7.1.20-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jul 25 2018 10:06:40) ( NTS )
phpenv shell 7.0
7.0
phpenv shell
7.0
php -v
=> This is working as expected
Output:
PHP 7.0.32 (cli) (built: Sep 20 2018 12:17:17) ( NTS )
phpenv which php-fpm
Output:
/home/vagrant/.phpenv/versions/7.0/sbin/php-fpm
vagrant@phpenv:~/.phpenv/versions/7.0.32/sbin$ php-fpm
[20-Sep-2018 12:46:25] ERROR: failed to open configuration file '/home/vagrant/.phpenv/versions/7.0.32/etc/php-fpm.conf': No such file or directory (2)
[20-Sep-2018 12:46:25] ERROR: failed to load configuration file '/home/vagrant/.phpenv/versions/7.0.32/etc/php-fpm.conf'
[20-Sep-2018 12:46:25] ERROR: FPM initialization failed
So if I unserstand correctly, I have to configure all php-fpm relevant conf files myself, right? Then php-fpm will run and I have to configure Nginx to use this socket. However switching the PHP version with phpenv again, requires manual configurarion again. And I think this was also the initial question in this thread: Is it possibile to facilitate this?
Can you confirm my understanding @madumlao? Or am I missing something?
That's.... interesting.
PHP 5.x used to provide etc/php-fpm.conf.default
in that directory, but now I see that in 7.x and onwards, php-fpm.conf isn't provided.
This is probably more of a php-build issue (php-build is the one populating the versions/ directory), although if upstream itself does not provide the php-fpm.conf, there's not much they can do and you have to provide the config yourself.
Hi @sebbaum, my mistake, php-fpm.conf.default
is provided by php during the build process. I confused my latest php build with an older one where I had moved php-fpm.conf.default
to another file.
The recommended way would be to move the php-fpm.conf.default
to php-fpm.conf
and then configure it.
@sebbaum, this should be handled in my latest php-build/php-build PR https://github.com/php-build/php-build/pull/528
Hi @madumlao,
thanks for your effort and your speed. I'm looking forward to use phpenv when everything is merged and updated.
Cheers Sebastian
php-build/php-build#529 has merged, and thus I'm able to include the change into upstream phpenv. This will be closed soon.
hello!
thank you for that great tool! but, one feature request: please, add init.d script for php-fpm