Set up WordPress on Single instance EC2 in Ubuntu


If you have not setup your EC2 yet, please go to https://www.teachonetofish.net/setup-ubuntu-ec2-in-aws/

Update OS

sudo su -
apt -y update
apt -y upgrade

Install Apache, PHP, MySQL

apt -y install apache2 php8.1
apt -y install mysql-server
mysql -uroot
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'P@ssw0rd';
flush privileges; 
exit;
/usr/bin/mysql_secure_installation

Install PHP and library

apt -y install php8.1 php8.1-mysql
apt -y install php8.1-curl php8.1-mbstring
service apache2 restart

PHPinfo

vi /var/www/html/phpinfo.php

On your keyboard type i to change to insert mode. Type the following PHP code.

<?php
phpinfo();

Press “Esc” key, then type “:wq” -> enter

Open browser and check your PHP. “http://your-ip-address/phpinfo.php”

Setup Database

mysql -uroot -p

Type your MySQL password

create database wordpress;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
exit;

Install WordPress

cd
wget https://wordpress.org/wordpress-6.0.tar.gz
tar zxvf wordpress-6.0.tar.gz
mv wordpress /var/www/html
chown -R www-data.www-data /var/www/html

Setup WordPress

In your browser, open URL

http://your-ip-address/wordpress/

Setup your admin user and password.

All done!

WordPress Admin page

http://your-ip-address/wordpress/wp-admin

, , ,