Softaculous


Topic : Using WP-Cli


Posted By: azanebrain on April 7, 2014, 5:12 am
I've setup wp-cli (wp-cli.org/) on my machine, but it is unable to run any commands from the path of the wordpress site.
Running the basic `wp` command returns this error:

Error:
<h1>Error establishing a database connection</h1>
<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>localhost</code>. This could mean your host's database server is down.</p>
<ul>
    <li>Are you sure you have the correct username and password?</li>
    <li>Are you sure that you have typed the correct hostname?</li>
    <li>Are you sure that the database server is running?</li>
</ul>
<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='wordpress.org/support/'>WordPress Support Forums</a>.</p>

I have found a lot of support for this error with MAMP, but nothing with AMPPS. The main lead seems to be the bath to the PHP binary, however I've had no luck.
link: github.com/wp-cli/wp-cli/wiki/Alternative-Install-Methods

Has anyone been able to figure out how to run wp-cli with AMPPS?

Posted By: tidus on April 7, 2014, 7:14 am | Post: 1
Hi,

AMPPS PHP and MySQL are not in environment variable, so you may have to set their path in PATH variable.


-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack

Posted By: azanebrain on April 7, 2014, 5:33 pm | Post: 2
Are those paths /Applications/AMPPS/<php version>/bin and /Applications/AMPPS/mysql/bin ?
When I tried that (export WP_CLI_PHP=/Applications/AMPPS/php-5.3/bin in my .bash_profile) , I got a jumbled output of question marks and diamonds, and the PHP binary path in wp --info is still `/usr/bin/php`

Posted By: tidus on April 7, 2014, 5:34 pm | Post: 3
Hi,

You can create a symlink at that location if necessary.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack

Posted By: azanebrain on April 7, 2014, 7:14 pm | Post: 4
Thanks for the quick responses

I tried symlinking to AMPPS/bin/php, and AMPPS/php-5.3/bin/php but those totally broke wp-cli (before I could run command such as `wp --info`)

I'm on Mac OS Mavericks, running AMPPS 2.3 if that helps

Posted By: tidus on April 8, 2014, 5:26 am | Post: 5
Hi,

AMPPS/bin/php ? I don't think symlink here is necessary.

wp is looking for php in /usr/bin/php, so create one there.

Code
ln -s /Applications/AMPPS/php/bin/php /usr/bin/php





-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack

Posted By: azanebrain on April 8, 2014, 4:09 pm | Post: 6
That's the command I ran, but it turned out I also had to set the PHP version to 5.4. The WP-Cli official page says it supports PHP 5.3.2 or later, so I'm guessing AMPPS 5.3 is 3.0 or 3.1?

Thanks for the help, Tidus!

Posted By: tidus on April 9, 2014, 8:57 am | Post: 7
Hi,

PHP 5.3.28.

It also has PHP 5.4.25 and 5.5.9.


-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack

Posted By: lrussell on April 23, 2014, 8:04 pm | Post: 8
I just ran into this too, I posted my solution here: http://lucrussell.com/fix-for-wp-cli-ammps-printing-rubbish/

Powered By AEF 1.0.8 © 2007-2008 Electron Inc.