Lab 5 3: Setting up WordPress on LAMP - nicolas-tullio/Tech-Journal GitHub Wiki

Deliverables

Screenshot of Post-Install Wordpress Site

image

URL to your Wordpress Site

http://ec2-3-83-145-101.compute-1.amazonaws.com/wp-admin/

Steps

To download and unzip the WordPress installation package

Download the latest WordPress installation package with the wget command

wget https://wordpress.org/latest.tar.gz

Unzip and unarchive the installation package

tar -xzf latest.tar.gz

To create a database user and database for your WordPress installation

Start the database server

sudo systemctl start mariadb

Log in to the database server as the root user

mysql -u root -p

image

Create a user and password for your MySQL database

CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'PASSWORD';

Create your database

CREATE DATABASE wordpress-db;

Grant full privileges for your database to the WordPress user

GRANT ALL PRIVILEGES ON wordpress-db.* TO "wordpress"@"localhost";

Flush the database privileges to pick up all of your changes

FLUSH PRIVILEGES;

Exit the mysql client

exit

To create and edit the wp-config.php file

Copy the wp-config-sample.php file to a file called wp-config.php. This creates a new configuration file and keeps the original as a backup.

cp wordpress/wp-config-sample.php wordpress/wp-config.php

Edit the wp-config.php file

nano wordpress/wp-config.php

Define DB info

define('DB_NAME', 'wordpress-db');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'PASSWORD');

Find the section called Authentication Unique Keys and Salts. Create unique values by visiting (https://api.wordpress.org/secret-key/1.1/salt/) to randomly generate a set of key values that you can copy and paste into your wp-config.php file

image

Save file and exit

To install your WordPress files under the Apache document root

WordPress will run at your document root, so copy the contents of the wordpress installation directory

cp -r wordpress/* /var/www/html/

To allow WordPress to use permalinks

Edit the httpd.conf file

sudo nano /etc/httpd/conf/httpd.conf

Find the section that starts with <Directory "/var/www/html">

image

Change the AllowOverride None line in the above section to read AllowOverride All

Save the file and exit your text editor.

To install the PHP graphics drawing library on Amazon Linux 2

Install the PHP-gd

sudo yum install php-gd

To fix file permissions for the Apache web server

Grant file ownership of /var/www and its contents to the apache user

sudo chown -R apache /var/www

Grant group ownership of /var/www and its contents to the apache group

sudo chgrp -R apache /var/www

Change the directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories

sudo chmod 2775 /var/www find /var/www -type d -exec sudo chmod 2775 {} \;

Recursively change the file permissions of /var/www and its subdirectories to add group write permissions

find /var/www -type f -exec sudo chmod 0664 {} \;

Restart the Apache web server to pick up the new group and permissions

sudo systemctl restart httpd

To run the WordPress installation script with Amazon Linux 2

Use the systemctl command to ensure that the httpd and database services start at every system boot

sudo systemctl enable httpd && sudo systemctl enable mariadb

Verify that the database server is running

sudo systemctl status mariadb

image

Verify that your Apache web server (httpd) is running

sudo systemctl status httpd

image

In a web browser, type the URL of your WordPress blog

http://ec2-3-83-145-101.compute-1.amazonaws.com/wp-admin/install.php

Provide the information required by the WordPress installation. Choose Install WordPress to complete the installation

image