faurmic's picture

Hello,

You'll immediately realise that I'm a newbie, sorry in advance if my issue comes from a simple settings solution. I'm using Wordpress on Turnkeylinux and installed WP-CLI.

wp --info gives me the following :

OS:	Linux 3.16.0-6-amd64 #1 SMP Debian 3.16.56-1 (2018-04-28) x86_64
Shell:	
PHP binary:	/usr/bin/php5
PHP version:	5.6.33-0+deb8u1
php.ini used:	/etc/php5/cli/php.ini
WP-CLI root dir:	phar://wp-cli.phar
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/root
WP-CLI packages dir:	
WP-CLI global config:	
WP-CLI project config:	
WP-CLI version:	1.5.1

 

I'd like to install Gravity CLI to be able to import entries. I tried :

> wp plugin search gravity
Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under.

If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

If you'd like to continue as root, please run this again, adding this flag:  --allow-root

If you'd like to run it as the user that this site is under, you can run the following to become the respective user:

    sudo -u USER -i -- wp <command>

 

So I tried :

> wp plugin search gravity --allow-root
Error: This does not seem to be a WordPress install.
Pass --path=`path/to/wordpress` or run `wp core download`.

 

Then tried to move to the Wordpress folder :

cd /var/www/wordpress

 

And again :

> wp plugin search gravity --allow-root
PHP Notice:  Constant AUTH_KEY already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 10
PHP Notice:  Constant AUTH_SALT already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 11
PHP Notice:  Constant FS_METHOD already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 37

 

Honestly I have no idea to solve my issue. So I tried installing Gravity-CLI from the wordpress plugin manager. But get the same things :

> wp help gf --allow-root
PHP Notice:  Constant AUTH_KEY already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 10
PHP Notice:  Constant AUTH_SALT already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 11
PHP Notice:  Constant FS_METHOD already defined in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 37

 

May someone give me a hand with this one ? Thanks

Mic

 

Forum: 
Jeremy Davis's picture

I don't know much about WordPress, but I do know a fair bit about Linux in general and TurnKey in particular so hopefully I might be of some help.

Judging from what you've posted, I'm guessing you probably used this page (or similar). FWIW I quickly fired up an instance of our development version (15.0rc1 - still not publicly released) to see if that worked. FWIW I installed wp-cli like this:

wget -O /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x /usr/local/bin/wp

I then got a very similar (although slightly different because of the newer version) output to you when I ran wp --info. When I tried running the commands that you noted, it actually worked ok, but did still spew out some very similar warnings to you.

After a little digging, it appears that the complaints about AUTH_KEY and AUTH_SALT are because they're defined twice in the wp-config.php file. The entries are identical, so I doubt it would actually cause any issues, but they should really only be defined once. Removing the duplicates resolved those issues. I didn't get any warning relating to FS_METHOD, but I assume something similar is happening.

So to resolve this, simply edit your wp-config.php file (in /var/www/wordpress) and double check I'm right. Assuming I am, you can safely remove the first instances of both AUTH_KEY and AUTH_SALT (they should be identical, so it actually shouldn't matter which you remove, so long as they only appear once each in your wp-config.php). I assume that the warning your getting regarding FS_METHOD is because it too is included twice (same message so stands to reason that it would be the same cause). If you do have 2 and they're the same, just remove one. If they're different, then please feel free to post back and I'll have a look.

FWIW I also got another warning you didn't note:

PHP Notice:  Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval()'d code on line 33

It turns out that that is because we use the HTTP_HOST variable (i.e. $_SERVER['HTTP_HOST']) in the wp-config.php file. We do that so it automatically picks up the domain that it's being accessed by. If you hit that too, it's mentioned in an issue on the wp-cli issue tracker. The links given there should hopefully provide additional info and explanation on how to work around that.

Good luck. :)

faurmic's picture

Hi Jeremy,

 

Thanks for your answer.

 

After deleting both AUTH_KEY and AUTH_SALT (and FS_METHOD)  from wp-config.php I got :

PHP Notice: Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval(

)'d code on line 33 

PHP Notice: Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(1145) : eval(

)'d code on line 34 

Segmentation fault

 

Went to this page and added the following to wp-config.php :

if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) {
    $_SERVER['HTTP_HOST'] = 'wp-cli.org';
}
 
But now there's no output... when I try :
> wp gf form list --allow-root
 

