Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Install WordPress with W3 Total Cache on Ubuntu 16.04

WordPress is one of the best open source content management systems written in PHP you can use to create websites or blogs.

In this tutorial, we are going to provide you with step by step instructions on how to install and configure the W3 Total Cache plugin on an Ubuntu 16.04 VPS. W3 Total Cache is a great WordPress plugin and it is mainly used to increase the website performance by reducing the download times.

At the time of writing this tutorial, the latest WordPress stable version is 4.7.3 and it is recommended to install it on a VPS which supports:

  •     PHP 7.0 or greater with MySQLi and GD Graphics Library 2.0 enabled.
  •     MySQL 5.6 or greater, or MariaDB version 10.0 or greater installed on your Linux virtual server.
  •     Web server like Apache or nginx with enabled HTTPS support.

Install WordPress

This install guide assumes that Apache, MySQL and PHP are already installed and configured on your virtual server, so download the latest version of WordPress available at https://wordpress.org to the server and extract it using the following commands:

cd /opt/
wget https://wordpress.org/latest.zip
unzip latest.zip -d /var/www/html/

Create a .htaccess file and add the following lines:

cd /var/www/html/wordpress
vi .htaccess
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Enable Apache rewrite module if it is not already done so:

a2enmod rewrite

In order to improve the PHP performance, install and enable the PHP Opcache extension:

apt-get install php7.0-opcache

Edit the PHP configuration file:

vi /etc/php/7.0/cli/php.ini

Add/modify the following lines in the ‘[opcache]’ section:

opcache.enable=1;
opcache.memory_consumption=256;
opcache.max_accelerated_files=20000;
opcache.max_wasted_percentage=10;
opcache.revalidate_freq=360;
opcache.fast_shutdown=0;
opcache.enable_cli=0;
opcache.revalidate_path=0;
opcache.validate_timestamps=0;
opcache.interned_strings_buffer=32;
opcache.fast_shutdown=1;

Create a new MySQL database for WordPress on your server:

mysql -u root -p
mysql> CREATE DATABASE wpdb;
mysql> GRANT ALL PRIVILEGES ON wpdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> quit

Do not forget to replace ‘your-password’ with a strong password.

Create a new Apache configuration file, e.g. /etc/apache2/sites-available/wordpress.conf, open it and add the following lines to it:

vi /etc/apache2/sites-available/wordpress.conf

ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common

Make sure to replace ‘your-domain.com’ with your actual domain name.

Remove the 000-default.conf file:

rm /etc/apache2/sites-enabled/000-default.conf

Run the following command to enable the wordpress.conf configuration in Apache:

ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf

Restart the Apache web server for the changes to take effect:

service httpd restart

The webserver user (www-data) needs to be able to write to the ‘/var/www/html/wordpress/’ directory so you can easily accomplish that by executing the following command:

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

Open ‘http://your-domain.com’ in your favorite web browser and enter the following information:

Database name: wpdb
Username: wpuser
Password: your-password
Database Host: localhost

Click ‘Submit’, then ‘Run the install’ and enter a website title, an Administrator’s username, password and email address, and finally click on the ‘Install WordPress’ button.

The WordPress installation is now complete.

Install and Configure W3 Total Cache

Log in to the WordPress dashboard, go to Plugins, click ‘Add New’, search for ‘W3 Total Cache’ and click ‘Install Now’ next to ‘W3 Total Cache’. Click ‘Activate’ to enable the ‘W3 Total Cache’, then click ‘Settings’ and configure the W3 Total Cache plugin:

  • Enable the page cache option and set the page caching method (‘Disk: Enhanced’ is the default option).
  • Enable the minify option to reduce load time by decreasing the size and number of CSS and JS files, and set the ‘minify cache method’ (‘disk’ is the default option).
  • Enable the opcode cache
  • Enable the database cache and choose a database caching method
  • Enable the object cache option
  • Enable the browser cache option
  • If you use a CDN, enable it.

Leave other settings as-is and click ‘Save all settings’.

That is it. The basic W3 Total Cache options are now enabled.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.



This post first appeared on Virtual-Server.org Virtual Server, please read the originial post: here

Share the post

How to Install WordPress with W3 Total Cache on Ubuntu 16.04

×

Subscribe to Virtual-server.org Virtual Server

Get updates delivered right to your inbox!

Thank you for your subscription

×