At first sight this sounds ridiculous. In fact it sounds absurd. But it’s not, if you heard of the new Microsoft feature — Bash on Ubuntu on Windows.
Windows 10’s Anniversary Update offered a big new feature for developers: A full, Ubuntu-based Bash shell that can run Linux software directly on Windows. This is made possible by the new “Windows Subsystem for Linux” Microsoft is adding to Windows 10.
In this post, I will setup fully functional WordPress installation with WP-CLI on top of LAMP server which will be installed on my Linux Subsystem through Windows 10.
Let’s do this!
First we need to install Bash on Ubuntu on Windows
LAMP stack is the next task
WordPress requires PHP, MySQL and HTTP server. We can go with Apache, so LAMP toolset is all we need. This command will install PHP, MySQL and Apache in a moment:
$ sudo apt-get install lamp-server^
When we have our server ready we can start with the fun part — installing our command-line interface for WordPress
Note that you must have PHP 5.3.29 or later and the WordPress version 3.7 or later.
Download the wp-cli.phar file via curl:
$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Now lets check, if it is running:
$ php wp-cli.phar --info
To use WP-CLI from the command line by typing wp, make the file executable and move it somewhere in your PATH. For example:
$ chmod +x wp-cli.phar
$ mv wp-cli.phar /usr/local/bin/wp
Check, if it is working:
$ wp --info
If everything went okay, you should see something like this:
$ wp --info PHP binary: /usr/bin/php5 PHP version: 5.5.9-1ubuntu4.14 php.ini used: /etc/php5/cli/php.ini WP-CLI root dir: /home/wp-cli/.wp-cli WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/ WP-CLI global config: /home/wp-cli/.wp-cli/config.yml WP-CLI project config: WP-CLI version: 0.23.0$
Run our local WordPress installation
Аfter we have our environment and tools ready, playing with the WP-CLI makes the new local WP installation a few commands away.
$ cd ../var/www/html
This is where our WP will live. Remove the default
index.php file. Also, now is a good time to start our Apache and MySQL services:
$ rm index.html
$ service apache2 start
$ service mysql start
Let’s download our WP core files:
$ wp core download
This will download the latest version of WordPress in English (
en_US). If you want to download another version or language, use the
--locale parameters. For example, to use the Bulgarian localization and 4.2.2 version, you would type:
$ wp core download --version=4.2.2 --locale=bg_BG
Once the download is completed, you can create the
wp-config.php file using the
core config command and passing your arguments for the database access here:
$ wp core config --dbname=databasename --dbuser=databaseuser --dbpass=databasepassword --dbhost=localhost --dbprefix=prfx_
This command will use the arguments and create a
wp-config.php file. Using the db command, we can now create our datebase:
$ wp db create
This command will use the arguments from
wp-config.php and do the job for us. Finally, to install WordPress, use the
core install command:
$ wp core install --url=example.com --title=WordPress Website Title --admin_user=admin_user --admin_password=admin_password [email protected]
If you’ve got your success message, restart Apache:
$ service apache2 restart
After the restart is completed, open your browser and type http://localhost/ and enjoy your brand new WP installation.
Note that every time you start the application you must first start up MySQL and Apache services:
$ service mysql start|restart|stop
$ service apache2 start|restart|stop
I like WP-CLI a lot for saving me time in doing boring stuff, but this may seems as a workaround and it probably is. Still, nothing compares to a real Linux environment.
But let’s face the fact we are running native Linux software on Windows. That by itself is fantastic. The benefits are unlimited.
Keep in mind that the Bash on Ubuntu on Windows feature is still in beta, so let’s hope that Microsoft will keep up with the good news.
Please, share and comment in the section below for your opinion.