Task 02

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Task02: Setting Up a New WordPress

install and configure WordPress with Apache on your AWS environment.

Create AWS EC2 instance.

Log in to your AWS instance using SSH.

How To Install the Apache Web Server on AWS EC2 (Ubuntu 22.04)
install the apache2 package:

sudo apt install apache2

Make sure the service is active by running the command for the systemd init system:

sudo systemctl status apache2

Figure 1 service has started successfully.

When you have your server’s IP address, enter it into your browser’s address bar:
Figure 2 default webpage of Apache

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-
22-04
check this out more additional commands and configurations.
How to Install MySQL on Ubuntu 22.04
open the terminal.

sudo apt update && sudo apt upgrade

sudo apt-get install mysql-server

few minutes as the installation of the MySQL will take some time to complete

check the status of the “mysql” service using this command


systemctl is-active mysql

Configure MySQL server

sudo mysql_secure_installation

In the configuration manual, you will be first asked to set the level for the password validation
policy. Input a number from the given menu according to your password validation requirements

After doing so, type out the new password for “root” and enter “y” to continue with the provided
password

Also, set the other configuration options accordingly


After set the password you can login this command
sudo mysql -u root -p

Enter the password and login to your MYSQL server

https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-22-04

https://linuxhint.com/install-mysql-on-ubuntu-22-04/

now step up domain for your WordPress site , go to GoDaddy and create a new DNS record in
your site

Type : DNS record

NAME : Your Subdomain

DATA : The destination of the record - the value varies based on the record type.

TTL : The amount of time that DNS servers will wait before refreshing the record. Shorter TTLs
mean faster DNS updates in the future, and longer TTLs mean more resilience and higher
performance.

opsdemo.xyz is our Domain.

wordpress.opsdemo.xyz is our WordPress site.

here are the steps on how to host a WordPress site with Apache
Install and configure the necessary dependencies.

 Install Apache web server.

 Install PHP.

 Install MySQL database server.

Install PHP

sudo apt install php


Verify that PHP has been installed correctly by running the following command:

php -v

apt install php php-mysql

sudo apt install php libapache2-mod-php php-mysql

Install phpMyAdmin
phpMyAdmin is a web-based database management tool that you can use to view and edit the
MySQL databases on your EC2 instance

To install phpMyAdmin

Install the required dependencies.

sudo yum install php-mbstring php-xml -y

Restart Apache.

sudo systemctl restart httpd

Restart php-fpm.

sudo systemctl restart php-fpm

Navigate to the Apache document root at /var/www/html.

cd /var/www/html

Select a source package for the latest phpMyAdmin release


from https://www.phpmyadmin.net/downloads.

wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz

mkdir phpMyAdmin && tar -xvzf phpMyAdmin-latest-all-languages.tar.gz -C


phpMyAdmin --strip-components 1

Delete the phpMyAdmin-latest-all-languages.tar.gz tarball.

rm phpMyAdmin-latest-all-languages.tar.gz
Create WordPress Database

$ mysql -u root -p

CREATE DATABASE wordpress_db;

CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'password';

GRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost' IDENTIFIED BY 'password';

Great, now you can exit the database.

FLUSH PRIVILEGES;

Exit.

Create a database name and password as your wish.

Downloading WordPress
First, change into a writable directory (we recommend a temporary one like /tmp):

cd /tmp

Then download the compressed release with the following curl command:

curl -O https://wordpress.org/latest.tar.gz

Extract the compressed file to create the WordPress directory structure:

tar xzvf latest.tar.gz

sudo cp -a /tmp/wordpress/. /var/www/wordpress

Adjusting the Ownership and Permissions on Wordpress

sudo chown -R www-data:www-data /var/www/wordpress

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

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

Setting Up the WordPress Configuration File

Now, you need to make some changes to the main WordPress configuration file.
sudo nano /var/www/wordpress/wp-config.php

Next, You need to adjust the database name, the database user, and the associated password that
you configured within MySQL.

Figure 3 Save and close the file when you are finished.

Completing the Installation Through the Web Interface

In your web browser, navigate to your server’s domain name

WordPress is now installed and is ready to be used.

https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-22-04-
with-a-lamp-stack#adjusting-the-ownership-and-permissions

2.

A.

here are the steps to install MySQL and phpMyAdmin on Ubuntu 22.04 and create a
user/password
Update your system packages

Install the MySQL server

Start the MySQL serve

Set up a secure password for the MySQL root user

sudo mysqladmin -u root password 'password'

Replace password with a strong password that you will remember.

Create a new user for phpMyAdmin with appropriate privileges

sudo mysql -u root -p

Enter the password that you set for the MySQL root user in the previous step.

CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost';

FLUSH PRIVILEGES;

Exit MySQL:

Exit;

B.

Log in to MySQL using the root user credentials:

sudo mysql -u root -p

Enter the password that you set for the MySQL root user in the previous step.

Create a new database for the WordPress site:

CREATE DATABASE wordpress;

Grant the phpMyAdmin user access to the newly created database:

GRANT ALL PRIVILEGES ON wordpress.* TO 'phpmyadmin'@'localhost';

Assign the necessary privileges to the phpMyAdmin user for managing the database:
FLUSH PRIVILEGES;

C.

Install workbench on your host pc using this ink https://dev.mysql.com/downloads/workbench/

How to Allow Remote Connections to MySQL

Edit your MySQL Config File on your AWS EC2 instance

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Figure 4 Change Bind-Address IP

The new IP should match the address of the machine that needs to access the MySQL server
remotely. For example, if you bind MySQL to 0.0.0.0, then any machine that reaches the
MySQL server can also connect with it. Once you make the necessary changes, save and exit the
configuration file.

Restart MySQL Service

sudo systemctl restart mysql

create a new remote user in MYSQL server

login to your MYSQL server

create user ‘YOUR USER NAME’@’%’ identified by ‘YOUR PASSWORD’;

now created user successfully now give to the privileges their databases
grand all on *.* ‘YOUR USER NAME ’@’%’;

and exit from mysql server

and restart mysql server

sudo systemctl restart mysql

go to your work bench

Connection name : as your wish

Hostname : private ip address of your EC2 instance

Port : The port always will be 3306

User Name : user name is going to be just we created on the mysql server

Password : password is just we created on the mysql server

Now successfully connect to your workbench from your AWS EC2 instance

https://www.sqlshack.com/how-to-connect-to-remote-mysql-server-using-ssl-on-ubuntu-18-
04/

https://phoenixnap.com/kb/mysql-remote-connection

You might also like