How to Run WordPress Locally in a VirtualBox VM
In this tutorial, you will learn how to install and run a WordPress website on your local computer from a virtual machine. Not only will this tutorial show you how to setup WordPress locally, but also how to configure an Nginx server, PHP, and MariaDB database for a complete LEMP server on Ubuntu.
Don’t have a virtual machine yet? Check out this video tutorial to set up an Ubuntu VM for free.
This blog post accompanies the following video tutorial.
1. Install LEMP Server
First, install the Nginx web server, MariaDB (a MySQL server package), and PHP.
2. Enable Port Forwarding in VirtualBox
To be able to access the VM’s web server from your local computer, we must open port 80 which is the HTTP port. We can do this in the VM’s settings in VirtualBox under Network > Advanced > Port Forwarding. For the TCP protocol, set the Host Port and Guest Port to 80.
3. Install WordPress
Get the latest version of the official WordPress package and extract it in
with the appropriate permissions and ownership.
4. Database Setup
Secure your MySQL installation with the mysql_secure_installation command, accepting the defaults for all prompts. Give the MySQL root user a strong password.
Access the MySQL console where you can issue MySQL commands directly. Use the password that you just created to login when prompted.
Create a database and user for WordPress. Pick an appropriate username, strong password, and database name.
5. Configure the Nginx Web Server
Nginx configuration files are stored at
, so let’s go there.
Confirm the version of PHP FPM that your system is running. You will need this information when creating the Nginx config file next.
In my case, I am running PHP 8.1, so I will specify this in my new Nginx config file at
.
Create a symbolic link from
to
to enable this Nginx configuration. Then test the configuration and restart the Nginx server to apply the changes.
6. Set Up WordPress
In a web browser on your local computer, go to http://localhost and finish the WordPress setup. Part of this is telling WordPress about the MariaDB that we set up earlier in this tutorial.
Now you have a fresh WordPress installation. You can access your site at http://localhost and your WordPress admin console at http://localhost/wp-admin where you can design your website.
As you are getting your website ready for the public, make sure you do these 15 important things after installing WordPress.
0 Comments
If you have any doubts,please let me know