Sunday, February 12, 2017

apache + nginx wordpress dynamic cache

nginx.conf http section

    proxy_cache_path /var/cache/nginx levels=2 keys_zone=cache:10m inactive=60m max_size=1024m;
    proxy_cache_key "$host$request_uri $cookie_user";
    proxy_temp_path  /var/cache/nginx/temp;
    proxy_ignore_headers Expires Cache-Control;
    proxy_cache_use_stale error timeout invalid_header http_502;
    proxy_cache_valid any 1d;

location config:

    location / {
        proxy_pass      http://127.0.0.1:8080;
        proxy_pass_header "X-Accel-Redirect";
        proxy_pass_header "X-Accel-Expires";
        proxy_cache cache;

Wednesday, January 11, 2017

nginx + php-fpm + wordpress, dynamic cache

Add to /etc/nginx/nginx.conf to http section

log_format  cache '$remote_addr - [$time_local] "$host$request_uri" $status $upstream_cache_status';
fastcgi_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=dynamic:100m inactive=5m;
fastcgi_cache_key "$scheme://$host$request_uri";

Add to your virtualhost to location section

        fastcgi_pass_header "X-Accel-Redirect";
        fastcgi_pass_header "X-Accel-Expires";
        fastcgi_cache dynamic;
        fastcgi_cache_key $scheme$host$request_uri$request_method;
        fastcgi_pass_header Set-Cookie;
        fastcgi_pass_header Cookie;
        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
        fastcgi_cache_valid 200 301 302 10m;
        access_log /var/log/nginx/access-cache.log cache;

then reload nginx

nginx -t && nginx -s reload

Thats all

Saturday, November 26, 2016

mysql qcache enabling


/etc/my.cnf

tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 1
query-cache-size               = 32M
max-connections                = 500
thread-cache-size              = 50
open-files-limit               = 65535
table-definition-cache         = 4096
table-open-cache               = 4096

Thursday, October 6, 2016

Openvz notes


Migrate container between nodes

vzmigrate --live REMOTE-IP LOCAL-CTID

For example

vzmigrate --live -v 192.168.5.5 413

Quotas

Disk quota
vzctl set CTID --diskspace 45G:49G --save

Ram quota
vzctl set CTID --ram 3G --swap 2048M --save

Tuesday, July 26, 2016

firewalld allow ports

Check rules

# firewall-cmd --state

Get default zone

# firewall-cmd --get-default-zone

Add allowed ports

# firewall-cmd --zone=public --add-port=50000-51000/tcp

Add permanent allowed ports

# firewall-cmd --zone=public --permanent --add-port=50000-51000/tcp

Check ports and services

# firewall-cmd --zone=public --permanent --list-services
# firewall-cmd --zone=public --permanent --list-ports

Add custom service

# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --zone=public --permanent --add-service=smtp
# firewall-cmd --zone=public --permanent --add-service=imap

After all changes need apply rules

# firewall-cmd --reload

Wednesday, June 29, 2016

git notes


Git, delete all deleted files

# git rm $(git ls-files --deleted)

Switch to other branch

# git branches
  Master
  Dev1
* Dev2

# git checkout Master
Branch Master set up to track remote branch Master from origin.
Switched to a new branch 'Master'

# git branches
* Master
  Dev1
  Dev2

Tuesday, June 28, 2016

Mysql / MariaDB check tables engine


SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'dbname' AND engine = 'MyISAM';


Where dbname - database name
And InnoDB - engine, you can use InnoDB


Convert MyISAM tables to InnoDB

SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME,' ENGINE=InnoDB;')
FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'DBNAME' AND ENGINE = 'MyISAM' AND TABLE_TYPE = 'BASE TABLE'

Then run result as SQL query

For example:

 ALTER TABLE databasename.tablename ENGINE=InnoDB;

grub2-install: error: disk `mduuid/e54081d398c6d57b4d67436f6d032162' not found

After raid 1 disk replacement faced with this issue # grub2-install /dev/sdb Installing for i386-pc platform. grub2-install: error: disk `md...