Архив категорий Вебдизайн и Wordpress


Верстка wordpress — работаем с темой от roots.io — sagemaster

Для начала установим nodejs через nvm. Ставить будем версию 7.1.0. Делается это в пару команд.

Далее идем в каталог с вашим сайтом в папку wp-content/themes
Клонируем репу в папку itclifesagemaster

Ok. Идем далее
Устанавливаем composer в каталоге с темой


Install php7 + nginx + MariaDB + WordPress on Debian Jessie

Install php7 + nginx + MariaDB + WordPress on Debian Jessie

Install nginx on Debian

I use the dotdeb repo as they compile nginx with useful addons like x-cache, pagespeed and others. They usually have the latest stable nginx build as well.

Make some changes to the nginx configuration

Add these values in the server block or adjust them if they are already there.

The client_max_body_size is the largest theme or plugin you’ll be able to upload (here 8 megabytes) so adjust that if necessary. It should match the upload_max_filesize in php.ini.

Ctrl+X, Y and Enter

Install PHP 7 on Debian

The dotdeb repository has precompiled php7 packages for Debian Jessie. php7.0-fpm is used for serving PHP pages for nginx.

Note that the benefits of opcache which speeds up your site significantly will be enabled by default with these packages.

Change your pm.max_children value for the php7.0-fpm

Adjust pm.max_children to 10 (make sure there is no leading ;), this is may be higher than necessary, see the formula link below for more precise calculations.

Adjust pm.max_requests, uncomment it by deleting the ; before pm.max and change it from 500 to 200

Ctrl+X, Y and Enter

Note that for the php7.0-fpm www.conf configuration above, you may want to adjust it following this formula in the future.

Adjust some php.ini values

Change your timezone by removing the ; semicolon and adding your country/city (list here).

Use a larger maximum upload size because some plugins are larger than 2 megabytes.

Change max_execution_time so backup scripts and other possible slow scripts have enough time to finish

If you have a large menu like mine with tons of menu items, increase the max_input_vars.

Ctrl+X, Y and Enter to save

Install MariaDB Server on Debian

MariaDB is a MySQL drop in with better performance, luckily it’s in the Debian Jessie repo so installing is easy.

Enter MariaDB (MySQL drop in)

Create the SQL WordPress user, database and grant privileges.

Note that this is not the WordPress user you use to log on but the credentials WordPress needs in wp-config.php to store posts and options in the database.

Tweak the MariaDB configuration

These values should be a good starting point for MariaDB with WordPress

If you are curious about any slow queries or queries not using indexes, enable these features by adding the configuration lines below.

Looking at these from time to time has helped me eliminate poorly coded WordPress plugins

These values will be adjusted in the future after you get some usage statistics and tweaking information from MySQLTuner

Ctrl+X, Y and Enter

Install WordPress

Create the site directory, this is the folder where your WordPress installation will be stored

Enter the site directory, grab the latest WordPress package and unpack it, then adjust the ownership so nginx can read it

Set up WordPress with MariaDB and nginx

Copy the sample wp-config.php file

Open the wp-config.php file to adjust the SQL database used

Adjust these settings so WordPress can connect to MariaDB. They are the values from when you created the SQL WordPress user.

Change ownership of the WordPress directory

Change permissions of the directories to the recommended 0755

Change permission of the wp-config.php file and other files to 0644

Create the WordPress nginx virtual host file

Paste this secure WordPress nginx configuration, if you want to only use domain.com or www.domain.com see this post.

Unlink the default site and symlink the WordPress site nginx virtual host

Restart nginx and php7.0-fpm

Now you can enter the IP address of your host into a browser and begin the 2 step process for installing WordPress on your VPS or dedicated server using nginx, MariaDB, php7-fpm.

Next see WordPress APCu Object Cache for PHP7

For additional speed use Redis object cache (guide here) to ease the load on the MySQL server.

For speeding up your site, consider using nginx’s fastcgi caching, personally I prefer using Varnish(guide) so that I can more precisely control the cache – warming up, specifically emptying cache for certain posts, categories etc and selectively purge static files.


Install and Configure Latest Redis Cache for WordPress

Install and Configure Latest Redis Cache for WordPress

Redis-server is a caching system that speeds up WordPress using object cache. Benchmarks show ridiculous speed increases with the PECL Redis extension for PHP. I use Redis caching and Varnish caching for this site and have found it to be the best combination on my 512 MB Digital Ocean droplet for $5 a month.

This guide is for Ubuntu and Debian based systems (Wheezy 7, Jessie 8, Trusty 14.x and Vivid 15.x and later) but should work on CentOS, Fedora and others by making small adjustments to package managers and paths. It provides a secure Redis installation for WordPress in light of recent telnet exploits – no easy root access can be gained from hackers if you follow this configuration tutorial.

Note: If you are on Ubuntu 16.04 please follow my new Redis guide.

Install and Configure Latest Redis Cache for WordPress

Using Redis object cache with WordPress requires two components speed boost your site

  • Redis Server which stores the WordPress object cache
  • Redis PHP extension (phpredis or predis) for php to communicate with the redis-server for storing and retrieving cache

