Forum

Ask, reply and learn. Join the community of Akaunting.

New Discussion

How to Set PHP_BINARY on Install

Thirsty Crow   ( User )

Commented 3 years ago

I've tried installing Akaunting on my shared server on Dreamhost. Dreamhost allows me to set the HTTP version of PHP to whatever I want. However, for CLI, the default is PHP 7.2.3. I have access to other versions, and I've set up an alias to make the "php" command point to PHP 7.4. I've also added the directory for it to my $Path variable. However, the version of PHP that is located at /usr/bin/php is still 7.2.3.

Upon doing more research, I learned that you can set the PHP_BINARY to establish the path to the version of PHP you want to use. This is set in the .env file. However, I don't know how to establish this on first install. I can't make it to the setup screens because I'm failing the version check for PHP. If I create a .env file, I don't have all the details to get Akaunting to set up and launch correctly. Is there a place to set the PHP_BINARY that will be used by the version check for the install script?

Thirsty Crow   ( User )

Commented 3 years ago

Well, I got ambitious and commented out the error check in the Installer.php script. Once I fixed that, I was able get everything set up and installed. I was able to add PHP_BINARY to my .env file at that point.

However, in spite of adding that line to the .env file, when I am trying to install the double-entry app, it is giving me the same error that I am using an old version of PHP. That would mean that it has to be hard coded to look at /usr/bin/php, and is ignoring the PHP_BINARY variable, as well as the local php command which is aliased to PHP 7.4.

How do I get the app to recognize the PHP_BINARY environment variable, rather than having it attempt to use the /usr/bin/php command?

Thirsty Crow   ( User )

Commented 3 years ago

And more specifically, the command that failed is:

The command php artisan module:install double-entry 1 en-US failed.

Exit Code: 1(General error)

So perhaps a more accurate version of my question is how to make sure artisan is using the PHP_BINARY?

Thirsty Crow   ( User )

Commented 3 years ago

Ok, so final work-around for me, and I'm documenting it here in case it helps anyone else who is having similar troubles. I know less than nothing about PHP, but it appears that my issues are coming from the overrides/symfony/process/PhpExecutableFinder.php

There is a note that the override doesn't work for shared hosting (something I didn't know until I got here). I was able to make a workaround for my problem by setting the path for my PHP executable with the correct version on line 36. I'd imagine that had I done this originally, I wouldn't have needed to mess around with my workaround above, because it would have been able to find the correct version of PHP on the command line originally.

Obviously, this is a work-around and not a long term fix, but it was enough to allow me to get everything working.

Abdul Haq   ( User )

Commented 1 year ago

Adding APP_PHP_PATH="/usr/local/bin/php82" to my .env file fixed issues for me.

Please login or register to leave a response.

Showing 1 to 5 of 5 discussions