Install WordPress on a Ubuntu Virtual Machine using VirtualBox

Web Design & Development
This entry is part 1 of 4 in the series WordPress Development Environment.

Installing WordPress

To install WordPress, we’ll first need to configure our network, then we’ll install the web server software to run WordPress, and finally we’ll install and configure WordPress itself. Let’s get started!

  1. First, right-click on the icon that looks like two computer screens near the bottom right corner and select “Network Adapters.”

    VirtualBox Network Icon
    The network icon gives you access to the VM's network settings
  2. In the Network Adapters window, change the Attached to option to “Bridged Adapter.” Select your network adapter in the Name drop-down menu and click OK.

    Network Adapters window
    Select "Bridged Adapter" in the Network Adapters window
  3. Now open Firefox and browse to “www.apachefriends.org/en/xampp-linux.html.” Download the latest version of XAMPP for Linux (as of this writing version 1.7.3a). If asked, saveit instead of opening it.
    Download XAMPP for Linux
    Download XAMPP for Linux

    Download window
    When prompted, save XAMPP for Linux to the Downloads folder
  4. Once the download is complete, close Firefox, then open up a terminal (Applications > Accessories > Terminal).

    Open a terminal
    Open a terminal
  5. In the terminal, type “sudo tar xvfz Downloads/xampp-linux-1.7.3a.tar.gz -C /opt” and press Enter. Be sure to use the version number of your download (it may not be 1.7.3a).

    Install XAMPP
    Type "sudo tar xvfz Downloads/xampp-linux-1.7.3a.tar.gz -C /opt" to install XAMPP for Linux
  6. You’ll need to enter your password to run the installation.

    Enter password
    Enter your password to continue
  7. The installation will run for a few moments. You should see this when it is complete:

    XAMPP installation complete
    XAMPP installation complete
  8. Now we can start XAMPP. Type “sudo /opt/lampp/lampp start” to start the XAMPP server. You’ll need to do this each time you start up the VM.

    Start XAMPP
    Type "sudo /opt/lampp/lampp start" to start the XAMPP server
  9. Now we can test if the server is running. Find the IP address of the VM by going to System > Administration > Network Tools.

    Open Network Tools
    Open Network Tools in the Administration menu
  10. Select “Ethernet Interface” from the Network devicedrop-down menu. The IPv4 address is the one we want for now. It will most likely be “192.168.1.10x” or similar.

    Network Tools window
    Get the IPv4 address
  11. Now minimize the VirtualBox VM window and open a web browser on your host OS. Type the IP address of the VM into the address bar and press Enter. You should see the XAMPP start screen:

    XAMPP start screen
    The XAMPP start screen should appear
  12. Now we can restore the VM window and open Firefox. Type “localhost” into the browser to get to the same XAMPP start screen. Click on your language to continue.

    XAMPP start screen on VM
    Type "localhost" to view the XAMPP start screen on the VM
  13. We need to set up a MySQL database for WordPress to use. Click on the “phpMyAdmin” link on the left side of the page.

    XAMPP for Linux
    Click the "phpMyAdmin" link
  14. Select “utf8_unicode_ci” in the MySQL connection collation drop-down menu, then enter “wordpress” into the Create new database field. In the drop-down menu to the left of where you just typed in “wordpress”, select “utf8_unicode_ci” again. Then click the Create button.
    Create database
    Create a new database for WordPress

    Database created
    This screen will appear when the database is successfully created
  15. Now that the MySQL database is ready, go to “http://wordpress.org/download/” in Firefox and download WordPress. Because this is Ubuntu, we need the “.tar.gz” file, not the “.zip” file (it’s the link under the Download WordPressbutton).

    WordPress Download page
    Download the ".tar.gz" file
  16. Once the download is complete, open the Places menu and click on “Downloads.”

    Places menu
    Open Downloads from the Places menu
  17. Double-click on the wordpress tar.gz file to open it.

    Open WordPress
    Open the wordpress tar.gz file
  18. Minimize the window (we’ll come back to it shortly). Now we need to open the file manager with root access. Open a terminal and type “gksudo nautilus” then press Enter. You’ll need to enter your password. Once you do, the file manager will open.

    Open file manager with root access
    Type "gksudo nautilus" to open the file manager with root access
  19. Click on “File System” in the left pane, then open opt > lampp.

    File manager root
    Click on "File System" on the left, then open the "opt" foder and the "lampp" sub-folder
  20. Right-click on the htdocs folder and select “Properties.”

    lampp folder
    Open the htdocs Properties window
  21. In the Permissions tab, set the Owner at the top of the Properties window to your username, then set all of the Folder access fields to “Create and delete files” to ensure that you can edit all files while developing. Click on the Apply Permissions to Enclosed Filesbutton and then close the Properties window.

    htdocs Permissions window
    Set the permissions for the htdocs folder
  22. Double-click on the htdocs folder to open it. Now restore the wordpress tar.gz file window that we minimized a few moments ago, then drag and drop the wordpress folder into the htdocs folder.

    Drag and drop wordpress folder
    Drag and drop the wordpress folder into the htdocs folder
  23. Once the wordpress folder has been copied over, open the Properties window for it and set the permissions to the same settings that we used previously for the htdocs folder. Click the Apply Permission to Enclosed Filesbutton and close the Properties window.

    wordpress folder Permissions
    Set the Permissions for the wordpress folder
  24. Now we need to set up the WordPress configuration file so WordPress can use the MySQL database that we created earlier. Open the wordpress folder, right-click on the wp-config-sample.php file and select “Open With Text Editor.”

    Open wp-config-sample.php
    Open the wp-config-sample.php file with the text editor
  25. Scroll down to the MySQL settings section and modify the DB_NAME, DB_USER, and DB_PASSWORD settings as follows (the password is empty because we did not specify one when we created the MySQL database; this is OK for development purposes, but it should never be blank for a production server):
    Text editor
    wp-config settings
    // ** MySQL settings - You can get this info from your web host ** //
    
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'root');
    
    /** MySQL database password */
    define('DB_PASSWORD', '');
  26. Save the changes as a newfile called “wp-config.php” and close the text editor.

    wp-config Save As...
    Save the changes as "wp-config.php"
  27. Now open Firefox and navigate to “http://localhost/wordpress/wp-admin/install.php” to run WordPress’ famous five minute installation.

    WordPress installation
    Start the WordPress installation by going to "http://localhost/wordpress/wp-admin/install.php"
  28. Fill out the information on the page and click Install WordPress.

    WordPress Installation information
    Enter the necessary information on the installation page
  29. The installation should only take a moment. When it’s finished, click Log In.

    WordPress installation complete
    Once the installation completes, click the Log In button
  30. This will bring you to the WordPress login page. Enter the username and password you created on the previous installation page (I used “admin” and “password” because those are easy to remember) and click Log In.

    WordPress login page
    Enter your username and password to login
  31. You should now see the WordPress dashboard. Congratulations, your WordPress development site is now running on your VM!

    WordPress dashboard
    WordPress is now up and running on your VM
  32. Now that everything is installed and configured, take a moment to create another snapshot of the VM so you can always revert it to its current state.
  33. As a final reminder, remember that the security on this system is planned with a development environment in mind – don’t make this system accessible from the Internet!

 

