Skip to content

Instantly share code, notes, and snippets.

@teja156
Last active May 2, 2024 23:03
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 77 You must be signed in to fork a gist
  • Save teja156/8c35a05f43635da4cbd06b47c0d91e93 to your computer and use it in GitHub Desktop.
Save teja156/8c35a05f43635da4cbd06b47c0d91e93 to your computer and use it in GitHub Desktop.
Commands for deploying wordpress website on AWS EC2 shown in my YouTube video
YouTube video link: https://youtu.be/8Uofkq718n8
All the commands that are executed in the above youtube video are mentioned in this gist.
1. Install Apache server on Ubuntu
sudo apt install apache2
2. Install php runtime and php mysql connector
sudo apt install php libapache2-mod-php php-mysql
3. Install MySQL server
sudo apt install mysql-server
4. Login to MySQL server
sudo mysql -u root
5. Change authentication plugin to mysql_native_password (change the password to something strong)
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'Testpassword@123';
6. Create a new database user for wordpress (change the password to something strong)
CREATE USER 'wp_user'@localhost IDENTIFIED BY 'Testpassword@123';
7. Create a database for wordpress
CREATE DATABASE wp;
8. Grant all privilges on the database 'wp' to the newly created user
GRANT ALL PRIVILEGES ON wp.* TO 'wp_user'@localhost;
9. Download wordpress
cd /tmp
wget https://wordpress.org/latest.tar.gz
10. Unzip
tar -xvf latest.tar.gz
11. Move wordpress folder to apache document root
sudo mv wordpress/ /var/www/html
12. Command to restart/reload apache server
sudo systemctl restart apache2
OR
sudo systemctl reload apache2
13. Install certbot
sudo apt-get update
sudo apt install certbot python3-certbot-apache
14. Request and install ssl on your site with certbot
sudo certbot --apache
@iamishu
Copy link

iamishu commented Jan 4, 2023

This article helps you in this situation. Click here

@iurisman
Copy link

iurisman commented Jan 26, 2023

This is super useful, thank you. Thee additional things I had to do:

  • Do sudo apt-get update before installing anything.
  • Change Apache's user and group from the default www-data to ubuntu by editing /etc/apache2/envvars
export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=ubuntu 

Otherwise, any attempt to download a theme, a plugin or an update to the Wordpress software will result in a misleading FTP-related error message, masking the real problem that the default user does not have write permission to the Wordpress directory structure.

  • Run the following command before running sudo certbot ...:
sudo add-apt-repository ppa:certbot/certbot

@dron420
Copy link

dron420 commented Feb 21, 2023

how do i save

@dron420
Copy link

dron420 commented Feb 21, 2023

how do i save copied folder

@karthirock98
Copy link

how can i connect this DB with dbeaver client

@noorshanu
Copy link

when i refresh its says 404 not found also on any url unable to login to dashboard

@abdulahath
Copy link

After all the steps mentioned in the video, should run sudo chown -R www-data:www-data /var/www/html . then only we can install/delete any themes & plugins. Or it will give a misleading FTP-related error message, masking the real problem that the default user does not have write permission to the Wordpress directory structure.

@Muizism
Copy link

Muizism commented Jun 11, 2023

I purchased domain from hostinger and it worked but when i write /wp-admin in url is said:
Not Found
The requested URL was not found on this server.

Apache/2.4.52 (Ubuntu) Server at www.muezism.pro Port 80

HELP!!

@noorshanu
Copy link

https://ambassador.deelance.com/wp-admin
wont able to login it says url not found

@leavesofshade
Copy link

leavesofshade commented Jul 5, 2023

I followed all steps in video, but when I got to the point where you add the /wordpress to the end of IP and start the wordpress install in the browser I got this:

@mg410
Copy link

mg410 commented Jul 10, 2023

elasticipaddress/wp-admin doesn't open the WP admin console. Any fox for this

@mg410
Copy link

mg410 commented Jul 10, 2023

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

Yes same issue, there is no response from Author ?

@tanishqarya007
Copy link

tanishqarya007 commented Jul 11, 2023

Can anyone tell why my wordpress installation screen showing me this -

@Kwasu1
Copy link

Kwasu1 commented Jul 14, 2023

I followed all the steps and got stuck trying to access the WordPress admin page (wp-login). I get to the WordPress custom page using the IP address, but whenever I click other links from the custom page, I get the error message as follows:
"Not Found. The requested URL was not found on this server. Apache/2.4.52 (Ubuntu) Server at ...** Port 80."

Please can you assist me with this problem? Thank you so much

@AnthonyEhizogie
Copy link

