WordPress is the most popular content management system in use today. It’s an open-source platform and works great in Linux systems, including Ubuntu. If you’re running Windows and want to use WordPress, using Windows with WSL 2 might be your best option and the steps below will show you how to do that. With WSL, you can install a full Linux operating system inside Windows. So get Windows, enable WSL, install a Linux OS and run WordPress. Back in 2017, Windows released the original WSL version. WSL 2 is an improvement over version 1 and comes with a performance boost, and full system call compatibility, and is built with a new architecture that delivers features that make WSL an amazing way to run a Linux environment in Windows. If you have a machine that meets the requirements above to run WSL 2, then continue below. To get started with running WordPress on Windows with WSL, follow the steps below:
Enable WSL in Windows
To enable WSL in Windows, you will want to open the PowerShell terminal as administrator. Click on Start then begin typing PowerShell. Next, right-click the Windows PowerShell app and choose to run as administrator. When the console opens, run the commands below: After installing, you should get a success message similar to the lines below:
Enable Virtual Machine Platform
WSL 2 requires Windows 10 Virtual Machine Platform to be enabled. This is not Hyper-V. To enable the VM platform feature in Windows, run the commands below from the same PowerShell administrator’s console. If you’re using Windows 10 version lower than 2004, then use the commands below: When you’re done running the commands above, restart your computer for all the configuration changes to apply. If you don’t restart, the below command might not be recognized. After restarting your computer, login back in and launch PowerShell as administrator. Then run the commands below to configure WSL 2 as the default version of WSL.
Install Ubuntu on Windows 10
Now that WSL 2 is installed and ready to be used, open the link below to download and install a copy of Ubuntu 20.04 from the Windows store. Get Ubuntu 20.04 LTS – Microsoft Store Ubuntu 20.04 LTS on Windows allows you to use Ubuntu Terminal and run Ubuntu command line utilities including bash, ssh, git, apt, and many more. Click the Get button and install. After installing Ubuntu, you’ll want the option to launch Ubuntu from the Windows WSL environment. After launching Ubuntu, it should install and prompt you to create your account. That should do it! Some troubleshooting commands to run when you run into the issues above. These run below and try to launch the Ubuntu image again. Now that Windows 10 WSL environment is ready, continue below to install Nginx, MariaDB, and PHP and configure WordPress to run.
Install Nginx HTTP Server
WordPress requires a web server to function, and Nginx is one of the most popular open-source web servers available today. To install Nginx on Ubuntu, run the commands below: After installing Nginx, the commands below can be used to stop and start Nginx services. To test whether Nginx is installed and functioning, open your web browser and browse to the server’s IP address or hostname. http://localhost If you see the above page in your browser, then Nginx is working as expected.
Install MariaDB Server
You’ll also need a database server to run WordPress. A database server is where WordPress content gets stored. A truly open-source database server that you can use with WordPress is the MariaDB database server. It is fast, secure and the default server for almost all Linux servers. To install MariaDB, run the commands below: After installing MariaDB, the commands below can be used to stop, start and enable the MariaDB service always to start up when the server boots. Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation. When prompted, answer the questions below by following the guide.
Enter current password for root (enter for none): Just press the Enter Set root password? [Y/n]: Y New password: Enter password Re-enter new password: Repeat password Remove anonymous users? [Y/n]: Y Disallow root login remotely? [Y/n]: Y Remove test database and access to it? [Y/n]: Y Reload privilege tables now? [Y/n]: Y
To verify and validate that MariaDB is installed and working, log in to the database console using the commands below: type the root password when prompted. If you see a similar screen as shown above, then the server was successfully installed.
Install PHP and Related Modules
WordPress is a PHP-based application, and PHP is required to run it. Run the commands below to install PHP and related modules to support WordPress. After installing PHP, go and configure some basic settings that may be required for WordPress to function properly. For this tutorial, PHP 7.4 was installed. Based on your environment, another version of PHP might be installed. So verify that. Below are good settings to configure for most WordPress websites. That should get PHP 7.4 installed with some basic settings to allow WordPress to function. After setting up PHP, the command below can be used to stop and start PHP7.4 services.
Create WordPress Database
When all the servers are installed above, it’s now time to begin setting up the WordPress environment. First, run the steps below to create a blank database for WordPress to use. Login to the MariaDB database console using the commands below: Then create a database called wpdb Next, create a database user called wpdbuser and set a password Then grant the user full access to the database. Finally, save your changes and exit.
Download WordPress
At this point, WordPress is ready to be downloaded and installed. Use the commands below to download the latest version of WordPress. Then run the command below to allow the www-data user to own the WordPress directory.
Configure the Nginx Server block
Below is where you configure the Nginx VirtualHost file for the WordPress site you’re creating. This file defines how client requests are handled and processed. Run the commands below to create a new VirtualHost file called WordPress in the /etc/Nginx/sites-available/ directory. A very good configuration setting for most WordPress sites on the Nginx server is below. This configuration should work great. Copy the content below and save it into the file created above. Save the file and exit. After saving the file above, run the commands below to enable the new site, then restart the Nginx server. At this stage, WordPress is ready and can be launched by going to the server’s IP or hostname. That should bring up the WordPress setup wizard. Type in the database connection and continue Create a WordPress admin account and password, then click Install WordPress Log in with the account above and you’re done. That’s it! Conclusion: This post showed you how to install WordPress on Windows 10 with Ubuntu. If you find any error above, please use the comment form below to report.