Testing PHP-MySQL connection

Edit

dbHost = IP address of the remote database server.
dbname= give the database name
dbuser= database user
dbPass= the password of the user.

Access this script via browser and check whether the user is able to connect.

$dbHost = " ";
$dbName = " ";
$dbUser = " ";
$dbPass =
$dbType = "mysql";
mysql_connect($dbHost, $dbUser, $dbPass) or die("could not connect ".mysql_error());
mysql_select_db($dbName) or die("could not select db ".mysql_error());
echo "db selected";
?>


Enjoy:)

MySQL Socket Error in phpMyAdmin

While accessing phpMyAdmin, you may get the following error.

-----------------------------------------------------------------------------------------
#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
-----------------------------------------------------------------------------------------

This is due to the missing socket file in the location /tmp.

The socket path which is specified in the phpMyAdmin configuration file is /tmp/mysql.sock.

$ vi /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php
cfg['Server']['socket'] = '/tmp/mysql.sock';


If mysql.sock is missing in /tmp, then create a link to the mysql.sock file in /var/lib/mysql.

$ ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

There is also another fix for this issue.

1. Open the phpMyadmin config file "config.inc.php".
-------------------------------------------------------------
vi /usr/local/cpanel/base/3rdparty/phpMyAdmin/config.inc.php
-------------------------------------------------------------

2.Locate the line:
---------------------------------------------------
$cfg['Servers'][$i]['host'] = 'localhost';
---------------------------------------------------

3.Replace 'localhost' with '127.0.0.1' and save.
---------------------------------------------------
$cfg['Servers'][$i]['host'] = '127.0.0.1';
---------------------------------------------------

This will also fix the issue.

Enjoy:)

Wrong disk usage on DirectAdmin Panel

DirectAdmin panel is showing wrong disk usage. In such cases we need to update the disk usage manually. Run the following command in the server to update the disk usage.

[root@test]# echo "action=tally&value=all" >> /usr/local/directadmin/data/task.queue



We can verify the disk usage shown in the directAdmin panel is correct
or not as the directAdmin will list the quota information based on the
output of the following command.

[root@test]#/usr/sbin/repquota -a

Enjoy:)

Installing Horde in Direct Admin

You can use the following steps to install Horde in a Direct Admin server.

1. First check whether IMAP module is enabled in PHP, if not recompile PHP with IMAP support.

$ vi /usr/local/directadmin/custombuild/configure/ap2/configure.php5

Add the following entries.
--with-imap=/usr/local --with-imap-ssl

$ /usr/local/directadmin/custombuild/build php n

If you are doing the installation in a VPS, sometimes you might get the following error:

configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

To fix this error install the libc-client-devel package

$ yum -y install libc-client-devel.i386 rpm

Now download the horde install script for DirectAdmin and install it.

$ wget http://www.fusion-ict.nl/da_plugin/horde_install.tar.gz
$ tar -zxvf horde_install.tar.gz
$ sh horde_install/horde_install.sh

This will install Horde in the server. Now you can access the Horde webmail using the URL http://domain.com/horde

If you get the following error when accessing Horde through browser,

A fatal error has occured DB Error: connection failed PASSWORD:


then do the following:

$ mysql
mysql > grant all privileges on da_horde.* to da_horde@localhost identified by "PASSWORD";
mysql > flush privileges;
mysql >\q


3. If you would like to access the Horde using the URL http://webmail.domain.com/ do the following :

First add an A record for webmail.domain.com. Then add the following VirtualHost entry in the /etc/httpd/conf/extra/httpd-vhosts.conf file and restart httpd service.

$ vi /etc/httpd/conf/extra/httpd-vhosts.conf


IP2:80>

ServerName webmail

ServerAlias webmail.*

DocumentRoot /var/www/html/horde



$ service httpd restart


Enjoy:)

To enable spamassassin for all existing accounts in Directadmin

To enable spamassassin for all existing accounts in Directadmin, create the following script and execute it.

Open a new file enablespam.sh

#!/bin/sh
for i in `ls /usr/local/directadmin/data/users`; do
{
username=$i spam=ON /usr/local/directadmin/scripts/custom/user_create_post.sh
};
done;
exit 0;

Chmod the file as 755 and execute it.

chmod 755 enablespam.sh

./enablespam.sh


Enjoy:)

How to upgrade apache in a directadmin server

For upgrading apache from 1.3.39 to Apache 2.0.63, just login to the server and run following commands/scripts.

#cd /usr/local/directadmin/customapache
#./build update
#./build clean
#./build update_data_ap2
#./build convert
#./build apache_2
#./build php_ap2 n
#./build mod_frontpage_ap2
#./build mod_perl_ap2

Enjoy:)

Recompiling apache/PHP in a directadmin server

To recompile apache/PHP on a directAdmin server. ( Like easyapache script in cPanel servers, there is no custom script, need to run the following commands manually ). This will be helpful, if current PHP/apache compilation in the server is broken and this can be found out from the error log (/var/log/httpd/error_log).
For updating apache run the following commands.

#cd /usr/local/directadmin/customapache

#./build clean

#./build update

#./build apache_mod_ssl

For building apache with PHP run the following commands.

#cd /usr/local/directadmin/customapache

#./build php y


Restart apache service.