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 or 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.

1 thought on “Install php7 + nginx + MariaDB + WordPress on Debian Jessie

  1. Thank you so much for this :)
    Now my site is way faster than it was.

Добавить комментарий

Войти с помощью: 

Ваш e-mail не будет опубликован. Обязательные поля помечены *