Kind assistance is needed, I got the same problem as below
I followed all the steps and got stuck accessing the WordPress admin page (wp-login). I get to the WordPress custom page using the IP address, but whenever I click other links from the custom page, I get the error message as follows:
"Not Found. The requested URL was not found on this server. Apache/2.4.52 (Ubuntu) Server at ...** Port 80."

Please can you assist me with this problem? Thank you so much

@Kwasu1
Copy link

Kwasu1 commented Jul 27, 2023

This was how I fixed the problem:

"Not Found. The requested URL was not found on this server. Apache/2.4.52 (Ubuntu) Server at ...** Port 80."

  1. I reverted the changes I made to the "000-default.conf" file on the "sites-available" directory.
  2. On WordPress, I went to "Settings", then "General" and edited both "WordPress Address (URL)" and "Site Address (URL)" by removing the "\wordpress" extension from the URL's.
  3. I went back to the "000-default.conf" file (sites-available directory) on Mobaxterm and added the "/WordPress" extension (var/www/html/WordPress).

After doing this, I stopped getting the error message above and could navigate around the WordPress admin console.

Note
The Wordpress Address (URL)" and "Site Address (URL) on Wordpress will further change from your public IP address to your domain name.

@AnkushPrakash-cloud
Copy link

Thank you for this project.

@JyothisNarayanan
Copy link

thank you all for the above inputs.
However I have come across the following issue while adding the starter templates to WordPress
"We're Almost There!
You're close to importing the template. To complete the process, please clear the following conditions.
XMLReader Support Missing
cURL Support Missing "

can someone pls help me resolve this

@chrisroundhill
Copy link

This was how I fixed the problem:

"Not Found. The requested URL was not found on this server. Apache/2.4.52 (Ubuntu) Server at ...** Port 80."

  1. I reverted the changes I made to the "000-default.conf" file on the "sites-available" directory.
  2. On WordPress, I went to "Settings", then "General" and edited both "WordPress Address (URL)" and "Site Address (URL)" by removing the "\wordpress" extension from the URL's.
  3. I went back to the "000-default.conf" file (sites-available directory) on Mobaxterm and added the "/WordPress" extension (var/www/html/WordPress).

After doing this, I stopped getting the error message above and could navigate around the WordPress admin console.

Note The Wordpress Address (URL)" and "Site Address (URL) on Wordpress will further change from your public IP address to your domain name.

For anyone who is stuck after registering an A record with your DNS settings, this is the proper fix. Another way of phrasing it:

  1. Remove the DocumentRoot, ServerName, and ServerAlias values from the 000-default.conf file in your apache directory
  2. Restart apache with sudo systemctl restart apache2
  3. In a web browser go to your WordPress admin page (IP Address/wp-admin) and go to Settings @15:45 in the YouTube video. Remove the /wordpress from the "WordPress Address (URL)" and "Site Address (URL)" entries, but leave the IP address for now.
  4. Go back to the 000-default.conf file on your Apache webserver and add the DocumentRoot, ServerName, and ServerAlias values back in and save the configuration.
  5. Restart apache with sudo systemctl restart apache2

Now you should be able to go to mydomain.com/wp-admin and change out the IP addresses in the "WordPress Address (URL)" and "Site Address (URL)" entries in the Settings page and proceed.

What's happening (If I understand correctly) is that there's a conflict with DNS because your A record is pointing you to the IP Address but the WordPress configuration is expecting the IP Address to have /wordpress at the end of it. Take this with a grain of salt, but that's what makes sense to me. But doing @teja156 's steps slightly out of order this way works as of November 2023.

@HimelAhmed62
Copy link

https://prnt.sc/PlgAQgnrg-xY

showing this error when i tried to install mysql server

@ivankiller2023
Copy link

Do you want to continue? [Y/n]
Err:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-bin amd64 2.4.52-1ubuntu4.6
  404  Not Found [IP: 3.110.169.167 80]
Err:2 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-data all 2.4.52-1ubuntu4.6
  404  Not Found [IP: 3.110.169.167 80]
Err:3 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2-utils amd64 2.4.52-1ubuntu4.6
  404  Not Found [IP: 3.110.169.167 80]
Err:4 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 apache2 amd64 2.4.52-1ubuntu4.6
  404  Not Found [IP: 3.110.169.167 80]
E: Failed to fetch http://ap-south-1.ec2.archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-bin_2.4.52-1ubuntu4.6_amd64.deb  404  Not Found [IP: 3.110.169.167 80]
E: Failed to fetch http://ap-south-1.ec2.archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-data_2.4.52-1ubuntu4.6_all.deb  404  Not Found [IP: 3.110.169.167 80]
E: Failed to fetch http://ap-south-1.ec2.archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2-utils_2.4.52-1ubuntu4.6_amd64.deb  404  Not Found [IP: 3.110.169.167 80]
E: Failed to fetch http://ap-south-1.ec2.archive.ubuntu.com/ubuntu/pool/main/a/apache2/apache2_2.4.52-1ubuntu4.6_amd64.deb  404  Not Found [IP: 3.110.169.167 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

