Thursday, September 30, 2010

Mysql-Proxy

Mysql-proxy installation and configuring on FreeBSD server

Mysql proxy is a intermediate between mysql client and mysql server.


# cd /usr/ports/
#make search name=mysql-proxy --> from there you will get the port path
# cd /usr/ports/databases/mysql-proxy
# make
# make install

on /etc/rc.conf we need to add the following settings

mysql_proxy_enable="YES"
mysql_proxy_address=":3307" --> port no
mysql_proxy_backend_addresses="proxing server IP:3306"
mysql_proxy_args="--user=mysql"

next /usr/local/etc/rc.d/mysql-proxy restart

finally confirm mysql-proxy is running and listening on the correct port
# ps aux |grep sql

Any mysql connection to this server would be redirected to sql server on your proxing server IP(DB server ip):3306

Monday, September 27, 2010

VPS RAM

Setting RAM for a VPS(openVZ)

1. 512MB GUARANTEED RAM and 1024MB Burst RAM
vzctl set VEID --vmguarpages 512M --save
vzctl set VEID --oomguarpages 512M --save
vzctl set VEID --privvmpages 512M:1024M --save

easyapache run issue.

sh-3.2# /scripts/easyapache
cPanel Update (upcp) is currently running. Please wait for upcp to complete, or kill off all upcp processes and try again.
sh-3.2# ps aux | grep upcp
root 11611 0.0 0.0 3080 728 pts/1 S+ 05:12 0:00 grep upcp
root 24126 0.0 0.0 2488 980 ? Ss 04:31 0:00 /bin/sh -c sleep $((RANDOM % 7100)); /bin/nice -n +19 /scripts/upcp --force
sh-3.2# kill -9 24126

then you run your easyapche script it will work. this upcp is cpanel cron that is executing as per your your cron setting.

sh-3.2# /scripts/upcp --force
Running Futex Check/Fix......Done
cPanel Update (upcp) is already running. Please wait for the previous upcp to complete, or kill off all upcp processes and try again. You may wish to use '--force'
sh-3.2# ps aux | grep upcp
root 13417 0.0 0.4 6900 5240 ? S 01:24 0:00 cPanel Update (upcp) - Master
root 13576 0.0 0.4 6900 4476 ? Ss 01:24 0:00 cPanel Update (upcp) - Slave
root 19519 0.0 0.0 1916 548 pts/2 S+ 01:26 0:00 grep upcp
sh-3.2# kill -9 13417
sh-3.2# kill -9 13576

Changing Port No

1. Changing FTP port number
# ps aux | grep ftp --> to check which ftp server
if it is pure-ftpd
# vi /etc/pure-ftpd.conf
under IP address/port to listen to add a new line as Bind *,2121
# service pure-ftpd restart
Replace the same port on your csf configuration file /etc/csf.conf and restart csf

2. Changing ssh port
# vi /etc/ssh/sshd_config
#Port 22 default line to Port 9555(as you required, not 0-1024)
# service sshd restart
Replace the same port on your csf configuration file /etc/csf.conf and restart csf

Sunday, September 26, 2010

Unable to delete a email account

Using your Cpanel you can not delete a particular email account [cpanel >> mail >> Email Accounts]
Error:-
The e-mail address user@yourdomain.com deleted successfully.Sorry, you do not have access to the domain yourdomain.com

Delete the entries from
1. vi /home/ajeeshc/etc/ajeesh.com/passwd
ajeesh:x:506:503::/home/ajeeshc/mail/ajeesh.com/ajeesh:/bin/bash --> for ajeesh@ajeesh.com
2. vi /home/ajeeshc/etc/ajeesh.com/shadow
3. vi /home/ajeeshc/.cpanel/email_accounts.yaml

ajeesh:
diskquota: 262144000
diskused: 0
mtime: '1285469016' -->
4. rm -rf /home/ajeeshc/mail/ajeesh.com/ajeesh/

0.00MB Mysql DB size

On your Cpanel > MySQL Databases > Current Databases size shows as 0.00 MB

To correct this please do the following process
1. vi /var/cpanel/cpanel.config
disk_usage_include_sqldbs value should be "0" change to "1" and wq from your vi editor
ie, it should be as disk_usage_include_sqldbs=1

2. # /scripts/update_db_cache

3. Login to WHM >> Main >> Server Configuration >> Tweak Settings
put "tick" mark for "Calculate the disk usage of account MySQL and PostgreSQL databases" under SQL section
By default it is tick marked in WHM

