Monday, November 8, 2010

How to stop core file generation in the server from php?

■ Requirement : stop core file generation in the server from php
■ OS Environment : Linux[RHEL, Centos]
■ Application: ulimit
■ Implementation Steps : 

          A core file records memory image of running process.when a php process is killed, apache creates core files under your account.These core files take too much of space on server.There is no harm on deleting these files.You can get rid off these core files by modifying the httpd start up file.

Edit /usr/sbin/httpd and make ulimit like below :

ulimit -c 0 



eth0 errors +WARNINGS packets is + outside range

■ Error : eth0 error "WARNINGS: packets is outside range"
■ OS Environment : Linux[RHEL, Centos]
■ Application: ethtool
■ Symptom  :

  Following messages had been received from munin monitoring service :

eth0 errors
WARNINGs: packets is 1.52 (outside range [:1]).

■  Investigation : 
            My basic concept is, either eth0 is being overloaded or isn't compatible with kernel or OS. So, I checked the settings of the eth0 and RX(receive) and TX(transmit) packet errors and I found that there is error at RX. It looks like below :

$ethtool eth0
[...]
RX packets:162432463 errors:3770202 dropped:0 overruns:0
frame:3770202
TX packets:258975594 errors:0 dropped:0 overruns:0 carrier:0
[....]

You can use other commands to check the continuous traffic statistics of the card like :

$ watch -n 1 cat /proc/net/dev
$ sar -n DEV|more
$ netstat -plan --interfaces=eth0

I contacted the owner of the server and he assured me that the maximum speed of the NIC is 1GB/sec.

■ Resolution :

Increased speed to 1 Gbs. 

$ethtool -s eth0 speed 1000 duplex full

Sunday, November 7, 2010

How to access the webalizer from the outside of the cpanel?

■ Requirement : How to access the webalizer from the outside of the cpanel
■ OS Environment : Linux[RHEL, Centos]
■ Application:cpanel
■ Assumption : domain is domain.com
■ Implementation Steps : 

$ /scripts/whoowns domain.com
domain
$  cd ~domain
$ cd public_html/
$ pwd
/home/domian/public_html
$ ln -s /home/domian/tmp/webalizer stats
$ chown domain. stats
$ chmod 755 ~domain/tmp -R

Now access http://domain.com/stats

Thursday, November 4, 2010

How to change admin password in the table of the mysql database?

■ Requirement : How to change admin password in the table of the mysql database
■ OS Environment : Linux[RHEL, Centos]
■ Application: mysql
■ Implementation Steps : 


mysql> update agb_book_auth set password=MD5("newwpass") where username="admin";

Where table agb_book_auth contains admin and password attributes.

OR :

mysql> update wp_users set user_pass = 'b15a2021cb835426552c5d8599d5c7ab' where user_login = 'admin';
mysql> flush privileges;


Plesk configuration files path + linux?

■ Requirement :  Location of plex configuration files
■ OS Environment : Linux[RHEL, Centos]
■ Application:plex
■ Implementation Steps : 

Here are the paths :

Plesk Config & Binary file

Linux :

===========================================================
# Plesk tree
PRODUCT_ROOT_D - /usr/local/psa
==================================================
# Directory of SysV-like Plesk initscripts
PRODUCT_RC_D - /etc/init.d

/etc/psa/psa.conf // common config file
/etc/psa/.psa.shadow // admin password file
/var/log // common log file
/etc/local/psa/admin/logs //plesk log file
================================================

# Directory for config files
PRODUCT_ETC_D - /usr/local/psa/etc
================================================

# Virtual hosts directory
HTTPD_VHOSTS_D - /var/www/vhosts
/var/www/vhosts//anon_ftp , cgi-bin, conf, error_docs , httpdocs, httpsdocs , pd , private , statistics-->/logs(domain logs), subdomains , web

Domain based httpd.conf file:- /var/www/vhosts/
conf/httpd.include
Doc root : /var/www/vhosts/
/httpdocs
===============================================

# Apache configuration files directory
HTTPD_CONF_D - /etc/httpd/conf/httpd.conf //server based
/var/www/vhosts/
conf/httpd.include // domain based
------------------------------------------------------------------------------------------------------------
# Apache include files directory
HTTPD_INCLUDE_D - /etc/httpd/conf.d/mailman.conf , perl.conf, python.conf , webalizer.conf, zz010_psa_httpd.conf, fcgid.conf, manual.conf , php.conf, ssl.conf, welcome.conf
------------------------------------------------------------------------------------------------------------
# Apache binary files directory
HTTPD_BIN_D - /usr/bin
--------------------------------------------------------------------------------------------------------------
#Apache log files directory
HTTPD_LOG_D - /var/log/httpd
-----------------------------------------------------------------------------------------------------------
#apache startup script
HTTPD_SERVICE httpd
/etc/init.d/httpd [start|stop|restart|status]


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

