Wednesday, 28 September 2011

Root password of MySQL in Ensim

You can execute the following command for getting the "mysql" root password of the server in Ensim control panel.

[root@test]#ensim-python -c "import sys;sys.path.append(\"/usr/lib/opcenter/mysql\");import mysqlbe;print mysqlbe.read_mysqlpass()"

[or]

[root@test]#ensim-python -c "from vh3 import virthost; from vh3.modules import mysql; print mysql.GetMySQLRootPass()"

Both command will return the mysql root password.

How to reset the Plesk Admin password

We can reset the plesk admin password by doing the following steps.

1. Login to the server as root.

2. [root@test]# cd /usr/local/psa/admin/bin/

3.Enter the following command

[root@bin]#export PSA_PASSWORD='newpass'

4.Execute the command "./ch_admin_passwd " and it will reset the plesk admin with new one which we entered now.

[root@bin]#./ch_admin_passwd

Now you are able to login to plesk by using the new password.

Monday, 26 September 2011

Fixing File and Folder Permission on suPHP

After installing suPHP on server, the directories which is having the permission more than 755 and files which is having more than 644 will not work in the browser. The browser will show the Internal server error.

For fixing the suPhp error, you can use the following scripts.

1. find /home/*/public_html -type d -exec chmod 755 {} \;

This command fix all folder permission

2. find /home/*/public_html -name '*.php' -o -name '*.php[345]' -o -name '*.phtml'| xargs chmod -v 644

This command fix all file permission

3. Create a file with the following content and give the executable permission.

