Lab 5: Wordpress
Objective
To get experience installing and configuring more complex software.
Task
For this lab you will install the Wordpress content management system. A CMS is software that lets you create and manage a website. You'll need to follow these steps to do this:
- Install a LAMP stack. This acronym stands for Linux, Apache, MySQL (or MariaDB) and PHP (or Python or Perl).
We already have Linux and Apache setup, so we'll just need the latter two.
- Install the
mariadb-serverandmariadb-clientpackages. Then make sure the MariaDB service is started and enabled. - Run
sudo mysql_secure_installationwhich will configure the database system, including setting the root password. MariaDB has its own root password which is separate from the Linux one. Make sure you remember what you pick. - Install PHP with the following packages (most of which are libraries that Wordpress
requires):
php libapache2-mod-php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath. - Enable PHP with Apache:
sudo a2enmod php8.2. - Verify PHP is working with Apache by putting the code
<?php phpinfo(); ?>into the file/var/www/html/test.php, and then navigating to your IP address with "/test.php" on the end in a web browser. You should see a page with PHP info on it. - Remove the test.php file as it was just for testing purposes.
- Install the
- Setup the databases needed for Wordpress:
- Run
mysql -u root -pand enter your database root password. You should be at a MariaDB prompt. Enter the following commands at the shell: CREATE DATABASE wp_database;CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword';(replacing the password of course).GRANT ALL ON `wp_database`.* TO `wpuser`@`localhost`;FLUSH PRIVILEGES;- Exit the database shell
- Run
- Download Wordpress from https://wordpress.org/latest.tar.gz into your home directory.
- Decompress the tar-ball, which will make a directory called
wordpressin your home directory. - Make sure
/var/www/htmlis empty. If there's anything there, delete it. - Move all of the files in this
wordpressdirectory into/var/www/html/. We can now remove the empty wordpress directory in our home, and the .tar.gz file. - Set the owner of all of these files to
www-data. - Ensure that all of the permissions in
/var/www/htmlare correct. The files should be 644 and the directories should be 755. If something isn't readable, the website will not be accessible. - Copy the
wp-config-sample.phpfile towp-config.php. - Open up the file and put in the following info we setup with MariaDB:
- Put in
wp_databaseDB_NAME - Put in
wpuserfor DB_USER - Put in the password you set for this user in for DB_PASSWORD
- Put in
- Load your IP address in your web browser. You should see a Wordpress welcome page asking for your site title, email and so on. Put in whatever you want and click the Install Button.
- Login with the info you just setup. You should be at the Wordpress dashboard!
Submitting
Take a screenshot of the Wordpress dashboard with your IP address visible in the screenshot, and submit it in Canvas for this lab.