This will fix your issues. :)

PPP [Pear to Pear] module installation on OpenVz VPS

For enable PPP you need Hardware Node access.
To insert module to your existing Kernel.Please do the following steps
1. # modprobe ppp_async
2. # modprobe ppp_deflate

To check the module installed or not
3. # lsmod | grep ppp


4. # vzctl set VEID –devices c:108:0:rw –save
5. # vzctl exec VEID mknod /dev/ppp c 108 0
6. # vzctl exec VEID chmod 600 /dev/ppp

7. # vzctl restart VEID

8. # vzctl enter VEID

9. # /usr/sbin/pppd --> for confirming

Thursday, September 23, 2010

Removing malicious Code

Removing malicious Code from your pages:-

Once your server compromised or hacked, most case they have insert some malicious Codes/ scripts on all your web pages. So these following commands will help you to remove completely from your server.

First we need to identify which files are infected with malicious Code/malicious Scripts, for that we can use the following command
1. grep -Ri SEARCH WORD DIRECTORYNAME
OR
2. grep -Ri --files-with-matches 'searchword' directorname(or). for current directory

Script for searching a word in a file and delete that line

#!/bin/bash
grep -rl --include=*.{php,js,html} 123 $1 | xargs sed -i".bckp" '/123/d'
rm -f $1/*.bckp

Sunday, September 19, 2010

Friday, September 17, 2010

WORDPRESS

1. Fatal error:Call to undefined function wp() in /home/user/public html/wp-blog-header.php on line14

Solution:-
This issue is due to your wordpress wp-config.php content. For my case wp-config.php content was null. So i have copied the wp-config.php from backup and solve this issue.

or if you dont have one, there is one example:wp-config-sample.php change the name of that file to wp-config.php and change the database connection configures

2.Wordpress site very slow
This might be because of the plugins that you have installed on your wordpress site. Try disabling the last installed plugin or disable them all. To disable, you can follow the following steps
Cpanel --> PhpMyadmin --> Select Database -->> wp-options -->>select active_plugins(will be on page 2) -->>Edit
Copy down the plugins to somewhere else
Remove the plugins from there
Click GO
Then we can re enable it one by one form wordpress admin dashboard, so that we can find the plugin which caused the problem.
NB: If this solution is not successful, you can check these options: Upgrade to the Latest Version, Check With The Host, Optimize the Database, Verify That it Isn’t A Connectivity Issue,

3.Blank Pages in home page or admin page

This is due to recently added plugin , so we can avoid this by disable the last activated plugin by using your PHPMYADMIN[ select the particular database from wp_options > active_plugins]

or this may due to the wrong theme selection , all your wordpress themes are located on /wp-content/themes directory. So we can select the correct theme to "template" and "stylesheet" fields on your Phpmyadmin >> wp-options

*Idea from Dan Thompson

4. Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/user/public_html/wp-content/plugins/web-traffic-genius-pro/curl_functions.php on line 80 or 37 etc

In this situation we need to check php.ini whether safe_mode set to OFF and open_basedir is comment out. In my case open_basedir was not comment out. So i have copied a php.ini file to wp-admin directory and change the line as ;open_basedir = "/home:/tmp:/usr"

5 Problems when trying to open a post from categories list.
or RSS Feed time out

Solution:- Try disabling all your plugins, then see if you can access the feed and the categories. If you can, you then need to re-activate the plugins 1 by 1 until you find which one is causing the site to stop loading correctly.

6 increase the upload size
Solution: copy a php.ini file on your home directory and paste the line
upload_max_filesize = 32M(your required size)

Friday, September 10, 2010

Advanced DNS Zone Editor

For enabling Advanced DNS Zone Editor on your cpanel Please do the following

Main >> Packages >> Feature Manager
Edit a Feature List (Click "Edit") There you can put tick mark on your required fields.

Wednesday, September 8, 2010

DDOS ATTACK

Symptoms
*Unusual slow network performance
*Unavailability of a particular web site
*Inability to access any web site
*increase the number of spam emails

There are some paid services are there for doing this DDOS attack for the compting companies server to put down. What they are doing , accessing the website from different geo-location/IPs . That is the no of connections made by them should be greater your web server able to handle.

Following command will give you a sorted list of IP addresses that are being connected to the server at port 80:-
netstat -n | awk '{ print $5 }' | cut -d ":" -f 1 | grep "[1-9]" | sort | uniq -c | sort -n
netstat -plan |grep :80 | awk '{print $5}' |cut -d: -f1 |sort |uniq -c |sort -n

You can use the following command to block the IP address:-
iptables -A INPUT -s IP --dport 80 -p tcp -j DROP


There are some scripts will automatically help you against DoS attacks on your server

1. DDoS Deflate

They are using the command " netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n " on their script.

Configuration file is located on /usr/local/ddos/ddos.conf

IP addresses are automatically unblocked after a preconfigured time limit (default: 600 seconds)

To install, simply follow these directions:-

cd /usr/local/src/
wget http://www.inetbase.com/scripts/ddos/install.sh
chmod 0700 install.sh
./install.sh


Installing DOS-Deflate 0.6

Downloading source files.........done
Creating cron to run script every minute.....(Default setting).....done
Installation has completed.
Config file is at /usr/local/ddos/ddos.conf
Please send in your comments and/or suggestions to zaf@vsnl.com
quit from the page

After installing we can do the configuration on /usr/local/ddos/ddos.conf with your favourite editor

NO_OF_CONNECTIONS=150 (it is the default value)
BAN_PERIOD=600(it is the default value) it means Number of seconds the banned ip should remain in blacklist.

==================
Hardening sysctl.conf

/etc/sysctl.conf using your favorite text editor and add the following

# Enable IP spoofing protection, turn on Source Address Verification
net.ipv4.conf.all.rp_filter = 1
# Enable TCP SYN Cookie Protection
net.ipv4.tcp_syncookies = 1

After that Add the below code in /etc/rc.local and restart network

for f in /proc/sys/net/ipv4/conf/*/rp_filter;
do echo 1 > done
echo 1 > /proc/sys/net/ipv4/tcp_syncookies

===================

Monday, September 6, 2010

IP TABLE MODULE LOAD ISSUE ON OPENVZ

ftp connection to the server failed and it will throw an error like

[ajeesh@tech24 ~]$ ftp ftp.yourdomain.com
Connected to ftp.yourdomai.com (IP).
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.

Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode ()
ftp: connect: Connection timed out

Solution:-

pure-ftpd you could add the port range 30000:35000 to TCP_IN and add the following line to /etc/pure-ftpd.conf and then restart pure-ftpd:

PassivePortRange 30000 35000

after that we need to enter the port range 30000:35000 on /etc/csf/csf.conf on the line ' TCP_IN = ' [Allow incoming TCP ports]

This will fix my issue

Related issue also fixed
*WARNING* Since the Virtuozzo VPS iptables ip_conntrack_ftp kernel module is currently broken you have to open a PASV port hole in iptables for incoming FTP connections to work correctly. See the csf readme.txt under 'A note about FTP Connection Issues' on how to do this if you have not already done so.

csftest.pl
Testing ipt_recent...FAILED [Error: iptables: Unknown error 18446744073709551615] - Required for PORTFLOOD feature


=====================
To activate passive mode in Firewall Pf and FTP server PureFtp.
1. First we need to check the conf of pureftp PassivePortRange
Suppose it is 30001 32000
2. open your pf configuration file /etc/pf.conf and enter the following rule
pass in on $ext_if proto tcp from any to any port 30000 >< 32001 keep state
3. ipf -Fa -f /etc/ipf.rules;sleep 40;ipf -Fa :- for testing the firewall for 40 sec
4. if step 3 is ok then reload your pf firewall : ipf -Fa -f /etc/ipf.rules
=======================

FFmpeg FFmpeg-PHP Mplayer Mencoder flv2tool LAME MP3 Encoder INSTALLATION

Here We can discus how to install FFMPEG and it associated friends ( Supporting Software) on Linux Servers.
FFmpeg
FFmpeg-PHP
Mplayer Mencoder
flv2tool
LAME
MP3 Encoder

****************

For Installing FFMPEG and its friends we need to make sure the following packages already installed on your server
gcc,gmake,make, libcpplibgcc, libstdc++, gcc4, gcc4-c++, gcc4-gfortran, subversion, ruby ncurses-devel -y

If not please install these packages using yum
yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran subversion ncurses-devel -y
Install Ruby, Ruby Gem, Fastthread, Mongrel and Rails on cpanel servers by using the command
/scripts/installruby
Please do the following Steps