# Qmail directory
QMAIL_ROOT_D /var/qmail

# Location of qmail maildirs
QMAIL_MAILNAMES_D /var/qmail/mailnames/
/var/qmail/mailnames/
/mail a/c/Maildir/new,cur,tmp
# Path to rblsmtpd
RBLSMTPD /usr/sbin/rblsmtpd

# Courier-IMAP
COURIER_IMAP_ROOT_D /

/etc/init.d/qmail [status,start,stop,restart] //service control

================================================
# Proftpd
FTPD_CONF /etc/proftpd.conf
FTPD_CONF_INC /etc/proftpd.include
FTPD_BIN_D /usr/bin
FTPD_VAR_D /var/run/proftpd
FTPD_SCOREBOARD /var/run/proftpd/scoreboard

Log file :- /var/log/xferlog
Service control :- /etc/init.d/proftpd [start,stop,status,restart]
================================================
# Bind
NAMED_RUN_ROOT_D /var/named/run-root/etc/named.conf
/var/named/run-root/var/
// db record

Service control :- /etc/init.d/named [status,start,stop,restart]
log:- /var/log/messages
===============================================

# Webalizer
WEB_STAT /usr/bin/webalizer
===============================================
# Logrotate
LOGROTATE /usr/local/psa/logrotate/sbin/logrotate
===============================================
# MySQL
MYSQL_VAR_D /var/lib/mysql
MYSQL_BIN_D /usr/bin

Service control:- /etc/rc.d/init.d /mysqld [start,stop,restart,status]
log :- /var/log/messages
===============================================
# PostgreSQL
PGSQL_DATA_D /var/lib/pgsql/data
PGSQL_BIN_D /usr/bin
===============================================
# Backups directory
DUMP_D /var/lib/psa/dumps
===============================================
# Mailman directories
MAILMAN_ROOT_D /usr/lib/mailman
MAILMAN_VAR_D /var/lib/mailman
===============================================
# Python binary
PYTHON_BIN /usr/bin/python2.3

# Tomcat root directory
CATALINA_HOME /usr/share/tomcat5

# DrWeb
DRWEB_ROOT_D /opt/drweb
DRWEB_ETC_D /etc/drweb

# GnuPG binary
GPG_BIN /usr/bin/gpg

# Tar binary
TAR_BIN /bin/tar
===============================================
# Curl certificates
CURL_CA_BUNDLE_FILE /usr/share/curl/curl-ca-bundle.crt
=========================================================
# AWStats
AWSTATS_ETC_D /etc/awstats
AWSTATS_BIN_D /var/www/cgi-bin/awstats
AWSTATS_TOOLS_D /usr/share/awstats
AWSTATS_DOC_D /var/www/html/awstats
===============================================
# openssl binary
OPENSSL_BIN /usr/bin/openssl

LIB_SSL_PATH /lib/libssl.so
LIB_CRYPTO_PATH /lib/libcrypto.so

CLIENT_PHP_BIN /usr/local/psa/bin/php-cli
--------------------------------------------------------------------------------------------------
Psa Spammasion:-
/usr/local/psa/admin/bin/spamd --status
--stop
--start
--------------------------------------------------------------------------------------------------


How to delete file using inode number?

■ Requirement : How to delete file using inode number
■ OS Environment : Linux[RHEL, Centos]
■ Application: find, inode
■ Implementation Steps : 

To view the inode number :

$ ls -il

Assume indoe is 782263 :

Delete file which has inode  782263 :

$ find . -inum 782263 -exec rm -f {} \;




Wednesday, November 3, 2010

How to setup loop device?

■ Requirement : How to setup loop device?
■ OS Environment : Linux[RHEL, Centos]
■ Implementation Steps : 

         In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loopback file interface) is a pseudo-device that makes a file accessible as a block device.


$losetup /dev/loop0 example.img
$ mount /dev/loop0 /home/you/dir


     The second command mounts the device on the directory /home/you/dir. The overall effect of executing these two commands is that the content of the file is used as a file system rooted at the mount point.

The mount utility is usually capable of handling the entire procedure:

mount -o loop example.img /home/you/dir