What to do?

@princesokrati
Copy link

if you open any blog then it is not working may by htaccess issue i have that same folder name wordpress can any one help ?

@Sailendrakafle
Copy link

I got this while accessing WordPress:

@LoveAboveAll
Copy link

I follow every step but I get this message after trying to install mysql
Uploading Screenshot (23).png…

@LoveAboveAll
Copy link

  1. I follow every step but I get this message after trying to install mysql. Somebody help what I'm doing wrong

ubuntu@ip-172-31-13-249:$ sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl
libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl
liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
libdata-dump-perl libipc-sharedcache-perl libbusiness-isbn-perl libwww-perl
mailx tinyca
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl
libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl
libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl
libhttp-date-perl libhttp-message-perl libio-html-perl
liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl
liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0
mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0
mysql-server-core-8.0
0 upgraded, 28 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.8 MB/29.6 MB of archives.
After this operation, 243 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Ign:1 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-client-core-8.0 amd64 8.0.35-0ubuntu0.22.04.1
Ign:2 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-client-8.0 amd64 8.0.35-0ubuntu0.22.04.1
Ign:3 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server-core-8.0 amd64 8.0.35-0ubuntu0.22.04.1
Ign:4 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server-8.0 amd64 8.0.35-0ubuntu0.22.04.1
Ign:5 http://us-east-2.ec2.archive.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server all 8.0.35-0ubuntu0.22.04.1
Err:1 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-client-core-8.0 amd64 8.0.35-0ubuntu0.22.04.1
404 Not Found [IP: 52.15.107.13 80]
Err:2 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-client-8.0 amd64 8.0.35-0ubuntu0.22.04.1
404 Not Found [IP: 52.15.107.13 80]
Err:3 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server-core-8.0 amd64 8.0.35-0ubuntu0.22.04.1
404 Not Found [IP: 52.15.107.13 80]
Err:4 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server-8.0 amd64 8.0.35-0ubuntu0.22.04.1
404 Not Found [IP: 52.15.107.13 80]
Err:5 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 mysql-server all 8.0.35-0ubuntu0.22.04.1
404 Not Found [IP: 52.15.107.13 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/mysql-client-core-8.0_8.0.35-0ubuntu0.22.04.1_amd64.deb 404 Not Found [IP: 52.15.107.13 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/mysql-client-8.0_8.0.35-0ubuntu0.22.04.1_amd64.deb 404 Not Found [IP: 52.15.107.13 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/mysql-server-core-8.0_8.0.35-0ubuntu0.22.04.1_amd64.deb 404 Not Found [IP: 52.15.107.13 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/mysql-server-8.0_8.0.35-0ubuntu0.22.04.1_amd64.deb 404 Not Found [IP: 52.15.107.13 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/m/mysql-8.0/mysql-server_8.0.35-0ubuntu0.22.04.1_all.deb 404 Not Found [IP: 52.15.107.13 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
ubuntu@ip-172-31-13-249:
$

@Novavamp
Copy link

Novavamp commented Feb 20, 2024

If you have any issues regarding permalinks and pages showing error not found. Goto this path: /etc/apache2/sites-enabled and sudo nano 000-default.conf then add this code:

<Directory path/to/dir>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</ Directory>

(the closing without space)
Then restart apache2 sudo systemctl restart apache2

@Syamabbas
Copy link

Syamabbas commented Mar 11, 2024

I follow every step and get succedd, thx for it

@Rolkany
Copy link

Rolkany commented Apr 30, 2024

I Have a problem:

@shahryar-cmyk
Copy link

If you have any issues regarding permalinks and pages showing error not found. Goto this path: /etc/apache2/sites-enabled and sudo nano 000-default.conf then add this code:

<Directory path/to/dir> Options Indexes FollowSymLinks AllowOverride All Require all granted </ Directory>

(the closing without space) Then restart apache2 sudo systemctl restart apache2

I tried this but the issue remains same.
image

@Novavamp
Copy link

Novavamp commented May 2, 2024

If you have any issues regarding permalinks and pages showing error not found. Goto this path: /etc/apache2/sites-enabled and sudo nano 000-default.conf then add this code:
<Directory path/to/dir> Options Indexes FollowSymLinks AllowOverride All Require all granted </ Directory>
(the closing without space) Then restart apache2 sudo systemctl restart apache2

I tried this but the issue remains same. image

Make sure you added the correct path to your website directory here: <Directory path/to/dir>

And remove the space at the closing tag (I added space so that GitHub doesn't change the output of the code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment