Monthly Archives: July 2010

Synchronizing Folders using Rsync

This is an alternative to the “mv” command (move) or cp (copy) but slightly with a added feature of doing it remotely from server to another server.

Local Server
rsync -avzp /source-address/* /destination-address/

Remote Server
rsync -avzp -e ‘ssh -p portnumber’ /source-address/* root@ipaddress:/destination-address/

source-address = the source of the folder/files eg:

destination-address = the destination to sync the files from the source eg:

portnumber = the ssh port number, default is:

ipaddress = the ip address of the destination server of the hosname eg: or

Lastly, don’t forget to change the file ownership, example like below:
chown username.username *

================== Edit 1 ===================

If you noticed, some files won’t be copied over using the Rsync, especially like the .htaccess file. As an alternative you can use this coding to copy those special file like example below:
scp -P portnumber /home/username/public_html/.htaccess root@ipaddress:/home/username/public_html/

If a folder that can’t be transfered, you can use as below, but make sure to create a folder at server B also, for example as below:
scp -P portnumber /home/username/public_html/.smileys/* root@ipaddress:/home/username/public_html/.smileys/

Don’t forget to change the ownership again.

================== Edit 2 ===================

When moving website that have a database, make sure to properly configure the data base when transferring it.

Let say now our current situation, server A is transferring to server B. After the files have been transferred to server B, log into server A PhpMyAdmin and find the account name.

Click to open the database (_testdb).

Click Export
Select compression = gzipped
Click Go

Then just save it any place in your pc.

Ok then, next is a bit tricky part. Go to server B, and the folder where you upload the file and try to open:
nano configuration.php

The content of the file as below:
$mosConfig_offline = ‘0’;
$mosConfig_host = ‘localhost’;
$mosConfig_user = ‘username_testdb’;
$mosConfig_password = ‘xxxxx’;
$mosConfig_db = ‘username_testdb’;

$mosConfig_dbprefix = ‘mos_’;
$mosConfig_absolute_path = ‘/home/username/public_html/’;
$mosConfig_live_site = ‘’;
$mosConfig_sitename = ‘Testing Website’;
$mosConfig_shownoauth = ‘0’;
$mosConfig_useractivation = ‘1’;
$mosConfig_uniquemail = ‘1’;
$mosConfig_usecaptcha = ‘0’;
$mosConfig_offline_message = ‘This site is down for maintenance.<br /> Please check back again soon.’;
$mosConfig_error_message = ‘This site is temporarily unavailable.<br /> Please notify the System Administrator’;
$mosConfig_debug = ‘0’;
$mosConfig_lifetime = ‘900’;
$mosConfig_MetaDesc = ‘This Software Site Is Under Serverfreak’;
$mosConfig_MetaKeys = ”;
$mosConfig_MetaAuthor = ‘1’;
$mosConfig_MetaTitle = ‘1’;
$mosConfig_lang = ‘english’;
$mosConfig_locale = ‘en’;
$mosConfig_charset = ‘utf-8’;
$mosConfig_locale_debug = ‘0’;
$mosConfig_locale_use_gettext = ‘0’;
$mosConfig_offset = ‘0’;
$mosConfig_hideAuthor = ‘1’;
$mosConfig_hideCreateDate = ‘1’;
$mosConfig_hideModifyDate = ‘1’;
$mosConfig_hidePdf = ‘0’;
$mosConfig_hidePrint = ‘0’;
$mosConfig_hideEmail = ‘0’;
$mosConfig_enable_log_items = ‘0’;
$mosConfig_enable_log_searches = ‘0’;
$mosConfig_enable_stats = ‘0’;
$mosConfig_sef = ‘0’;
$mosConfig_vote = ‘0’;
$mosConfig_gzip = ‘0’;
$mosConfig_multipage_toc = ‘1’;
$mosConfig_allowUserRegistration = ‘0’;
$mosConfig_link_titles = ‘0’;
$mosConfig_error_reporting = ‘-1’;
$mosConfig_register_globals = ‘1’;
$mosConfig_list_limit = ’50’;
$mosConfig_caching = ‘0’;
$mosConfig_cachepath = ‘/home/username/public_html/cache’;
$mosConfig_cachetime = ‘900’;
$mosConfig_mailer = ‘mail’;
$mosConfig_mailfrom = ‘[email protected]’;
$mosConfig_fromname = ”;
$mosConfig_sendmail = ‘/usr/sbin/sendmail’;
$mosConfig_smtpauth = ‘0’;
$mosConfig_smtpuser = ”;
$mosConfig_smtppass = ”;
$mosConfig_smtphost = ‘localhost’;
$mosConfig_back_button = ‘0’;
$mosConfig_item_navigation = ‘0’;
$mosConfig_secret = ‘xxxxxx’;
$mosConfig_pagetitles = ‘1’;
$mosConfig_readmore = ‘1’;
$mosConfig_hits = ‘1’;
$mosConfig_icons = ‘1’;
$mosConfig_favicon = ‘favicon.ico’;
$mosConfig_fileperms = ”;
$mosConfig_dirperms = ”;
$mosConfig_mbf_content = ‘0’;
$mosConfig_helpurl = ‘’;

The parts I bold above are the part you need to pay attention.
$mosConfig_user = ‘username_testdb’;
$mosConfig_password = ‘xxxxx’;
$mosConfig_db = ‘username_testdb’;
$mosConfig_absolute_path = ‘/home/username/public_html/’;
$mosConfig_cachepath = ‘/home/username/public_html/cache’;

So now assuming that our database name and the user is username_testdb, while the password is xxxxx

Go to the the account’s cPanel. Under Database, select the MySQL Databases. Under Create New Database, fill in the BOLD part as below:
New Database:   username_testdb
and then click the Create Database button.

Next, go to the Add New User, then fill in as below:
Password (Again):xxxxx
Click Create User button afterward.

Then, go to Add User To Database section, select as below:
User: username_testdb
Database: username_testdb
and click on the Add button.
It will bring to a new page. This page is quite important. Make sure to Tick the ALL PRIVILEGES checkbox and then click the Make Changes button.

==================== End ====================

Ok then, the database part is finished. Make sure to test run and check whether got any error message or not. By the way, this were all tested in a cPanel-based hosting. The Rsync and the scp part will work on any hosting, but the database part might be slightly different.

Happy Trails.

Compile PHP 5.3 via CustomBuild in Direct Admin

This is the step on how to compile your PHP into the latest version (or vice versa, according to your preferences) using CustomBuild in Direct Admin servers.

Note: This same procedure also can be applied with any other supported modules in Direct Admin. Just type “./build” to list out the things that you are able to update.

First, go to this folder:

Then modify the option.conf:
nano options.conf

Try to find this string:

In my case, my current php is 5.2 and i need to recompile it to 5.3, so my current option.conf should looks like this:

and modified to this:

Save and close it.

Next, to download the updated version, type:
./build update

After the download is done, then finally we can start compiling by typing this:
./build php n

The compiling process should take a while. But just in case you ran into this kind of error:
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/tm2unixtime.lo] Error 1
make: *** Waiting for unfinished jobs….
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/parse_tz.lo] Error 1
virtual memory exhausted: Cannot allocate memory
make: *** [ext/date/lib/parse_date.lo] Error 1

So you are running out of RAM. Make sure too add enough RAM for the process to proceed.

Finally when finished, it will restart the httpd by itself. You can check the php version by typing “php -v” and the result as below will appear:
[root@server custombuild]# php -v
PHP 5.2.13 (cli) (built: Jul  7 2010 01:09:45)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies

and after:
[root@server custombuild]# php -v
PHP 5.3.2 (cli) (built: Jul  8 2010 07:36:44)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

Happy compiling.

Adding multiple alternative SMTP Port in cPanel

By default, cPanel only support one additional alternative SMTP port. However, if you need multiple port, follow the steps below:

1) Disable “exim on another port” in WHM -> Service Manager
2) Go to WHM-> Exim Configuration Editor -> Advanced Editor -> at the first text box, add in “daemon_smtp_ports = 25 : 26 : 587” without “”.
3) Save.

Custom php.ini on suPHP using .htaccess

Remove the lines that begin with “php_value” and “php_flag”. You will need to move these files to a file named php.ini and upload php.ini into your public_html directory. Then, add the following line into the .htaccess file in your public_html:

suPHP_ConfigPath /home/username/public_html

where “username” is your cPanel username. You will need to remove php_value and php_flag from ALL .htaccess files you may have. However, you only need to add the suPHP_ConfigPath line in the .htaccess file in your public_html directory only.

Please note that you will need to change the format of your php_value and php_flag lines into the php.ini format