Follow the readme file for below mentioned git repository
https://github.com/harsh6768/deploy-in-ec2
sudo apt install apache2 -y
or
sudo apt-get install apache2 -y
You can copy the PUBLIC_IP of EC2 Instance and make sure you open the HTTP port 80 in In-Bound Security Group.
Optional Commands to start,restart,stop and check the status of Apache2
sudo systemctl start apache2
sudo systemctl restart apache2
sudo systemctl stop apache2
sudo systemctl status apache2
Run bellow command required/optional
sudo systemctl enable apache2
sudo apt install mysql-server
or
sudo apt-get install mysql-server
sudo mysql_secure_installation
Restart mysql database
sudo systemctl restart mysql
sudo apt install php php-mysql php-gd php-cli php-common
Go to wordpress website to download
https://wordpress.org/download/
Double click or right click on download button to get the option and copy the copy link address
Run below command to download wget and unzip to donwload wordpress and unzip it.
sudo apt install wget unzip -y
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo cp -r wordpress/* /var/www/html/
-r : for recursive copy
sudo chown www-data:www-data -R /var/www/html/
-R : for recursive
You have copied all the data of wordpress It you see the apache server's default page.
sudo rm -rf index.html
Now you go to the web browser using your EC2 public ip address ,you will be able to see the wordpress setup starting page
A. Login to mysql
mysql -u root -p
B. create new database
create database wordpress;
C. You can see the Password policy in mysql ,
this option you select while mysql_secure_installation part , as I have selected the medium policy , I can not enter the normal password
SHOW VARIABLES LIKE 'validate_password%';
Follow below stack overflow link to modify the password policy
https://stackoverflow.com/questions/43094726/your-password-does-not-satisfy-the-current-policy-requirements
D. create new user to handle wordpress database.
create user "wpadmin"@"%" identified by "786Hh@786"; //password policy was medium to I need to enter the mixed password
E. Grant the permission to the created user
grant all privileges on wordpress.* to "wpadmin"@"%";
If You have stopped the ec2 for any reason and again start the Instance then you won't see the styling and other functionality to you as IP has been changed now. To fix this issue we need to add the new ip to the mysql database.
sudo mysql
or
sudo mysql -u root -p
show databases;
use wordpress; //this is the datbase that we have crated earlier
show tables;
update wp_options set option_value="http://PUBLIC_IP" where option_id=1;
update wp_options set option_value="http://PUBLIC_IP" where option_id=2;