Skip to content

Instantly share code, notes, and snippets.

@atulkamble
Created September 13, 2023 04:40
Show Gist options
  • Save atulkamble/0b34e84e672ccf110df7fb3fbba13069 to your computer and use it in GitHub Desktop.
Save atulkamble/0b34e84e672ccf110df7fb3fbba13069 to your computer and use it in GitHub Desktop.
wordpress-ec2-0

Task: Host a WordPress blog on Amazon Linux 2023

Update instance

sudo yum update -y

download pacakges

sudo dnf install wget php-mysqlnd httpd php-fpm php-mysqli mariadb105-server php-json php php-devel -y

download wordpress

wget https://wordpress.org/latest.tar.gz

Unzip and unarchive the installation package. The installation folder is unzipped to a folder called wordpress.

tar -xzf latest.tar.gz

database configurations

sudo systemctl start mariadb httpd

signing to database

sudo mysql -u root -p

CREATE USER 'wordpress-user'@'localhost' IDENTIFIED BY 'Atul@123';

CREATE DATABASE `wordpress-db`;

GRANT ALL PRIVILEGES ON `wordpress-db`.* TO "wordpress-user"@"localhost";

FLUSH PRIVILEGES;

get out of database

exit

To create and edit the wp-config.php file

cp wordpress/wp-config-sample.php wordpress/wp-config.php

edit configuration file

nano wordpress/wp-config.php

Add following details as per the database details in a wp-config file

define('DB_NAME', 'wordpress-db');

define('DB_USER', 'wordpress-user');

define('DB_PASSWORD', 'your_strong_password');

Create Authentication Unique Keys

https://api.wordpress.org/secret-key/1.1/salt/

Under Apache Document Root

sudo cp -r wordpress/* /var/www/html/

Alternative Directory

sudo mkdir /var/www/html/blog
sudo cp -r wordpress/* /var/www/html/blog/

To allow WordPress to use permalinks

edit config file

sudo nano /etc/httpd/conf/httpd.conf

Search following under lines

*<Directory "/var/www/html">

Find the section that starts with <Directory "/var/www/html">*

Change the AllowOverride None line in the above section to read AllowOverride All.

Install the PHP graphics drawing library on Amazon Linux 2023

sudo dnf install php-gd -y
sudo dnf list installed | grep php-gd

Add Permissions on webserver

sudo chown -R apache /var/www

sudo chgrp -R apache /var/www

sudo chmod 2775 /var/www

sudo systemctl restart httpd

Php Page

http://your-ec2-ip/wp-admin/install.php

Wordpress Login Page

http://your-ec2-ip/wp-login.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment