Friday, November 24, 2017

Linux top opened files

## Get common list of all opened files
lsof > lsof.log

## Get top
cat lsof.log | awk '{ print $2 " " $1; }' | sort -rn | uniq -c | sort -rn | head -20

Monday, August 21, 2017

docker notes


Docker search image

> docker search <name>

Run docker in the background

> docker run -d redis

List of all runnning containers

> docker ps

Provide more details about container

> docker inspect <friendly-name|container-id>

Provide logs about container

> docker logs <friendly-name|container-id>

Open container ports

> docker run -d --name someName -p 6379:6379 redis:latest

Persisting data

> docker run -d --name redisMapped -v /opt/docker/data/redis:/data redis

Docker stats

> docker ps -q | xargs docker stats

Sunday, April 9, 2017

Fix website permissions


chown www-data:www-data  -R /var/www/vhosts/
find  /var/www/vhosts/ -type d -exec chmod 755 {} \;
find  /var/www/vhosts/ -type f -exec chmod 644 {} \; 

Tuesday, March 14, 2017

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

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