Archive for the ‘Command Line’ category

Add the date/time to your history

February 23rd, 2010

Edit /etc/bashrc, and add the following:

export HISTTIMEFORMAT="%Y%m%d %H:%M:%S"

Voila!

# history
...
368 20100323 20:46:17 vi /etc/bashrc
369 20100323 20:46:30 exit
370 20100323 20:46:35 date
371 20100323 20:46:36 history
...
#

Share

EasyApache Fails Due to YUM Failing

November 15th, 2009

EasyApache requires a working package manager to be able to run properly, as it needs to confirm several RPMs are up to date before proceeding with the build.

!! The server's system package manager, 'YUM', failed. !!
!!
This is the command that failed:
	yum --exclude=kernel* -y install aspell aspell-devel automake19 gettext
libstdc++.x86_64 libpng-devel openssl libpng-dev zlib-devel autoconf261
libidn-devel gmake libidn libXpm openssl-devel automake coreutils patch
libltdl3-devel libltdl libopenssl0.9.7-static-devel libtool-ltdl-devel
libXpm-devel sed libXpm-dev lsof krb5-dev flex glibc-dev expat-dev krb5-devel
pspell-devel libstdc++-devel.x64_64 xorg-x11-devel libtool-ltdl libssl-dev
pam-devel libopenssl0-devel zlib1-devel expat-devel pspell libopenssl0-dev
expat glibc-devel gcc-c++ zlib bison libjpeg-devel libtool-libltdl-devel
libtool openssl-dev libopenssl0 libz-devel libjpeg-dev pam-dev fileutils
libltdl-devel libopenssl0.9.7-devel e2fsprogs-devel make libstdc++-dev.x86_64
libX11-devel gd cpp xorg-x11-dev gcc ssl-dev autoconf lex
!!
!!
Since EasyApache was unable to resolve it automatically you should:
	1) Manually run the failed YUM command (shown above) via SSH
        2) See if your particular error is addressed at 

http://www.cpanel.net/support/could_not_ensurepkgs.htm

	3) Resolve the YUM problem manually
	4) Re-run EasyApache
!!
!! Please visit 

http://www.cpanel.net/support/could_not_ensurepkgs.htm

 for help with this error. !!

!! Restoring original working apache !!

First things first. Try running ‘yum -y update’ and see if it completes. You may see the following when running yum update.

error: rpmdbNextIterator: skipping h#      27 region trailer: BAD, tag 1507328 type 1507328 offset -1507328 count 1507328
error: rpmdbNextIterator: skipping h#      65 region trailer: BAD, tag 724250418 type 825833527 offset -740320047 count 842150704
error: rpmdbNextIterator: skipping h#      69 region trailer: BAD, tag 942410249 type 1952543335 offset -1702113073 count 842610488
error: rpmdbNextIterator: skipping h#      99 region trailer: BAD, tag 1814980474 type 4544080 offset -1598245200 count 1212502623

and so on and so on….

Then it’ll actually show packages that require updates, and experience a segmentation fault.

---> Package hotplug.x86_64 3:2004_04_01-7.10 set to be updated
---> Package fetchmail.x86_64 0:6.2.5-6.0.1.el4_8.1 set to be updated
--> Running transaction check
Segmentation fault
[root@vps ~]#

This means that your RPM database is corrupt, which is easily fixed with the following:

[root@vps ~]#rm -f /var/lib/rpm/__db.*
[root@vps ~]#rpm -vv --rebuilddb

Once that finishes, run ‘yum update’ again, and it should complete successfully. If so, you’re all set. Go ahead and retry your easyapache build.

Share

How to Disable Stats for a Specific User

November 10th, 2009

You can disable the stats service (Analog Stats, Awstats or Webalizer) for a specific user by doing the following:

1) Login to your server via ssh.

2) Edit /var/cpanel/users/username, and add any of the following, as needed:

skipanalog=1
skipawstats=1
skipwebalizer=1

3) Now we’ll restart the cPanel service:

/etc/init.d/cpanel restart
Share

How to install rtorrent

November 10th, 2009

This isn’t really cPanel related, and probably shouldn’t be run from your cPanel production server, but I’m posting nonetheless, as I like to be able to reference this stuff for myself at times :)

If you don’t want to compile rtorrent from source, you can install via RPM by adding Fedora’s EPEL repository:

http://fedoraproject.org/wiki/EPEL/FAQ#howtouse

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
yum install libtorrent rtorrent libsigc++20-devel
Share

How to strace cPanel software

November 10th, 2009

From time to time, strange issues pop up which aren’t going to be logged to an error log. For some of the more “hard to track down” issues, you can use strace to see just what the process is doing, and where your issue might be.

This article won’t go into how to read straces, as there are many other articles written about this, but I’ll provide a good base from which to start.

strace -v -o /root/strace.cpanel -f -s 4096 -p `cat /var/run/cpsrvd.pid`

That command uses several flags, outputting the strace to a file called strace.cpanel.

-v enables a more verbose output
-o specifies the file to output the contents to. If not specified, it will output directly to your terminal.
-f includes all processes forked by the process you’re stracing
-p will specify the PID. In this case, we’re going to cat the pic from cpsrvd.pid

Share

How to Enlarge /tmp on cPanel Servers

October 31st, 2009

If you don’t have a separate /tmp partition defined, you’re likely using cPanel’s tmpDSK method of setting up /tmp. By default, this “partition” is 512M in size, and for many that’s enough, but others need a larger /tmp.

So first, let’s edit /scripts/securetmp, and modify $tmpdsksize to increase the number of bytes this partition should have.
securetmp
Once you’ve set the value for $tmpdsksize, save the file, and let’s see what processes are using /tmp.

lsof /tmp

Likely, you’ll see a few MySQL and Apache processes. Now we’ll stop these processes (and any others using /tmp) so that we can unmount it.

service httpd stop
service mysql stop

Then umount /tmp and /var/tmp:

umount -l /tmp
umount -l /var/tmp

Then remove the old tmpDSK:

rm -fv /usr/tmpDSK

Then create your new /tmp:

/scripts/securetmp
Share

How to Enable and Repair Quotas in cPanel

October 31st, 2009

Quotas can be kind of a pain sometimes. If your accounts are showing 0 disk space used, be sure that you have enabled quotas in cPanel. Most people select this option during the initial cPanel configuration, but you can always enabled them later in WHM -> Initial Quota Setup. Once you’ve done that, let’s ensure that quotas are enabled on your partitions. You really only need them enabled on /home and /var. If you have a single partition, enable them on /.

fstab

If you needed to add usrquota to your /home partition, save your changes in /etc/fstab, and remount /home with

mount -o remount /home

Now we can run the following to repair the quotas:

/scripts/fixquotas

There are still plenty more ways that quotas can break, and dozens of errors associated with broken quotas, which I hope to go into deeper in the future.

Share

How to Install Logwatch

October 31st, 2009

Logwatch is very simple to install on CentOS boxen:

yum -y install logwatch

This will install logwatch and configure the daily logwatch cron in /etc/cron.daily. If you want to customize your logwatch configuration, you can edit /etc/logwatch/conf/logwatch.conf and modify settings like the email address the report is sent to, the verbosity of the report, what day you want logwatch to process, etc. A sample configuration is located at /usr/share/logwatch/default.conf/logwatch.conf

Share

Install SSH2 for PHP

October 16th, 2009
wget http://downloads.sourceforge.net/project/libssh2/libssh2-1.2.1.tar.gz?use_mirror=softlayer
 tar -zxvf libssh2-0.12.tar.gz
 cd libssh2-0.12
./configure && make all install

Run the pear installer for PECL/ssh2:

pear install ssh2

If this installing via pear fails,

wget http://pecl.php.net/get/ssh2-0.11.0.tgz
 tar -zxvf ssh2-0.11.tgz
 cd ssh2-0.11
 phpize && ./configure --with-ssh2 && make

Copy ssh2.so to /usr/local/lib/php/extensions/no-debug-non-zts-20020429.

 cp modules/ssh2.so /usr/local/lib/php/extensions/no-debug-non-zts-20020429

Add extension=ssh2.so to /usr/lib/php.ini
Run service restart httpd to enable these changes.

Share

no listening sockets available, shutting down

September 24th, 2009

(98)Address already in use: make_sock: could not bind to address [::]:80
no listening sockets available, shutting down
Unable to open logs

First let’s see what process is listening on that port:

lsof -i :80

Once you see what process is listening, you can kill it off

kill PID

replacing PID with the process ID number.

Share

cPanel Web Site Hosting by IntraHost