#!/bin/bash
cd /var/cpanel/users
for user in *
do
chown -R $user.$user /home/$user/public_html/*
done

This script fix all ownership issue.

Friday, 23 September 2011

Increase /tmp size

We can increase the /tmp directory by doing the following steps:

cd /usr
dd if=/dev/zero of=/usr/tmpMnt bs=1024 count=2000000

mke2fs -j /usr/tmpMnt

cd /
cp -R /tmp /tmp_backup

mount -o loop,noexec,nosuid,rw /usr/tmpMnt /tmp
chmod 0777 /tmp
/bin/cp -R /tmp_backup/* /tmp/
rm -rf /tmp_backup

+ Now, we will need to add this new block device in fstab. Open fstab by using your favorite editor

nano -w /etc/fstab

+ Add the following line at the bottom of the file

/usr/tmpMnt /tmp ext3 loop,noexec,nosuid,rw 0 0

That is it:)

Thursday, 22 September 2011

Webmail: A fatal error has occurred DB Error: connect failed Details have been logged for the administrator.

If you receive the following error during attempting to login into Webmail:

A fatal error has occurred DB Error: connect failed Details have been logged for the administrator.


please make sure that the following line exists in the directory /etc/my.conf:

socket=/var/lib/mysql/mysql.sock


Also check that Mysql service is running and that the /var/lib/mysql/mysql.sock socket exists. Make sure that the Horde user is able to connect to the Horde database with a password from etc/psa/.webmail.shadow using the command:


# mysql -uhorde -p`cat /etc/psa/.webmail.shadow` -D horde


If /etc/psa/.webmail.shadow is missing, put some password into this file and change the password for the Horde user in the MySQL database using the query listed below. If you get the error, make sure that the only one Horde MySQL user exists in the user table in MySQL database and try to change its password with a MySQL query like:


# mysql -uadmin -p`cat /etc/psa/.psa.shadow` -D mysql
mysql> update user set password=password(“THE_PASSWORD_FROM_WEBMAIL.SHADOW”) where user=”horde”;
mysql> FLUSH PRIVILEGES;


Look into the psa-horde log (by default: /var/log/psa-horde). If you see something like:


Nov 02 12:55:06 HORDE [emergency] [horde] DB Error: connect failed: [nativecode=Access denied for user: 'root@localhost' (Using password: NO)] ** Array [on line 1329 of "/usr/share/psa-horde/lib/Horde/DataTree/sql.php"]

make sure that sql.safe_mode is disabled in php.ini, such as:

sql.safe_mode=Off


Restart Apache after changes in php.ini have been made.


Wednesday, 21 September 2011

Unable to login to the WHM

If there are many failed login attempts, your account may get locked by WHM. You will get the following message in the browser after the account blocked in the WHM.


----------------

This account is currently locked out because a brute force attempt was detected. Please wait 10 minutes and try again. Attempting to login again will only increase this delay. If you frequently experience this problem, we recommend having your username changed to something less generic.

----------------


This lock was created by the "cphulkd"- Cpanel Brute Force Protection service.


cphulkd: Cpanel Brute Force Protection service. This service monitors failed authentication attempts and locks out accounts after the threshold is met.


To re-enable your account, login via ssh and disable cphulkd using the command below.


# /usr/local/cpanel/bin/cphulk_pam_ctl --disable


This should allow you to login to WHM and double check your cphulk settings.


You can view IP addresses that have been blocked via the WHM interface:
WHM -> Security -> Security Center -> cPHulk Brute Force Protection in the Brutes table. On that screen, you can also customize brute force protection settings.



Flush DB will remove all blocked IPs:


WHM -> Security Center -> cPHulk Brute Force Protection -> Click on Flush DB




RESET SSH PORT TO DEFAULT PORT THROUGH WHM

Sometimes, you may forgot the SSH port of the server. You can reset the SSH port to default one by doing the following steps.

1)Open the browser.

2) Enter the following URL in the browser,

http://serverip:2086/scripts2/doautofixer?autofix=safesshrestart

That's it. Now, you are able to login the server by using default SSH port(i.e., 22).

Monday, 19 September 2011

MySQL query failed: Incorrect information in file: './psa/misc.frm'

Sometimes we will get the following error when we tried
to access the Plesk control panel.

ERROR: PleskMainDBException
MySQL query failed:

Incorrect information in file: './psa/misc.frm'

0: common_func.php3:168
db_query(string 'select param, val from misc')
1: common_func.php3:587
get_param(string 'mysql41_compatible')
2: common_func.php3:484
db_set_names()
3: common_func.php3:463
db_connect_real(string 'localhost', string 'admin',
string '*************', 'psa')
4: common_func.php3:443
db_connect()
5: auth.php3:90

Even a restart of the plesk service will not work:

# /etc/init.d/psa restart
Unable to query parameter by query
select val from misc where param='mysql41_compatible':Incorrect
information in file: './psa/misc.frm'
Unable to query parameter by
query select val from misc where param='mysql41_compatible':Incorrect
information in file: './psa/misc.frm'
Mysql error: Incorrect
information in file: './psa/key_history.frm'
Processing config
directory: /usr/local/psa/admin/conf/httpsd.*.include
Syntax OK
/usr/local/psa/admin/bin/httpsdctl
restart: httpd restarted
ERROR 1033 (HY000) at line 1: Incorrect
information in file: './psa/sessions.frm'


so this is a mysqld failing to start properly problem. to fix this,
go to your mysql datadir and see if the sizes of your innodb log files
match those in your .cnf. we usually set innodb_log_file_size = 256M
and innodb_log_buffer_size = 256M in /etc/my.cnf.

if they don't match, stop mysqld, remove the ib_logfile0 and
ib_logfile1 files, and start mysqld. be careful not to delete the
ibdata1 or ibdata2 files or you lose your data.

avoid using rm -r ib*

innodb will recreate the log files to match your .cnf and mysqld
now becomes available for plesk.



Downgrade PHP 5.3 to 5.2 in centos 6.

The centos 6 normally comes with php 5.3. You can do the following procedures do downgrade the php version to 5.2.

1. Take the copy of the previous installed rpm to any one of the folder.

--------------
[root@cronline ~]# rpm -qa|grep php >>/root/php_modules/php_module.txt
[root@cronline ~]# cat /root/php_modules/php_module.txt
php-mysql-5.3.2-6.el6_0.1.x86_64
php-pear-1.9.0-2.el6.noarch
php-cli-5.3.2-6.el6_0.1.x86_64
php-pdo-5.3.2-6.el6_0.1.x86_64
php-pecl-memcache-3.0.4-3.2.el6.2.x86_64
php-5.3.2-6.el6_0.1.x86_64
php-devel-5.3.2-6.el6_0.1.x86_64
php-imap-5.3.2-6.el6_0.1.x86_64
php-common-5.3.2-6.el6_0.1.x86_64
[root@cronline ~]#
--------------

2. Remove the existing PHP 5.3 RPM in the server.

-------------------
[root@cronline ~]# rpm -e --nodeps php-pecl-memcache-3.0.4-3.2.el6.2.x86_64 php-5.3.2-6.el6_0.1.x86_64 php-devel-5.3.2-6.el6_0.1.x86_64 php-imap-5.3.2-6.el6_0.1.x86_64 php-common-5.3.2-6.el6_0.1.x86_64
-------------------

3. Download the corresponding PHP 5.2 version from the "http://www6.atomicorp.com/" webiste.

-----------------
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-mysql-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-cli-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-pdo-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-devel-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-imap-5.2.17-1.el6.art.x86_64.rpm
[root@cronline ~]# wget http://www6.atomicorp.com/channels/atomic/centos/6/x86_64/RPMS/php-common-5.2.17-1.el6.art.x86_64.rpm
-----------------

4. Install the downloaded PHP 5.2 RPM .

-----------------
[root@cronline ~]# rpm -ivh --nodeps php-devel-5.2.17-1.el6.art.x86_64.rpm php-pdo-5.2.17-1.el6.art.x86_64.rpm php-cli-5.2.17-1.el6.art.x86_64.rpm php-mysql-5.2.17-1.el6.art.x86_64.rpm php-imap-5.2.17-1.el6.art.x86_64.rpm php-common-5.2.17-1.el6.art.x86_64.rpm
-----------------

5. Finally restart the webserver.

-------------
[root@cronline ~]#/etc/init.d/httpd restart
Stopping httpd: [ OK ]
Startinging httpd: [ OK ]
-------------

6. The next important think is to exclude the php in yum.conf. If you are not excluding this line PHP will be upgraded if we enter yum update command in the server.

---------------
[root@cronline ~]# cat /etc/yum.conf|grep php
exclude=php*
[root@cronline ~]#
---------------

All the plesk websites are loading default webpage

Sometimes if we access any website from our server, the browser will go to the default website of plesk.

Here is the possible reason for this problem..

1. Check the file /etc/httpd/conf/httpd.conf for conf.d sections by using grep command.

------------------------
[root@one-res3 ~]# grep conf.d /etc/httpd/conf/httpd.conf
Include conf.d/*.conf
[root@one-res3 ~]#
------------------------

Check whether "Include conf.d/*.conf" is commented or not. Most of the time this is the problem for the websites are loading default page. If it is commented then uncomment this line and restart the httpd service by issueing the following command.

/etc/init.d/httpd restart

Sunday, 18 September 2011

Horde Error: Unable to get quota

Some times, when we open a horde we will get the following error

"Unable to get quota" in the horde page with some yellow colour and you will not any error in the horde error log too. You can do the following procedure to fix the issue.


1. Options--> Mailbox and Folder Display Options--> Default sorting criteria:Arrival Time




No space left on device: Couldn't create accept lock

If you see any error like this in your apache then you can do the following procedure to fix the issue.

for semid in `ipcs -s | grep apachec | cut -f2 -d" "`; do ipcrm -s $semid; done

ipcs -l

vi /et/sysctl.conf

kernel.msgmni = 1024

kernel.sem = 250 256000 32 1024

sysctl -p

IP changing script

Hi,

Consider a scenario, if you have n number of IP address in your server and you want to switch the IP address for every 10 or 5 minutes. You can use the following script to achieve this. We have tested this script in cpanel servers. This

#!/bin/bash

# List of IP's in file /root/mydomain/iplist.txt

CHANGEIP=/usr/local/cpanel/bin/setsiteip

#This is cpanel user account

USERNAME=mail23

IPLIST=/root/mydomain/iplist_123mail.txt

CUR_IP=/root/mydomain/current_ip_123mail.txt

##REMOVE EMPTY LINES FROM FILE

sed -i "/^$/d" iplist_123mail.txt

#Current IP

CIP=$(cat ${CUR_IP})

#Total line count

TLN=$(wc -l ${IPLIST}|cut -d" " -f1)

#Current line number

CLN=$(grep -n ${CIP} ${IPLIST}|cut -d: -f1)

echo -e "$CLN\n$TLN\n$CIP"

if [ $CLN -eq $TLN ]; then

CLN=1

echo ${CLN} > ${CUR_IP}

sed -n 1p ${IPLIST} > ${CUR_IP}

CIP=$(cat ${CUR_IP})

$CHANGEIP -u ${USERNAME} ${CIP} > ~/report_emailexp.txt

ret=$?

echo -e "CLN=1\nRET=${ret}"

else

CLN=$((CLN+1))

echo ${CLN} > ${CUR_IP}

sed -n "${CLN}"p ${IPLIST} > ${CUR_IP}

CIP=$(cat ${CUR_IP})

$CHANGEIP -u ${USERNAME} ${CIP} > ~/report_emailexp.txt

ret=$?

echo -e "CLN=${CLN}\nRET=${ret}"

fi

####SEND ALERT####

EMAIL_=rrrrrrrrrrrrttttttttttt@hotmail.com

if [ $ret -eq 0 ];then

exit 0

#msg="IP CHANGED SUCCESSFULLY NEW IP=${CIP}"

#echo "NOTIFICATION FROM `hostname`"| mail -s "${msg}" ${EMAIL_}

else

msg="IP CHANGED FAILURE IP TRIED=${CIP}"

content=$(cat ~/report.txt)

echo "$content" |mail -s "${msg}" ${EMAIL_}

fi

#######

##END

#######


Note that you have to add all the IP address in /root/mydomain/iplist.txt.

Root Login Alert

If you want to enable root login alert for your server then you can do the following procedure.

So lets get started!


1.
Login to your server and su to root.

2. cd /root

3. pico .bashrc

4. Scroll to the end of the file then add the following:
echo 'ALERT - Root Shell Access (YourserverName) on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`" you@yourdomain.com

Replace
YourServerName with the handle for your actual server
Replace
you@yourdomain.com with your actual email address

5. Crtl + X then Y

Sunday, 11 September 2011

How to configure Mozilla Thunder bird in MAC OS for the email account?

1) Open Thunderbird then click on Tools and select Account Settings.

2) Click on Account Actions and select Add Mail Account.

3) Enter your name, your Hover email address, and your email password then click on Continue.

4) Thunderbird will try to auto configure the account settings. The orange status lights indicate that a test connection failed. Click on the Edit button.

5) The following settings need to be entered:

Username: enter your full Hover email address
Incoming: mail.domain.com
Outgoing: mail.domain.com

Select IMAP after the Incoming mail server name.

Incoming port number: 993
Outgoing port number: 465

Incoming security: SSL/TLS
Outgoing security: SSL/TLS

6) Once these settings have been entered, click on the Re-test Configuration button.

7) The configuration test was successful, as indicated by the green lights. Click on Create Account.

8) The account configuration has been completed. Click OK.

Mac OS X Mail: "The server rejected the password" alert, even with correct password

Mail might tell you this, even when you're using the correct password:

"The server {server name} rejected the password for user {username}. Please re-enter your password, or cancel."
Products Affected

This message may appear several times while trying a correct password.

This can happen if the mail server is not available for authentication or cannot be contacted. Click Cancel, then wait a few minutes. After waiting, choose Go Online from the Mailbox menu, then enter the same password.

If this doesn't help, you may indeed be using the wrong password, or it may have been changed. Then reset the password of the email account and try to do the same.


Reference link:
http://support.apple.com/kb/TA22531?viewlocale=en_US

How to set up Mozilla Thunderbird for the E-mail account created with cPanel?

1) Open Thunderbird. On the Tools menu, select “Account Settings”.

2) Click on “Add account” or press Alt+A.

3) Select “e-mail address” and press next.

4) Type in your name and the e-mail address.

5) In this dialog box, Select POP and enter the address for the incoming server. This is usually mail.domain.com (where domain stands for your domain name).

(Deselect the “Use Global Inbox” checkbox – it’s a royal pain if you’ve got multiple accounts).

6) Set the incoming username. It is either your username (from username@domain.com) or username+domain.com

7) Set the name to whatever you like.

8) Verify all the details and press finish.

9) Click on “Server Settings” for the account and under security settings, select the radio button which says “TLS”.

10) Then back to the “Account Settings” dialog box.

11) Scroll down and select “Outgoing Server (SMTP)”

12) Click on “Add” if you haven’t already added any. Otherwise click on edit.

13) Set the server name to “mail.domain.com”.

14) Set the username (username@domain.com) and the default port setting is 25.

15) Click OK

Shopping cart source codes

Instructions
The code below is a simple HTML form which you can copy and paste in your website. Then you just need to adjust the values in red based on your requirements. Cart checkout will not work with your sandbox accounts.


Instructions
The code below is a simple HTML form which you can copy and paste in your website. Then you just need to adjust the values in red based on your requirements. Cart checkout will not work with your sandbox accounts.
<!-- ADD TO CART button code. -->
<form action="https://www.e-junkie.com/ecom/fgb.php?c=cart&cl=1&ejc=2" target="ej_ejc" method="POST">
<!-- paypal email(remove if not using PayPal) -->
<input type="hidden" name="business" value="
your_paypal_email"/>
<!-- google merchant id (remove if not using Google Checkout) -->

<input type="hidden" name="merchant_id" value="
your_google_merchant_id"/>
<!-- site url -->
<input type="hidden" name="site_url" value="
http://yoursite.com"/>
<!-- contact email (where we can notify of the updates) -->
<input type="hidden" name="contact_email" value="
your@email.address"/>
<!-- item name -->
<input type="hidden" name="item_name" value="
Test Item"/>
<!-- item number (should be different for each product)-->
<input type="hidden" name="item_number" value="
1"/>
<!-- item price -->
<input type="hidden" name="amount" value="
1.00"/>
<!-- initial quantity -->

<input type="hidden" name="quantity" value="
1"/>
<!-- item options (can be removed if not required) -->

<input type="hidden" name="on0" value="
Size"/>
<select name="os0" >
<option value="S">S</option><option value="M">M</option>
</select>
<input type="hidden" name="on1" value="
Color"/>
<select name="os1" >
<option value="Orng">Orng</option><option value="Blk">Blk</option>
</select>
<input type="hidden" name="on2" value="
Message"/>
<input name="os2" type="text" value="
Hello World"/>
<!-- shipping cost -->

<input type="hidden" name="shipping" value="
1">
<!-- shipping cost of each additional unit -->
<input type="hidden" name="shipping2" value="
0.5">
<!--handling cost -->
<input type="hidden" name="handling" value="
0.5">
<!-- tax (flat amount, NOT percentage)-->

<input type="hidden" name="tax" value="
0.50"/>
<!-- following options are applicable to whole cart-->


<!-- you thank you page -->

<input type="hidden" name="return_url" value="
http://www.e-junkie.com/"/>
<!-- any custom info you want to pass for the whole order -->

<input type="hidden" name="custom" value="
anything"/>
<!-- currency (USD for Google Checkout USA, GBP for Google Checkout UK. For PayPal: any currency that PayPal supports -->

<input type="hidden" name="currency_code" value="
USD"/>

<input type="image" src="https://www.e-junkie.com/ej/ej_add_to_cart.gif" border="0" onClick="javascript:return EJEJC_lc(this.parentNode);">
</form>

<!-- VIEW CART button code. -->
<a href="https://www.e-junkie.com/ecom/fgb.php?c=cart&cl=1&ejc=2&
merchant_id=
your_google_merchant_id&business=your_paypal_email" target="ej_ejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="https://www.e-junkie.com/ej/ej_view_cart.gif" border="0"></a>
<script language="javascript" type="text/javascript">
<!--
function EJEJC_lc(th) { return false; }
// -->
</script>
<script type="text/javascript"
src="https://www.e-junkie.com/ecom/box.js"></script>