Today you will configure a Linux user for managing WordPress, configure SSH access using authorized_keys, install MySQL, create a database for WordPress, and configure directory permissions so Apache (www-data) can write to the WordPress directory.
Create a new system user for managing the WordPress server.
sudo adduser wordpress
Add the user to the sudo group.
sudo usermod -aG sudo wordpress
Verify the user is in the sudo group.
groups wordpress
Create the SSH directory.
sudo mkdir /home/wordpress/.ssh
Set the correct permissions.
sudo chmod 700 /home/wordpress/.ssh
Create the authorized_keys file.
sudo nano /home/wordpress/.ssh/authorized_keys
Paste your public SSH key into the file.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCexamplekey student@laptop
Set proper permissions on the file.
sudo chmod 600 /home/wordpress/.ssh/authorized_keys
Set ownership.
sudo chown -R wordpress:wordpress /home/wordpress/.ssh
sudo apt update sudo apt install -y mysql-server
Enable and start the MySQL service.
sudo systemctl enable mysql sudo systemctl start mysql
Verify it is running.
sudo systemctl status mysql
sudo mysql_secure_installation
Recommended settings:
Login to MySQL.
sudo mysql
Create the database.
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
Grant permissions.
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX ON wordpress.* TO 'wp_user'@'localhost';
Apply changes and exit.
FLUSH PRIVILEGES; EXIT;
Set ownership to Apache.
sudo chown -R www-data:www-data /var/www/html/wordpress
Set directory permissions.
chmod -R 775 /var/www/html/wordpress
mysql -u wp_user -p
Inside MySQL:
SHOW DATABASES; USE wordpress; SHOW TABLES; EXIT;
Submit the following:
End of Day 3 Deliverable