1

I've installed php5-cli using bash, but Wordpress is using XAMPP's PHP 7 install. I've added /mnt/c/xampp/php to the PATH, and I've explicitly used export WP_CLI_PHP='/mnt/c/xampp/php' in .bashrc.

But when I do wp --info, I get:

PHP binary:     /mnt/c/xampp/php/php.exe
PHP version:    5.5.9-1ubuntu4.22
php.ini used:   /etc/php5/cli/php.ini

PHP binary seems correct, but the last two variables refer to PHP 5.

  • Good question! But I think you should change your title to something like "WP-CLI on Windows 10 using WSL with Windows PHP/MySQL". But yes, what you are trying to do would be ideal! It would be great to be able to use Ubuntu / Bash where all the WP-CLI commands work properly, but have the ease of being able to use Windows based PHP/MySQL like that from XAMPP rather than having to install all those on your WSL. – Trevor Aug 31 '18 at 8:50
1

Actually, I figured out how to do this, and it's actually really easy to do! Which is awesome because I think it's a great simple way to work!

First up, you don't want to change the PATH for PHP in bash. So you'll want to remove that. Instead, what you are doing is using bash based PHP and MySQL, but connecting to your Windows MySQL (installed by XAMPP).

Step 1:

sudo apt install mysql-client php-cli php-mysql

Step 2:

Create a symlink in bash to your website files, so something like this: sudo ln -s /mnt/c/websites /var/www

Step 3:

You need to connect to you MySQL db with an IP address, not localhost. So when creating your config do something like this:

wp config create --dbname=wpdbname --dbuser=wpdbuser --dbpass=securepswd --dbhost=127.0.0.1

If you want more info, I also wrote a blog post about this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.