A
A
Andrey2017-12-26 19:34:10
Server optimization
Andrey, 2017-12-26 19:34:10

Server optimization for wordpress sites?

After the holidays, I'm going to move to a new server (ssd started to die on the old one).
The old server had the following configuration: Centos 7, nginx+apache+php 5.6.31+opcache in fastcgi mode, MySQL 5.6.30.
This server config was implemented exactly 2 years ago. Tell me, what config is currently relevant for a budget server that hosts 5-10 wordpress sites, and the total traffic is no more than 20k.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Twelfth Doctor, 2017-12-26
@dyba

1) Throw out Apache
2) Switch to Nginx + php7.0-fpm
The Nginx virtual host configuration for WP is something like this:

server {
  server_name example.com;
  listen 80;
  root /home/site1/web;
  access_log /home/site1/logs/access.log;
  error_log /home/site1/logs/error.log;
  index index.php;

  location / {
    try_files $uri $uri/ /index.php?q=$uri&$args;
  }

  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ /\.ht {
    deny  all;
  }
        location ~ \.php$ {
                  try_files $uri =404;
                  fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/run/php/site1.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        }
}

Then create the appropriate pool file (/etc/php/7.0/fpm/pool.d/site1.conf)
[site1]
user = site1
group = site1
listen = /run/php/site1.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Each site runs as its own linux user. Site1 site files are in /home/site1/web
PS
Why do you need Apache together with php-fpm ? o_o

M
Moris Haos, 2017-12-26
@morihaos

Twelfth Doctor , why didn't Apache please you?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question