Conclusion

From this point on you can start developing within your VM by using it’s built-in text editor or installing a third-party editor (you can find many by searching the Ubuntu Software Center; access it from the Applications menu). In a future post I’ll go over some additional tips and tricks so you can leave your VM window minimized and do all of your actual development using your host OS.

I hope this post is helpful for anyone who wants to use a VM and create a WordPress development server, or even anyone interested in trying out Ubuntu. Keep in mind that this process can be adapted to install other content management systems such as Drupal or Joomla if you want to try those out as well. If anyone has any other tips or ideas on using a VM to set up a development server, post them in the comments below!

Special thanks to Justin over at Chop Shop for editing and contributing to this post.

Pages: 1 2 3 4


Comments

  1. Great tutorial, thanks - I've done the same with VMWare server 1 and later.... the thing that always gets me is when I set Wordpress to permanent links - it messes everything up!
  2. [...] This entry is part 4 of 4 in the series WordPress Development EnvironmentI do most of my WordPress development using a test environment that I installed on a Ubuntu Virtual Machine (VM). This let’s me play around as much as I want without any risk to my production website or my computer; everything is contained within the VM, and it costs me nothing because I only use open-source and/or free software (read about it at http://wp.me/p1iF71-4x). [...]
  3. I can recommend VirtualBox, since it is completely free and it offers pre-configurations for nearly all OS's. One thing you have to care about, maybe, is the netowrking-settings, since this stuff really *may* influence the internet-speed of the guest system, but you can fix this. Regards

Comments are closed