Install and Configure PHP, MySQL, WordPress

In this lesson, we’ll install WordPress; and PHP and MySQL on which it depends.

NOTE: a soundless video is posted at the end that shows an end-to-end of each step.

PHP

Run the following command to install PHP:

sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd php-pear

Let’s confirm it’s working correctly.  Create a text file called info.php and put it in the root of your general localhost web site:  /var/www/html/info.php. The file should have the following content:

<?php phpinfo(); ?>

Let the web server serve up the file. Using your browser navigate to: http://localhost/info.php If configured correctly, you should see something like this:


MySQL

From the terminal window, run:

sudo apt-get install mysql-client mysql-server mysql-workbench

This will install mysql and the GUI workbench tool, that you’ll probably find helpful.  Note, you can secure mysql using:

sudo mysql_secure_installation

However, for our development box, we’ll leave it pretty much open so we can recover if we make a booboo.

Start up the MySQLWorkbench and click on the server status button to confirm that MySQL is up and running.

Before we move on, we need to restart Apache to pick up these changes:

sudo systemctl restart apache2.service

WordPress

We are now ready to install wordpress.  Since we have MySQL and PHP installed, we really don’t have anything to install so let’s just copy down the wordpress files and copy them where we want to use them.

  • Go to the wordpress download site and download the latest release.
  • Extract the files.  I like to use the graphical Nemo File Explorer.  Just navigate to the downloaded file and select Extract from the menu
  • Copy all of the files and folders from the extracted /wordpress folder to your local wordpress site.  You can use Nemo; or just use the terminal.  Navigate inside the extracted new wordpress folder and issue the following command:sudo cp -R * /var/www/wordpressweb/
  • Before we attempt to open the new site with our browser, we need to give the folder and files permissions.  Execute the following to do that:sudo chown -R www-data:www-data /var/www/wordpressweb/
    sudo chmod -R 755 /var/www/wordpressweb/
  • Open the WordPress readme file: http://mywordpressweb.local/readme.html  from your Mint VM.  As you can see, there is the “Famous 5-minute install” which we will use.  But first, we need to create an empty database and user and password.
  • Open MySQLWorkbench, and click on the Create new Schema icon from the icon bar at the top
  • Name your new wordpress database (I called mine TestWordpress) and I suggest you put in the UTF-8 default collation
  • We now need to create a user who can access the database.
    • From MySQLWorkbench, select the Users and Privileges option in the upper left panel
    • Add Account button in the lower panel
    • Key in a Login Name (“TestWpUser”)
    • Standard Authentication
    • Limit to Hosts Matching (“localhost”)
    • Password (“password”).  
  • Press the Schema Privileges tab and then the Add Entry button
  • In the popup dialog, tick the Selected schema: option button and select our new database:  TestWordpress.  Press the OK button
  • Back at the previous screen, press the Select “ALL” button and then press the Apply button.
  • Now that we have our database, user, and password, we are ready to use the 5 minutes install.  Go back to the browser window and press the Let’s go button.
  • Enter the appropriate values for our new db, user, and password and press Submit and then the Run Install button.
  • In the next page, answer the questions (MyFirstWordpress, wpAdmin, wpPassword) and then press the InstallWordPress button.
  • After you login, you should see your Welcome to WordPress page.  Congratulations!
Conclusion

In this post, we installed the components we needed to support WordPress:  MySQL, MySQLWorkbench, and PHP and then we installed WordPress.  In the next lesson, we’ll show how to create a child theme and to use it to support jQuery.  We’ll then install Netbeans and Tomcat and show how we can use jQuery to make AJAX calls to a web server.

For an end to end, follow this vid:

NOTE: there is no commentary or sound in this video.

Leave a Reply

Your email address will not be published. Required fields are marked *