Optimize WordPress

Make it blazing fast

Why optimize wordpress

Especially useful for WordPress

How to install Apache

On most system it is installed by default but if it's not it should be in the standard repo for the current linux distro. For Debian and Ubuntu

and talknerd.php
inside /var/www/html/public_html/newdomain.com

Note: Its not a bad idea to create a index.html, foo.html and talkbase.php in the default root directory that the installation provides. It is useful for testing purposes. Be sure to make content inside then distingushable from thoose in /var/www/html/public_html/newdomain.com/ files

17. Secure with SSL
Install all packages needed for certbot
sudo apt install certbot python3-certbot-apache
Get the cert
sudo certbot --apache -d newdomain.com

Hardware Section

Seperate

  • Apache/Wordpress Server
  • Database mySQL server
  • PHP-FPM Server

Use dedicated server with ssd drives.

Partition one drive for whole wordpress(apache)

Make a seperates partiton for images files

1) Identify the New Drive device
lsblk
Drives are listed as sda, sdb, sdb and so on. Remember that when a number is assigned AFTER the device, sda1, sda2 the number denotes that it is a partition

2) Partition the new drive. Lets image that the drive device is sda then type
sudo fdisk /dev/sda
After this process you will have partion like sda1

3) Format the partition, sda1 with
sudo mkfs.ext4 /dev/sda1

4) Verify file system for partition with command
lsblk -f

5) Mount the partition to a folder /mnt/wordpress-pictures

a) cd into /mnt folder
cd /mnt

b) create the wordpress picture folder
sudo mkdir wordpress-pictures

c) Set ownership for wordpress
sudo chown -R www-data:www-data ./wordpress-pictures

d) Set correct permission for WordPress
sudo chmod -R 755 ./wordpress-pictures
Note: It will set directories to 755 and files to 644 (default behavior of chmod -R when used without any other flags

e) mount the sda1 partition to that folder
sudo mount /dev/sda1 /mnt/wordpress-pictures

6) Add a line to the /etc/fstab so you do NOT have to mount that on startup
sudo nano /etc/fstab

7) The UUID you will get from the lsblk -f command for the partition
UUID=bdc7dab1-aa73-46d2-9a15-262008bcaf2g /mnt/wordpress-pictures ext4 defaults 0 2

8) Now set new explicitly upload path

a) via a symblolic link
sudo ln -s /mnt/wordpress-pictures /var/www/html/wp-content/uploads
Note 1: The wordpress folder path for images may very but it should end with /wp-content/uploads
Note 2: /mnt/ssd/uploads should be owned by www-data:www-data
Note 3: the symlink (/var/www/html/wp-content/uploads) doesn’t need to be owned by www-data, but it should be readable and executable by www-data so that WordPress can access it properly

OR

b) Set in the upload path in file wp-config.php
define('UPLOADS', '/mnt/wordpress-pictures');