How to optimize WordPress site performance?

  • Use a CDN
  • Use a caching plugin or edit .htaccess to cache different file types for different lengths of time and use gzip, etc
  • Use a simple theme/framework
  • Split comments, products and long posts into smaller pages
  • Use less plugins and only use well established ones
  • Keep WordPress updated
  • Host images on a subdomain

  • A separate domain prevents your domain's cookies from being sent for every image request, where they're not needed. Reduces the bandwidth overhead for each request.
  • Most browsers will only make a certain number of HTTP requests at one time to a particular domain, so serving images and other static content off a second domain potentially doubles the number of HTTP requests at one time.
  • You can conceivably use a different, lighter weight webserver like nginx/lighttpd to serve the static content.

Creating a new project

Below are the steps needed to create a new project:

On Server

Login to PhpMyAdmin :

On Local

Login to PhpMyAdmin:

On Both

  1. Create user sarah with password: 575757aA
  2. Check off to create database with same name when creating

This creates an empty database with correct user assigned. WordPress will do rest when you upload files

Login to FTP with chris user and go to /var/www
Create folders: sarah/public_html

Add alias for new website since you probably won't have domain name yet

nano /etc/apache2/sites-available/000-default.conf
Alias /sarah /var/www/sarah/public_html

Save file

If you have domain name then do this

sudo cp /etc/apache2/sites-available/ /etc/apache2/sites-available/
nano /etc/apache2/sites-available/

Edit ServerName, ServerAlias, DocumentRoot, Directory

Enable new virtual host

sudo a2ensite

Deactivate any conf file you don't want to use right now like this

sudo a2dissite

useradd -m -d /home/sarah sarah
passwd sarah

Give password: 575757aA

usermod -g www-data sarah

Add user to vsftpd

cd /etc/vsftpd
nano sarah
htpasswd -cd /etc/vsftpd/ftpd.passwd sarah

Will ask for password now


Then edit user home directory (not sure if this is actually needed anymore)

usermod --home /var/www/sarah/public_html sarah

Check that user can write to directory

sudo chown -R sarah:www-data /var/www/sarah/public_html
chmod 775 /var/www/sarah/public_html
/etc/init.d/vsftpd restart

For changes to take effect restart apache

service apache2 restart

Try connecting to FTP using FTP user, password and port 21

Need port 21 because WordPress doesn't allow changing of ports

On Server

Download WordPress to site

wget -c
tar -xzvf latest.tar.gz
sudo rsync -av wordpress/* /var/www/sarah/public_html

OLD WAY Upload WordPress zip to directory


Make whole site writable for WordPress (wp-content needed for plugins, wp-admin needed for wordpress update)

I think you need to set like this instead (if you have trouble installing plugins after this then I was wrong)

find /var/www/sarah/public_html -type d -exec chmod 775 {} \;
find /var/www/sarah/public_html -type f -exec chmod 664 {} \;

Then update to belong to user:

sudo chown -R sarah:www-data /var/www/sarah/public_html

Go to IP alias or domain and follow wizard

After wizard complete, download wp-config.php and add this line to bottom so users can upload plugins using admin

if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );

On Local

Download latest Wordpress

Create new site folder under D:\sites\{site-name}

Unzip in folder

Open project in localhost:


Follow WordPress steps to hook up to WordPress database you created

Create empty theme folder by name of project on local: D:\sites\{site-name}\wp-content\themes\{site-name} and on server by same name

Open SourceTree and copy repo URL and point to empty folder on local. Clone repo to folder and add any files you want to push to server

Press Git Flow to set up the correct branches

  1. Choose Bitbucket and create project
  2. Choose your new repo you created
  3. Create Production Server
  4. Hostname:
  5. Username:
  6. Check off " Use SSH key rather than password for authentication? "
  7. Copy key, open Filezilla login with chris
  8. Go to .ssh/authorized_keys and copy file to desktop
  9. Open file and add new key. Upload back to server
  10. On FileZilla open theme folder in site and copy full path. Add to "Deployment Path"
  11. Click "Create Server"

You can now deploy master branch to website

Every new website uses gulp. Below is the code to start using it on a new project.

Install the npm init package:

npm init

Complete the npm init process populating all fields.

After, install gulp:

npm install gulp@3.9.0

And gulp dependencies:

npm install gulp-sass --save-dev; npm install gulp-concat --save-dev; npm install gulp-uglify --save-dev; npm install browser-sync --save-dev; npm install gulp-rename --save-dev;

If this is your first time using gulp in a new machine, we need to install the gulp-cli:

 npm install --g gulp-cli 

For more references, check the official documentation: