WordPress SQL instance

0

wanting to set up multiple wordpress sites in AWS and want to know how the SQL infrastructure works. if you have multiples Wordpress sites in your AWS, does each wordpress site have its own sql instance with individual passwords? Or is it the same log in credentials for all?

3 Answers
1

Hello.

Depends on configuration.
For example, you can create an RDS instance for each WordPress site, or you can have one RDS instance.
Even if you create an RDS instance for each WordPress site or have only one RDS instance, it is possible to change the password for each WordPress site.
Just create a MySQL user for each WordPress site and change the password for each, and the authentication information will change for each WordPress site.
If you have one RDS instance, if a failure occurs in one, it will affect other WordPress sites, so if you can afford the cost, it may be a good idea to create an RDS instance for each WordPress site.

Also, if you have a small site, it might be a good idea to use something like Lightsail, which comes with WordPress installed from the beginning.
https://aws.amazon.com/getting-started/hands-on/launch-a-wordpress-website/?nc1=h_ls

profile picture
EXPERT
answered 7 months ago
  • Yes, i want separate RDS instances incase there is a failure

1
profile picture
answered 7 months ago
  • does lightsail give seperate rds instances?

1

There are several ways to do this, but the simplest one is to host all WP websites and databases in the same EC2 (not the best recommendation).

For this, you can simply start a new instance (make sure to use a Graviton-based instance like t4g + a gp3 volume to provide the best price/performance combination), create the security group and get everything in place to connect to the instance via SSH.

Then you can install all the requirements you need for WordPress. For example: if you use Ubuntu, I will share the commands you will need here:

sudo apt-get update
sudo apt-get upgrade
sudo adduser <username>
sudo usermod -aG sudo <username>
su - <username>

# The recommended approach is to use another instance for the databases
sudo apt-get install apache2 mysql-server php libapache2-mod-php php-mysql php-xml php-gd php-curl
sudo mysql_secure_installation

# Apache rewrite module install
apache2ctl -M
sudo a2enmod rewrite

Next step is to et up Virtual Hosts for multiple Wordpress sites:

sudo mkdir -p /var/www/<domain1>/public_html
sudo mkdir -p /var/www/<domain2>/public_html
sudo chown -R $USER:$USER /var/www/<domain1>/public_html
sudo chown -R $USER:$USER /var/www/<domain2>/public_html
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/<domain1>.conf

Then you can use nano or vi to create a file with the following structure:

<Directory /var/www/<domain1>/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

Then, you need to add another record:

ServerAdmin info@<domain1>
ServerName <domain1>
ServerAlias www.<domain1>
DocumentRoot /var/www/<domain1>/public_html

Now, it's time for the WordPress installation:

sudo mysql -u root -p
create database wp_<domain1>_db;
CREATE USER ‘wp_user’@’localhost’ IDENTIFIED BY ‘<pasword>’;
GRANT ALL PRIVILEGES ON wp_db.* TO ‘wp_user’@’localhost’;
FLUSH PRIVILEGES;

Then download the last version of WordPress:

wget https://wordpress.org/wordpress-6.3.2.tar.gz
tar -xvzf wordpress-6.3.2.tar.gz -C /var/www/<domain>public_html/--strip-components 1
sudo a2ensite <domain1>.conf

Use Let's Encrypt to get a SSL certificate:

sudo apt install certbot python3-certbot-apache
sudo certbot — — apache

Run the below commands to secure the files and folders:

find /var/www/<domain1>/public_html -type d -exec chmod 755 {} \;
find /var/www/<domain1>/public_html -type f -exec chmod 644 {} \;

and finally, change the ownership of the wp-content directory to www-data to enable updates and plugin installation:

sudo chown -R www-data:www-data /var/www/<domain1>/public_html/wp-content
profile picture
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions