Pages

Saturday, December 30, 2017

How can I reboot my VPS from SSH?

To reboot your VPS using SSH, run as root the following command: 

reboot

How to solve: cPanel update failure: ***** FATAL: Cannot proceed. Needed system RPMs were not installed

On your VPS or dedicated server running CloudLinux (or CentOS switched to CloudLinux) you may find this problem while trying to upgrade your cPanel to the newest version:

[20130322.110359] Error: Protected multilib versions: libwmf-lite-0.2.8.4-22.el6.i686 != libwmf-lite-0.2.8.4-22.el6.centos.x86_64
[20130322.110359] You could try using --skip-broken to work around the problem
[20130322.110400] ** Found 5 pre-existing rpmdb problem(s), 'yum check' output follows:
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(bandmin.conf)
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(bmversion.pl)
[20130322.110400] bandmin-1.6.1-5.noarch has missing requires of perl(services.conf)
[20130322.110400] exim-4.80-5.x86_64 has missing requires of perl(SafeFile)
[20130322.110400] frontpage-2002-SR1.2.i386 has missing requires of libexpat.so.0
[20130322.110400] Prelinking shared libraries and binaries: /usr/sbin/prelink -av -mR
[20130322.110405] E Sysup: Needed system RPMs were not installed: libwmf
[20130322.110405] ***** FATAL: Cannot proceed. Needed system RPMs were not installed.
[20130322.110405] The Administrator will be notified to review this output when this script completes
[20130322.110405] E Detected events which require user notification during updatenow. Will send iContact the log
=> Log closed Fri Mar 22 11:04:05 2013
[20130322.110405] E Running `/usr/local/cpanel/scripts/updatenow --upcp --log=/var/cpanel/updatelogs/update.1363968224.log --force` failed, exited with code 4608

How to whitelist your IP at CPHulk

cd/script
 
./cphulkdwhitelistxxx.xxx.xxx.xxx

Just don’t forge to replace xxx.xxx.xxx.xxx with your IP addres

How do I disable SSH login for the root user?

Instructions

NOTE: In the following example, we are using admin for the username. This is just a example and can be replaced with any username you wish to use.

1. Add the user. In the following example, we will use the user name admin. The command adduser will automatically create the user, initial group, and home directory.

[root@root ~]# adduser admin
[root@root ~]# id admin
uid=10018(admin) gid=10018(admin) groups=10018(admin)

[root@root ~]# ls -lad /home/admin/
drwx------ 2 admin admin 4096 Jun 25 16:01 /home/admin/



2. Set the password for the admin user. When prompted, type and then retype the password.

How to enable mod_deflate globally in cPanel/WHM

This will be a quick one folks.  The Apache module mod_deflate helps in reducing the size of the information sent to a user, by compressing things prior.  It seems to work very well.  To test if your site already has mod_deflate installed and working, you can go here:

http://www.whatsmyip.org/http_compression/

To enable mod_deflate on your WHM / cPanel server, make sure you run EasyApache through WHM, and select to install mod_deflate.  Once done, you’ll notice that it is not active globally.  In your cPanel control panel for your domain, you should notice that under “Software / Services” an icon called “Optimize Website” is now there.  This is how you control mod_deflate on a per user basis.

If however, you wish enable it globally, so that all websites on your server can benifit from this, you need to venture back into WHM, and this time go to:

Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions

Monday, October 2, 2017

Simple shell script to check if a Host is UP

If you work on multiple servers and want to check what hosts are up/down then you can use the below shell script to  test multiple servers  connectivity ::
#!/bin/bash
# test1.txt should contain a list of IP's to be tested
for i in `cat test1.txt`;
 do
ping -c 1 -W 1 $i &> /dev/null
if [ $? -ne 0 ]; then
#use if [ $? -eq 0 ]; then to test the up IP's
echo "$i is down"
fi
 done

Roundcube : failed to open log file /var/log/httpd/suexec_log

While working on a issue for one of the client, I found that the Webmail link was giving 500 internal server error for Roundcube and checking the apache error logs I was getting the below errors.

failed to open log file /var/log/httpd/suexec_log
fopen: Permission denied
[Mon Aug 18 16:50:08 2014] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
[Mon Aug 18 16:50:08 2014] [error] [client x.x.x.x] Premature end of script headers: index.php
 Further checking , I’ve found that the below file was missing :

/var/www/cgi-bin/cgi_wrapper/cgi_wrapper

So, I’ve copied that file from one of my other server and restarted apache service and this fixed the issue with  500 internal error for roundcube.
Note :: The cgi_wrapper file should have 755 permission with ownership of root

Setup Putty Window Title Permanently

I was working on a migration of servers and for that I was manually setting up the Window Title for each server in  putty but the changes last only till I press Enter on  keyboard.
It’s often gets difficult to memorize the putty session, if  a proper title is not set and hence I was looking for a solution  to setup a permanent windows title for a server in putty and found that the same can be achieved by modifying/updating the below two settings in Putty:
  • In Window -> Behavior  set your desired Window Title
  • In Terminal -> Features check Disable remote-controlled window title changing

Backup Single Table from a database using MySQLdump

We normally backup entire database using mysqldump utility but what if only one table gets corrupt and you  only want to  restore  that table from backup.
In that case you can  use the below simple steps to backup and restore a single mysql table using   mysqldump utility.

Backup:

mysqldump -u -p databasename tablename > tablename.sql
 example :

mysqldump  psa BackupsScheduled > BackupsScheduled.sql -u admin -p`cat /etc/psa/.psa.shadow`


 Restoration :

mysql -u -p   databasename  <  tablename.sql
 for example :

mysql  psa < BackupsScheduled.sql -u admin -p`cat /etc/psa/.psa.shadow`

List all cPanel users having Wildcard Remote Mysql Access

Remote MySQL option in cPanel allows other webservers to access the MySQL database on your server remotely.
Remote MySQL option can be very handy, if  you want  to allow applications like shopping carts or guestbooks on your other servers to access the databases.
But on the contrary, if the Remote MySQL option is not handled with  care  then  it can lead to database hacks.
So, If you want to find out all cPanel users having Wildcard Access enabled then  you can  use the below simple command :

root@server[#]mysql -N  mysql -e "Select User from user where Host='%'" | awk  -F _ '{print $1}' | uniq

Saturday, September 16, 2017

Encrypting MySQLDump

If  you are looking to Encrypt your MySQL database dump for security reasons than you can  use the ccrypt tool  to encrypt your dump.sql file.

Follow the below simple steps to  achieve the database dump encryption and decryption :

  1. Create a  encryption key file as /root/.backup_keyfile and add the password/key in  that file.
  2. This keyfile  will be used to  encrypt and decrypt the data [dump.sql file]
Now, that we have created the encryption  file we just need to  execute the below commands:

mysqldump --opt  opsview |  ccrypt  -k /root/.encryptkeyfile > opsview.sql

Can’t locate DateTime perl module

If you are getting below error while installing any application on linux then perl date time module is missing.

    Can’t locate DateTime.
    pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at gatherbot_en.pl line 13.
    BEGIN failed–compilation aborted at gatherbot_en.pl line 13.

You can use below command to install Datetime on server.

    yum install perl-DateTime-TimeZone

dd command to migrate VPS on linux platform

First create new vps with same configuration on another node. It doesn’t matter new vps is having os or not or you can choose any OS.

Once same configuration VPS setup done then use below command to migrate VPS.

    dd if=/dev/guestos/kvm2351_img | ssh 10.10.10.10 “dd of=/dev/guestos/kvm2520_img

Once migration is completed then try starting VPS on new node.