I probably did something wrong. :D

May you have an idea to solve this ?

 

Thanks

 

Mic

 

faurmic's picture

Debug (bootstrap): No readable global config found (0.31s)
Debug (bootstrap): No project config found (0.311s)
Debug (bootstrap): argv: /usr/local/bin/wp --debug --allow-root (0.311s)
Debug (bootstrap): ABSPATH defined: /var/www/wordpress/ (0.311s)
Debug (bootstrap): Begin WordPress load (0.311s)
Debug (bootstrap): wp-config.php path: /var/www/wordpress/wp-config.php (0.312s)

Read the topic on this page but I don't know how to use the :

sudo chown -R apache:group /my/php/session

 

Jeremy Davis's picture

It's probably useful to be aware that TurnKey is based on Debian. So when you're having issues, anything that Google turns up that is relevant to a headless Debian server, should generally be relevant to TurnKey too. Ubuntu is also derived from Debian so instructions for that will often (but not always) also apply. Please keep in mind that Ubuntu is NOT binary compatible with Debian (TurnKey is) so there are certain situations, where you should NOT follow instructions for Ubuntu. That mostly applies to adding and installing software from third party repos. If in doubt, please feel free to check.

But onto your specific issues:

Firstly, when you note that you included:

if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) {
    $_SERVER['HTTP_HOST'] = 'wp-cli.org';
}

I'm pretty sure that where you have wp-cli.org, you should actually have the domain of your WordPress server! If I understand correctly, using wp-cli.org will make it think that your server is available via http://wp-cli.org !

Secondly, I'm not sure if you have been using Webmin "Command Shell" for all of your previous attempts, but my suspicion is that is part of your issue! I would encourage you to not use that other than specific single commands. E.g. in this instance either use:

wp gf form list --allow-root --path=/var/www/wordpress

or

cd /var/www/wordpress && wp gf form list --allow-root

I.e. so everything you are doing is contained in a single line.

Ideally I suggest that you use an SSH client to connect to your server so that you get a proper terminal. If you're on Windows, PuTTY is a fairly well known SSH client and should hopefully be pretty straight forward to install and set up (and google should help you out if you have issues with it). If you're on MacOSX (or Linux) then simply open a terminal and type ssh root@<SERVER_IP_OR_FQDN> (replace <SERVER_IP_OR_FQDN> with your actual server IP or domain name).

Alternatively you could use Webshell (available via https on port 12320 - i.e. the same as Webmin, but port 12320 instead of 12321). IMO a proper SSH client is preferable (e.g. copy paste works much better) but Webshell will be better than Webmin "Command shell" for your purposes.

Thirdly, the Apache user in TurnKey (same as Debian and Ubuntu) is www-data. So to change ownership (i.e. chown) your WordPress directory so it is owned by the Apache user (as I assume the command you note is doing) is:

chown -R www-data:www-data /var/www/wordpress
faurmic's picture

Hi Jeremy,

 

Thanks for your reply and the infos.

Was aware about Debian but still don't have a lot of knowledge about users management.

 

Started from a previous snapshot of my wordpress install (before all manipulations from the webshell). And did the following (also from the webshell on 12320) exactly in this order :

wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

chmod +x wp-cli.phar

mv wp-cli.phar /usr/local/bin/wp

Deleted (only the first 2 lines keeping the followings as they're the same) from wp-config.php :

define('AUTH_KEY', 'bc67acd50f01671e647338cb172a178a147345862f38787d08e12cc1a26cd70d');
define('AUTH_SALT', '978a6fe49f097b9905f35ff497660bab8e9410f2115b55fa57262a28006f3fac');

Added to wp-config.php :

if ( defined( 'WP_CLI' ) && WP_CLI && ! isset( $_SERVER['HTTP_HOST'] ) ) {
    $_SERVER['HTTP_HOST'] = 'http://192.168.1.96';
}

Ran (still from webshell:12320) :

chown -R www-data:www-data /var/www/wordpress

Then tried :

cd /var/www/wordpress && wp gf form list --allow-root

But still no output...

 

 

 

 

 

faurmic's picture

Forgot to mention :

  • yes as I was already in www/wordpress/ the cd /var/...  in the last command was unnecessary ;
  • could'nt get any output with : wp plugin install gravityformscli --activate so I installed it via the plugin manager.

Add new comment