Wednesday, December 21, 2011

Percona Installation

rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm

yum install Percona-Server-client-55 Percona-Server-server-55


1.) Stop mysql:
service mysql stop

2.) Start to Percona server w/o password:
mysqld_safe --skip-grant-tables &

3.) Connect to mysql server using mysql client:
mysql -u root

4.) Setup new MySQL root user password:

mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit


5.) Stop MySQL Server:
service mysql stop

5.) Start MySQL server and test it
service mysql start

Tuesday, July 26, 2011

Delete Files Older Than x Days on Linux

find /backup/* -mtime +5 -exec rm {} \;

How To create a MySQL database and set privileges to a user

mysql> CREATE USER 'root'@'10.0.0.1' IDENTIFIED BY 'password';


mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.0.0.1' WITH GRANT OPTION;


mysql> FLUSH PRIVILEGES;

Thursday, July 21, 2011

Linux – Kill a Process by Name

If you know the command

ps -A

then tou will probable also know

ps -A | grep firefox

now you can manually kill this via

kill -9

Where is from the last output. But how to do this in one line? If your ps command knows:

ps opid= -C firefox
(should print the )

Then you can simply do

kill -9 $(ps opid= -C firefox)

Wednesday, March 2, 2011

Tuesday, February 15, 2011

Clear memory caches on Linux

To free pagecache:

sync; echo 1 > /proc/sys/vm/drop_caches


To free dentries and inodes:

sync; echo 2 > /proc/sys/vm/drop_caches


To free pagecache, dentries and inodes:

sync; echo 3 > /proc/sys/vm/drop_caches


sync should be run because this is a non-destructive operation, and dirty objects are not freeable. So you run sync in order to make sure all cached objects are freed.

Thursday, February 3, 2011

Install and set php extention Memcached

yum install gcc gcc-c++


Install the dependency libevent

cd /usr/local/src
curl -O http://monkey.org/~provos/libevent-1.4.14b-stable.tar.gz
tar xzvf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure --prefix=/usr/local
make && make install


Next, install memcached:

cd /usr/local/src
curl -O http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar xzvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local
make && make install


Lets install the new PECL memcached extension in your web server. This new extension depends on libmemcached. You can grab the latest distribution of libmemcached from https://launchpad.net/libmemcached and compile it in your own machine. Make sure you have the dependencies met.

cd /usr/local/src
wget http://launchpad.net/libmemcached/1.0/0.44/+download/libmemcached-0.44.tar.gz
tar -zxvf libmemcached-0.44.tar.gz
cd libmemcached-0.44
./configure
make && make install


Considering everything went fine, lets install the PECL memcached extension

pecl install memcached


Build process completed successfully
Installing '/usr/lib64/php/modules/memcached.so'
install ok: channel://pecl.php.net/memcached-1.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=memcached.so" to php.ini

Sunday, January 9, 2011

How to Install fastcgi and Nginx on Centos

Install PHP & depends:

yum install gcc pcre-devel openssl-devel php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-imap php-snmp php-pdo php-xml php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-mysql


Download & install spawn-fcgi

cd /usr/local/src
wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
tar -xzvf spawn-fcgi-1.6.3.tar.gz
cd spawn-fcgi-1.6.3
./configure
make & make install


add user nginx

useradd nginx


Create file fastcgi in /etc/init.d/ directory and put

#!/bin/bash
PHP_SCRIPT=/usr/local/bin/php-fastcgi
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php
RETVAL=$?
;;
restart)
killall -9 php
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL



change mode

chmod 755 fastcgi


Create file /usr/local/bin/php-fastcgi

#!/bin/sh
/usr/local/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -f /usr/bin/php-cgi


change mode

chmod 755 /usr/local/bin/php-fastcgi


Download and install nginx

cd /usr/local/src
wget http://sysoev.ru/nginx/nginx-0.8.54.tar.gz
tar -xzvf nginx-0.8.54.tar.gz
cd nginx-0.8.54

./configure --prefix=/usr --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access_log --error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --with-md5-asm --with-md5=/usr/include --with-sha1-asm --with-sha1=/usr/include --with-http_realip_module --with-http_ssl_module --with-http_perl_module --with-http_stub_status_module

make & make install




Create configuration file for nginx /etc/nginx/nginx.conf

worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
sendfile on;
charset utf-8;
gzip on;
gzip_types text/plain application/xml text/javascript;
gzip_min_length 1000;

keepalive_timeout 65;



server {
listen 80;
server_name www.3nky.com;
server_tokens off;
root /home/3nky/public;
index index.php index.html index.htm;

access_log /var/log/nginx/3nky.com-access_log;
error_log /var/log/nginx/3nky.com-error_log;

#location / {
# try_files $uri /index.php;
#}

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


location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}

}
}


Thursday, January 6, 2011

How to install memcached on CentOS

yum -y install gcc gcc-c++


First, install the dependency libevent:

cd /usr/local/src
wget http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz
tar -xzvf libevent-2.0.10-stable.tar.gz
cd libevent-2.0.10-stable
./configure
make
make install



cd /usr/local/src
wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar -xzvf memcached-1.4.5.tar.gz
cd memcached-1.4.5
./configure
make
make install


Locate the file surely that is in /usr/local/lib and make a symbolic link

ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5


run memcached

memcached -u root -d