> For the complete documentation index, see [llms.txt](https://paul-gleason.gitbook.io/champlain-college-classes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://paul-gleason.gitbook.io/champlain-college-classes/sys-360-cloud-admin/labs/lab-5-3-setting-up-wordpress-on-lamp.md).

# Lab 5-3: Setting up WordPress on LAMP

## Install WordPress: <a href="#install-wordpress" id="install-wordpress"></a>

Download the latest WordPress installation package with the **wget** command. The following command should always download the latest release.

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

Unzip and unarchive the installation package. The installation folder is unzipped to a folder called `wordpress`.

```
tar -xzf latest.tar.gz
```

Log in to the database server as the `root` user. Enter your database `root` password when prompted; this may be different than your `root` system password, or it may even be empty if you have not secured your database server.

```
mysql -u root -p
```

Create a user and password for your MySQL database. Your WordPress installation uses these values to communicate with your MySQL database. Enter the following command, substituting a unique user name and password.

```
CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'your_strong_password';
```

Create your database. Give your database a descriptive, meaningful name, such as `wordpress-db`.

```
CREATE DATABASE `wordpress-db`;
```

Grant full privileges for your database to the WordPress user that you created earlier.

```
GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"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 sample file intact as a backup.

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

Edit the `wp-config.php` file with your favorite text editor (such as **nano** or **vim**) and enter values for your installation. If you do not have a favorite text editor, `vi` is suitable for beginners.

```
vi wordpress/wp-config.php
```

<figure><img src="/files/CWOQ8bXaLr2rNvUPXe62" alt=""><figcaption></figcaption></figure>

Find the section called `Authentication Unique Keys and Salts`. These `KEY` and `SALT` values provide a layer of encryption to the browser cookies that WordPress users store on their local machines. Basically, adding long, random values here makes your site more secure. You can create unique values by visiting [https://api.wordpress.org/secret-key/1.1/salt/ ](https://api.wordpress.org/secret-key/1.1/salt/)[  Links to an external site.](https://api.wordpress.org/secret-key/1.1/salt/)[ ](https://api.wordpress.org/secret-key/1.1/salt/)[  Links to an external site.](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. To paste text into a PuTTY terminal, place the cursor where you want to paste the text and right-click your mouse inside the PuTTY terminal.

<figure><img src="/files/ohqDv3aX5Nra4zShsNgi" alt=""><figcaption></figcaption></figure>

WordPress will run at your document root, socopy the contents of the wordpress installation directory (but not the directory itself) as follows:

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

Open the `httpd.conf` file with your favorite text editor (such as **nano** or **vim**). If you do not have a favorite text editor, `nano` is suitable for beginners.

```
sudo vim /etc/httpd/conf/httpd.conf
```

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

Note

There are multiple `AllowOverride` lines in this file; be sure you change the line in the `<Directory "/var/www/html">` section.

<figure><img src="/files/esvTNPBCiG3Rx7ftV44b" alt=""><figcaption></figcaption></figure>

#### **To install the PHP graphics drawing library on Amazon Linux 2:**

Use the following command to install the PHP graphics drawing library on Amazon Linux 2. For example, if you installed php7.2 from amazon-linux-extras as part of installing the LAMP stack, this command installs version 7.2 of the PHP graphics drawing library.

```
sudo yum install php-gd
```

To verify the installed version, use the following command:

```
sudo yum list installed | grep php
```

#### **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
```

**SUBMIT: Screenshot of Post-Install Wordpress Site.**

<figure><img src="/files/RbiqEd4fnV6VJUYFiy0T" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://paul-gleason.gitbook.io/champlain-college-classes/sys-360-cloud-admin/labs/lab-5-3-setting-up-wordpress-on-lamp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
