Skip to content

Instantly share code, notes, and snippets.

View jaircuevajunior's full-sized avatar
:octocat:
Hello there!

Jair Cueva Júnior jaircuevajunior

:octocat:
Hello there!
View GitHub Profile
@jaircuevajunior
jaircuevajunior / Apache Average Memory Usage.md
Created February 19, 2018 14:59
Apache Average Memory Usage
ps -ylC apache2 --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
@jaircuevajunior
jaircuevajunior / mysql_debian_user.md
Last active March 4, 2024 15:13
Fix logrotate error regarding mysql on Ubuntu

Fix logrotate error regarding mysql on Ubuntu

Sometimes if you are mailed of cronjobs, will may got an error like this:

/etc/cron.daily/logrotate:
error: error running shared postrotate script for '/var/log/mysql.log /var/log/mysql/mysql.log /var/log/mysql/mysql-slow.log /var/log/mysql/error.log '
run-parts: /etc/cron.daily/logrotate exited with return code 1

Well, don't panic! Also don't ignore it! :)

@jaircuevajunior
jaircuevajunior / plesk_php_composer.md
Created February 6, 2018 12:32
PLESK - PHP CLI + COMPOSER

PHP

Available versions:

  • 5.2, 5.3, 5.4, 5.5, 5.6, 7.0, 7.1

Example:

/opt/plesk/php/7.1/bin/php

COMPOSER

@jaircuevajunior
jaircuevajunior / change_wordpress_domain.md
Last active July 20, 2019 10:43
Change/Migrate wordpress domain in MySQL

Find/Replace within dump method

This is a very simple method, and for me (as a SysAdmin) it's very practical as I usually make things through SSH terminal.

It's important to say that everything (including text inside posts) that matches the find string WILL BE REPLACED!

For me it's never been a problem so far, but one never knows

First we generate the dump itself, for example:

mysqldump -umyuser -pmypass mydatabase > mydumpfile.sql
setfacl -R -d -m u:artisanuser:rwx storage
setfacl -R -d -m g:www-data:rwx storage

@jaircuevajunior
jaircuevajunior / shrink_xenserver_vm_disk.md
Last active January 22, 2023 10:20
Shrinking XenServer VDI VM Disk

Shrinking XenServer VDI VM Disk

XenServer doesn't allow us to do this kinda shrinking so we better recreate the vm copying all the files and recreating grub (boot) files.

1. Prepare the new disk

  • Create a Virtual Disk with the final desired size (eg our running vm disk has currently 100G and we want to shrinkg it to 80G so this new disk is gonna be 80G)
  • Attach the new disk to the running VM. (For this we'll need to shutdown the vm for a brief moment and power up it back again)
  • Under the VM terminal we format the new disk:
fdisk /dev/xvdb #(n, p, ...) DON'T FORGET TO CREATE THE SWAPP PARTITION!!!
mkfs.ext4 /dev/xvdb1
@jaircuevajunior
jaircuevajunior / elastic_search.md
Last active October 27, 2017 21:17
Install Elastic Search With Auth
@jaircuevajunior
jaircuevajunior / compile_mysql.md
Last active April 7, 2024 12:42
Compile MySQL 5.7 from source
  1. Download build-tools
apt-get install build-essential cmake -y
  1. Configure the compiler
cmake \
-DWITH_BOOST=/usr/local/src/mysql-5.7.19/boost/boost_1_59_0 \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 \
@jaircuevajunior
jaircuevajunior / LAMP_Ubuntu16.md
Last active May 5, 2017 03:35
compile PHP with extensions

apt-get install libbz2-dev libjpeg-dev libpng-dev libfreetype6-dev libmcrypt-dev libxslt-dev

./configure --enable-fpm --enable-pdo --with-pdo-mysql --enable-sockets --enable-exif --enable-ftp --enable-wddx --enable-pcntl --enable-soap --enable-bcmath --enable-mbstring --enable-dba --enable-gd-native-ttf --enable-zip --enable-calendar --with-mysqli --with-pdo-sqlite --with-iconv --with-zlib --with-bz2 --with-gettext --with-xmlrpc --with-openssl --with-curl --with-mhash --with-mcrypt --with-xsl --with-pcre-regex --with-gd --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-ldap --with-pear --with-fpm-user=www-data --with-fpm-group=www-data --with-config-file-path=/etc/php/ --with-libdir=lib/x86_64-linux-gnu