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.
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.