# cd <images_folder_orig>
# for IMAGE in $(find . -regextype posix-extended -regex '.*\.(jpg|jpeg|png)'); do jpegtran -copy none -progressive $IMAGE > ./optimized/$IMAGE ; done
# cd .. ; mv <images_folder_orig> <images_folder_orig>.backup ; ln -s optimized/ <images_folder_orig>
apache compilation
-----------------------------------------------------------------------
#!/bin/bash
version='2.4.12'
pushd /usr/src/
if [ ! -f /usr/src/httpd-${version}.tar.bz2 ]; then
wget http://apache.volia.net/httpd/httpd-${version}.tar.bz2
fi
rm -rf /usr/src/httpd-2.4.12
tar xvf httpd-${version}.tar.bz2
cd /usr/src/httpd-${version}
/usr/bin/make clean
./configure \
--prefix=/usr/local/apache-2.4 \
# --with-apr=/usr/local/apr-1.4.8 \
# --with-apr-util=/usr/src/apr-util-1.5.2
/usr/bin/make -j8
/usr/bin/make install
#/usr/src/compile-mod_umask.sh
#/usr/local/apache-2.4/bin/apxs -a -i -c /usr/src/mod_umask/src/mod_umask.c
popd
---------------------------------------------------------------------------------
php compilation :
---------------------------------------------------------------------------------
#!/bin/bash
version='5.6.9'
_wget='/usr/bin/wget'
_rm='/bin/rm'
_tar='/bin/tar'
_make='/usr/bin/make'
if [ ! -f /usr/src/php-${version}.tar.bz2 ] ; then
${_wget} http://ua2.php.net/distributions/php-${version}.tar.bz2
fi
pushd /usr/src/
${_rm} -rf php-${version}
${_tar} xvf php-${version}.tar.bz2
cd /usr/src/php-${version}
${_make} clean
./configure \
--prefix=/usr/local/php-5.6 \
--with-apxs2=/usr/local/apache-2.4.12/bin/apxs \
--with-config-file-scan-dir=/usr/local/php-5.6/etc/ext-active \
--with-mysql=/usr \
--with-mysqli \
--enable-dba \
--enable-intl \
--with-pdo-mysql=mysqlnd \
--with-bz2 \
--with-gd \
--with-gettext \
--with-zlib \
--enable-zip \
--enable-opcache \
--enable-fpm \
--enable-mbstring \
--with-curl \
--with-mcrypt
${_make} install -s
popd
-------------------------------------------------------
phpredis install script (gentoo, php 7)
--------------------------------
#!/bin/bash
php_ver='7.0'
if [ -d phpredis ]; then
rm -rf phpredis
git clone https://github.com/phpredis/phpredis.git
fi
cd phpredis
git checkout php7
/usr/lib64/php${php_ver}/bin/phpize
aclocal; libtoolize --force; autoheader; autoconf
PATH=/usr/lib64/php${php_ver}/bin/:$PATH ./configure
make
make install
if [ -f /etc/php/apache2-php${php_ver}/ext/redis.so ]; then
bash -c "echo extension=redis.so > /etc/php/apache2-php${php_ver}/ext/redis.ini"
fi
if [ -f /etc/php/apache2-php${php_ver}/ext-active/redis.so ]; then
cd /etc/php/apache2-php${php_ver}/ext-active/ && ln -s ../ext/redis.so
fi
--------------------------------------------------------------
mysqldump <source_db> <source_table> | gzip -9 | ssh <target_server_IP> "gunzip - | mysql <target_db>"
via cron:
*/10 * * * * root mysqldump --defaults-extra-file="/root/.my.cnf" <source_db> <source_table> | gzip -9 | ssh <target_server_IP> "gunzip - | mysql <target_db>"
example:
mysqldump testdb table1 | gzip -9 | ssh 192.168.0.1 "gunzip - | mysql testdb2"
in /etc/crontab :
*/3 * * * * root /usr/local/bin/check_la.sh
------------------------------------------
/usr/local/bin/check_la.sh :
if [[ $(uptime | sed -e 's/.*average:\ \(.*\)\..*,.*,.*/\1/') -ge 16 ]]; then
/usr/local/bin/stat.sh > /var/tmp/stat-$(date "+%Y_%d_%m-%H:%M")
fi
-----------------------------------------
/usr/local/bin/stat.sh :
#!/bin/sh
make_stat() {
echo -e "\n\n\n========================= processes ===================\n"
ps wwaux
echo -e "\n\n\n========================= http requests ===================\n"
links -dump http://localhost/server-status
echo -e "\n\n\n========================= mysql threads ==================="
mysql -u root --exec "SHOW FULL PROCESSLIST"
echo -e "\n\n\n========================= network connections ===================\n"
netstat -ant
echo -e "\n\n\n========================= memory ===================\n"
free
echo -e "\n\n###############################################\n\n"
}
if [ $(ps aux | grep apache | wc -l) -ge 2 -a $(ps aux | grep mysql | grep -v grep | wc -l) -ge 0 ] ; then
outfile=${1:-/dev/stdout}
cat /dev/null > $outfile
make_stat >> $outfile
fi