phpredis is the the native c extension so is the fastest and obvious choice, the instructions for compiling from source follow the Redis server installation section.

If you prefer to use predis (redis extension written in php – (read slower)) then you do not need to install phpredis as the WordPress Redis cache plugin will default to predis.

Install Redis Server

This block of code installs the compilation tools, grabs the latest stable redis, builds and installs it. The latest version number can be found here

Create a non-privileged Redis user for maximum security which has no login, valid shell and limited home directory to its PID

Ensure the redis user is there by checking the shadow file

If it isn’t there use the add user command again

Make some changes to the redis configuration

Set daemonize to yes for init.d and systemd services

Change bind to only listen on localhost: to prevent serious security issues

Set maxmemory to 50M so Redis doesn’t use more than 50 MB of RAM. Even with 40 plugins I have never seen Redis use more than 20-30 MB for WordPress object caching.

Change the policy to allkeys-lru which forces redis-server to delete old cache (least recently used objects) when the Redis server starts to run out of memory

Ctrl+X, Y and Enter to save

Create a folder for the pid file

Change permissions so the redis user owns it

Time to start Redis server on boot, only use the init.d script or the systemd script

If you are in doubt which to choose run this command, if it doesn’t say systemd use the init.d script

Redis Server Systemd Script

Create the redis-server systemd script

Paste the Redis server systemd script

Enable the redis-server systemd script

Start the redis-server systemd script

Redis-server init.d Script

Create the Redis server init.d script which may already exist

Paste the redis server init.d script unless it already exists

Make sure the redis-server init.d script is executable

Update the system to use Redis server init.d script

Start the Redis server service

Confirm Redis-server is Secure

These are a few checks to make sure Redis is running securely, first use netstat

Make sure it listening on

You can also make sure the redis process is running as the redis user we specified

If redis says root instead that would be bad, even though it’s listening on the loopback interface

Install phpredis

Install php5-development tools and git, clone the latest phpredis, build and install it.

If you are using php7 you will need the php7.0-dev package for the development tools. You will also need to add -b php7 at the end of the git clone line (not on its own new line) to use the php7 branch of the github repository.

Add the redis extension to php5-fpm for nginx or apache2

For Apache2 add Redis to its php file

For nginx with php5-fpm enable Redis like this

For nginx with php7.0-fpm

Install the WordPress Redis plugin and enable it and enjoy the speed!


APCu Object Cache for PHP7 on WordPress on Ubuntu 16.04

WordPress object cache is a common way to speed up your site. PHP-APCu on Ubuntu 16.04 can help achieve your goal of supreme WordPress or WooCommerce speed.

This guide will show you how to install APCu Object Cache for PHP7 for WordPress on Ubuntu 16.04. There are three installation methods outlined here to best suit your needs. Usually installing from the repository or using PEAR is recommended, for bleeding edge users installing APCu from source it shown as well.

Install APCu Object Cache for PHP7 on WordPress on Ubuntu 16.04

Here are 3 ways to install the APCu object cache for WordPress or WooCommerce.

You should only choose one installation method.

  • Install APCu object cache for WordPress with one of the following methods
    • Install using repository
    • Install using PHP Pear
    • Build PHP-APCu from source
  • Then install the APCu WordPress object cache plugin

Install APCu Object Cache via Repository

Using this method you will not always get the latest version, it is however the easiest method.

Restart your php7.0-fpm service if you are using nginx

Reload Apache if you are using it.

Install APCu Using php PEAR

Another way to install is using php-pear, install it first

Running this command will install APCu.

Add the extension to a custom ini file.

Since I use php7.0-fpm with nginx I am symlinking into the php7.0 fpm and cli folders.

Restart php7-fpm

Apache2 users will want to symlink this file

Apache users reload the Apache service

Install APCu from Source Manually

The last way to install php7-apcu is to build from source. This way you get the bleeding edge version.

We need to install the php 7 development package and git first.

Enter your /tmp folder and clone the latest APCu source code from the git repository.

Now build the php7.0-apcu extension and install it.

Add the extension to the apcu.ini file

Since I use php7.0-fpm with nginx I am symlinking into the php-7.0 fpm and cli folders.

Restart php7.0-fpm service

Apache2 users will want to symlink this file

Reload the Apache service

Install the APCu object cache plugin

We are going to install the LCache Plugin hosted on github sponsored by Pantheon.

If you do not have WP-CLI or shell access to your host then you have to create the object-cache.php file manually with these instructions.

You will see this output

Now you can optionally adjust the RAM for APCu and monitor the APCu cache


Open the apcu.ini configuration file

Add the apc.shm_size line after the extension line. Here the APCu allocated ram is being changed to 50 MB.

Ctrl+X, Y and Enter to Save

Restart php7-fpm if ou are using it

Reload Apache if that is your web server of choice

Monitoring APCu Cache

Download the apc.php script

Now you can open yourdomain.com/apc.php and see the amount of cached objects, hit and miss rate.