In this tutorial, we are going to provide you with step-by-step instructions on how to install WordPress with Memcached and Nginx on an Ubuntu 16.04 VPS. WordPress is one of the best open-source content management systems written in PHP.
Requirements
At the time of writing this tutorial, the latest stable version of WordPress is 4.8 and it requires:
- PHP >= 5.2.4 . Also, using MemCached is highly recommended for better site performance;
- Nginx or Apache web server;
- MySQL or MariaDB installed on your Linux VPS.
Table of Contents
1. Update the system
Make sure your package list and the OS packages are up to date by running the following commands:
You can also configure automatic updates.
2. Install Nginx
To install the latest Nginx version from the official Nginx repository, edit the ‘/etc/apt/sources.list’ file:
Add the following lines:
3. Install MySQL
Stop and remove Apache service, then install nginx your virtual server using the following commands:
Configure Nginx to start on boot:
4. Install Memcached, PHP 7 and PHP modules:
5. Start the WordPress installation procedure
Download the latest version of WordPress available at the official website to a directory of your virtual server, then extract it using the following commands:
WordPress requires a database to work as this is where data is saved, so create a new MySQL database:
Add the MySQL username, password and database name to the WordPress configuration file:
Create a new Nginx configuration file and add the following virtual block for your domain name:
Add the following lines:
Do not forget to replace ‘your-domain.com’ with your actual domain name. Then, disable the ‘default’ Nginx configuration file:
Enable the new Nginx configuration file:
Open the ‘/etc/php/7.0/fpm/pool.d/www.conf’ file and change the ‘listen’ variable:
change:
to:
Edit the ‘/etc/php/7.0/fpm/php.ini’ configuration file:
Add/modify the following settings:
[ecko_alert color=”blue”]All of this seems too complicated? Get a WordPress VPS from us and we’ll do all of this for you, free of charge! We’ll take care of your server 24/7[/ecko_alert]
Edit the ‘memcache.ini’ configuration file:
add the following lines at the end:
Edit /etc/memcached.conf and increase the Memcached memory limit to 128 MB or higher:
change:
to:
Configure memcached to listen on localhost (127.0.0.1) and disable UDP:
The web server user (www-data) needs to be able to write to files and directories inside the ‘/var/www/html/wordpress’ directory, so it can easily be accomplished by executing the following command:
Edit the main nginx configuration file (/etc/nginx/nginx.conf) and add ‘gzip_vary on’ in the ‘http’ block:
Test the nginx configuration:
If the test is successful, restart memcached, php7.0-fpm and Nginx services for the changes to take effect:
Open http://your-domain.com/ using your favorite web browser and follow the easy instructions. Once installed, log in to the administrator back-end and configure according to your needs.
6. Install and configure W3 Total Cache to use Memcached
Open http://your-domian.com/wp-admin/plugins.php >> Add New >> Search for ‘W3 Total Cache’ >> click ‘Install now’ next to ‘W3 Total Cache’ title >> Activate.
Open http://your-domian.com/wp-admin/plugins.php >> click ‘Settings’ from the W3 Total Cache section :
- Minify
Click ‘Save all settings’.
- Object Cache
Click ‘Save all settings’.
That is it. The WordPress installation with Memcached and Nginx is now complete.
7. Further reading
After installing WordPress, you can read some of our WordPress articles:
- How to Speed up and Optimize WordPress on a Linux VPS
- Top 10 Social Media Plugins for WordPress
- 8 Essential WordPress Plugins Your Website Must Have
- 5 Essential Tips for Securing Your WordPress Sites
- How to manage multiple WordPress sites from a single place using the MainWP plugin
Of course, you don’t have to Install WordPress with Memcached and Nginx on Ubuntu, if you use one of our WordPress VPS Hosting services, in which case you can simply ask our expert Linux admins to install WordPress with Memcached and Nginx for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to Install WordPress with Memcached and Nginx on Ubuntu, please share it with your friends on the social networks using the buttons below or simply leave a reply in the comments section. Thanks.
What do I do if I want to install multiple WordPress websites? What commands need to be tweaked/repeated?
In order to install multiple wordpress websites you will have to create a new nginx configuration for each domain, separate database and separate wordpress installation.
Hello,
Thanks for a very detailled tutorial.
Something does not make sens to me: why do you edit the /etc/php/7.0/cli/php.ini file, shouln’t it be the /etc/php/7.0/fpm/php.ini file as php-fpm is used to render webpages and cli is used for the command line version from the bash.
Am I wrong?
Thanks,
M
You are right. The tutorial has been updated.