cd /usr/local/src/

Next We need to Download the required MODULES .
wget www3.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
wget rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz

wget superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.1.tbz2
Or
wget http://space.dl.sourceforge.net/project/ffmpeg-php/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2

wget downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz

and wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.0.tar.gz

After that extract these downloaded MODULES using ' tar zxf filename '

mkdir /usr/local/lib/codecs/

By using Subversion we can down load packages for FFMPEG and Mplayer
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer

svn update

PS: Please note that now the SNV version has been not updated for a long time so it is good to use git installation instead of SNV: 19-08-2011(Firday)
cd /usr/local/src/
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

After that We can install one by one packages

LAME:-
cd /usr/local/src/lame-3.97
./configure
make && make install

LIBOGG:-
cd /usr/local/src/libogg-1.1.3
./configure --enable-shared && make && make install

PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

LIBVORBIS:-
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install

FLVTOOL2:-
cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

MPLAYER:-
cd /usr/local/src/mplayer
./configure && make && make install

FFMPEG:-
cd /usr/local/src/ffmpeg/
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
make
make install

export LD_LIBRARY_PATH=/usr/local/lib/

ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52

FFMPEG-PHP Extension:-
cd /usr/local/src/
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download

[0.50 version throws me error once i have used this version fixed my error]

tar -xjf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0/
phpize
./configure
make
make install

make install will shows you the extension file directory for ffmpeg.so. This Exension should be include in your php.ini file

extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/ffmpeg.so

Finally Restart Appache
service httpd restart

Veryfy: Create a info.php file (ie,) and verify this module is loaded or not.

*************************************
While compiling ffmpeg-php Error:ffmpeg_frame.c:421: error: ‘PIX_FMT_RGBA32’ undeclared (first use in this function)

/usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zif_ffmpeg_frame_toGDImage’: /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function) /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: (Each undeclared identifier is reported only once /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:336: error: for each function it appears in.) /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c: In function ‘zif_ffmpeg_frame_ffmpeg_frame’: /usr/src/ffmpeg-php-0.6.0/ffmpeg_frame.c:421: error: ‘PIX_FMT_RGBA32′ undeclared (first use in this function)


***********************
update ffmpeg_frame.c and replace every instance of PIX_FMT_RGBA32 with PIX_FMT_RGB32

vi ffmpeg_frame.c

:%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

:w :q!

Solve my issue

**********************
# ffmpeg -v
ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

Fix:
location of these libraries is /usr/local/lib/ such as /usr/local/lib/libavdevice.so.52 .

ln -s /usr/local/lib/libavdevice.so.52 /usr/lib/libavdevice.so.52
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
etc ... like we done for ibavformat.so.50

Or we can fix by

/etc/ld.so.conf.d/libc.conf open with your favourite editor and include this line /usr/local/lib

if /etc/ld.so.conf.d/libc.conf not there create one called /etc/ld.so.conf.d/ffmpeg.conf (or even libc.conf) and add the line /usr/local/lib in it, then run sudo ldconfig -v.


Iam Expecting some valuable suggestions on this posting
 *******

Error :   [STDERR] PHP Warning: Module 'ffmpeg' already loaded in Unknown on line 0

This seems you have multiple entries for ffmpeg.so extension on your php.ini file. So you need to check this file and remove the unwanted extension for ffmpeg.


*** THANK YOU ****

If you want to install ffmpeg and its components on your server please contact me on +91956799499 and i will help on this. Free of cost :)

Enhanced by Zemanta

Saturday, September 4, 2010

YUM ERROR

YUM INSTALLATION ERROR
ERROR:-Loaded plugins: presto, refresh-packagekit
Existing lock /var/run/yum.pid: another copy is running as pid 2448.
Another app is currently holding the yum lock; waiting for it to exit...
The other application is: yum
Memory : 51 M RSS ( 79 MB VSZ)
Started: Sat Sep 4 20:17:17 2010 - 10:34 ago
State : Traced/Stopped, pid: 2448
==========================================================
To solve this issue . Please do the following
From this message you can easily find out what process ID is for yum. It is 2448 or you can find out the yum process ID by using the following command

[root@localhost ajeesh]# ps aux | grep yum
root 2448 0.5 2.5 80520 52392 pts/1 T 20:17 0:04 /usr/bin/python /usr/bin/yum install lynx*

nest step please kill that process and re-execute your yum install again

This solve my yum install issue