WordPress on Ubuntu

I need to run a local installation of WordPress so I can dig deep into my WordPress learning and not crash a live site. Getting WordPress up and running took me way longer than it should have, so I am documenting my steps to hopefully save someone else all the aggravation I had since starting down this path. WordPress is installed on a LAMP stack so if you don’t already have a LAMP stack see my blog post LAMP on Ubuntu.

  • Start by opening the terminal (CTRL+ALT+T) and typing the following commands.
  • The first step ins setting up a database with some mySQL commands in MariaDB. The following will set up the database up as follows:
    • Database Name: wp_sandbox
    • Database User: wpkarl
    • Password for wpkarl: wpkarl123
  • $ sudo mysql -u root -p Note: Use the MariaDB password.
    • create database wp_sandbox;
    • grant all privileges on wp_sandbox.* to ‘wpkarl’@’localhost’ identified by ‘wpkarl123’;
    • flush privileges;
    • exit;
  • The next step is to download WordPress to the /tmp directory
  • $ cd /tmp
  • $ wget -c https://wordpress.org/latest.tar.gz
  • The tar file is 15.4 MB. The next step will decompress the file
  • $ tar -xvzf latest.tar.gz
  • The decompression created a wordpres folder with 2,457 items, totaling 53.1 MB. Files sizes and numbers may vary. I am just listing them here to detail what is happening.
  • $ sudo mv wordpress/ /var/www/html/wordpress
  • $ sudo chown -R www-data /var/www/html/wordpress
  • $ sudo chmod 755 -R /var/www/html/wordpress
  • $ cd /etc/apache2/sites-available
  • $ dir — check existing files
  • $ sudo cp 000-default.conf wp_sandbox.conf
  • $ sudo nano wp_sandbox.conf
  • Modify the wp_sandbox.conf as follows:
    • DocumentRoot websites/var/www/html/wordpress
    • ServerName wp_sandbox.com
    • Add line “ServerAlias www.wp_sandbox.com
    • “ServerAdmin” – can be updated – I am not since this is a local development sites
    • Add the following lines:
      • <Directory /var/ww/html/wordpress/”>
        • Options Indexes FollowSymLinks
        • AllowOverride all
        • Require all granted
      • </Directory>
      • note to exit CTL-X then Y
  • Enable the Virtualhost Note: the next command is a single line
  • $ sudo ln -s /etc/apache2/sites-available/wp_sandbox.conf /etc/apache2/sites-enabled/wp_sandbox.conf
  • Enable Apache’s rewrite module
  • $ sudo a2enmod rewrite
  • $ sudo systemctl restart apache2

WordPress should now be set up and ready to run. The final step is to access the WordPress setup and configure menu through a browser. Then follow the prompts to have a local version of WordPress running on Ubuntu.

Open a web browser and type in 127.0.0.1/wordpress/index.php into the search address search. This will start the installation process.

One final step is to update the hosts file so you can directly access the new site from your browser.

  • $ sudo /etc/hosts
  • add a line similar to the following to the file
    • 127.0.0.1 www.wp_sandbox.com

Please contact me with any comments or questions.

karl@karlsclipboard.com