Syncing Two Drupal Sites

The drush module for Drupal has a new “sync” option to synchronize two Drupal sites, but it is undocumented and looking at the source code all it does is sync the files, not the mysql database. I haven’t seen any other public solutions that do completely sync 2 drupal sites including the databases.

Tags:

How to disable and enable Drupal 7 blocks programmatically

Sometimes you need to enable and place a Drupal 7 block in a seen region like header, content, footer, etc., and other times you need to disable it programmatically in a custom module. So to do it you just need to create two functions:

function _start_refreshing() {

db_update('block')
->fields(array(
'status' => 1,
'weight' => -10,
'region' => 'footer',
))
->condition('module', 'mymodule')
->condition('delta', 'mymodule_delta')
->execute();

}

and

function _stop_refreshing() {

Tags:

How to delegate a subdomain to another nameserver

In order to delegate a sub-domain's DNS management to another server, perform the following steps:

1. Set NS records for your subdomain and in DATA field put a nameserver:


sub.domain.com NS ns1.nameserver.tld
sub.domain.com NS ns2.nameserver.tld

2. Then create a new nameserver
sub.domain.com

3. Now you can start adding A records for your new subdomain, like:


sub.sub.domain.com

Tags:

If delivered mail doesn't show in user inbox

One of our Ubuntu servers stopped to show properly delivered messages in user inboxes after the last kernel update (Ubuntu precise (12.04.4 LTS)). Because for some reasons DEFAULT= and ORGMAIL= in /etc/procmailrc got replaced by

DEFAULT=/var/mail/$LOGNAME
ORGMAIL=/var/mail/$LOGNAME

so we had to change it back to:

DEFAULT=$HOME/Maildir/
ORGMAIL=$HOME/Maildir/

Now everything is working fine with the following settings for procmail:

root@quiethost:/etc# cat procmailrc
LOGFILE=/var/log/procmail.log

Tags:

Disable Named in chroot and remove chroot partition

The recent versions of bind recommends the chroot environment for better security. When considering the most used popular Linux distribution ‘Red Hat’, they ship a package called ‘bind-chroot’ for the chrooting of bind. By default the bind or named daemon runs in a chroot environment.

But users who want to run ‘named’ in the old fashion may do so by disabling the ‘chroot’ environment. The ‘chroot’ing feature can be disabled by commenting out the directive ‘ROOTDIR=/var/named/chroot’ in the file ‘/etc/sysconfig/named’ and then restarting the ‘named’ service.

df -h

Tags:

How to install IonCube loader on CentOS 6.3

Download and uncompress the latest IonCube version:

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz # 32 bit
wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz # 64 bit
tar xvfz ioncube_loaders_lin_x86-64.tar.gz

Then we go to the new IonCube source directory:
cd ioncube/

Move ioncube_loader_lin_5.3.so:
mv ioncube_loader_lin_5.3.so /usr/lib/php/modules/

Now edit /etc/php.ini and add the line zend_extension = /usr/lib/php/modules/ioncube_loader_lin_5.3.so

Tags:

What is stopping Varnish?

Every so often with Pressflow and Varnish you might find that your anonymous users aren't being cached via Varnish.

A quick way to see whether your anonymous pages are being served is to add some debugging headers to Varnish by adding some code like the snippet here to vcl_deliver()

sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Varnish-Cache = "HIT";
}
else {
set resp.http.X-Varnish-Cache = "MISS";
}
}

and hit them with

curl -I http://yoururl.com

How to insert a block or a region in the middle of Drupal node content

The solution for Drupal 7.10:

/** in template.php **/

function THEME_preprocess_node(&$variables) {

//load your adblock
$adblock = block_load('block', '1');
$output .= drupal_render(_block_get_renderable_array(_block_render_blocks(array($adblock))));
$variables['ad'] = $output;
}
/** in node.tpl.php **/

$array = explode("", $body[0]['value']);
$array[1] = $ad. $array[1];
$content['body'] = implode("", $array);
print render($content['body']);

Inserting Adsense Into Content - Drupal 6.X

Tags:

WD cron: Attempting to re-run cron while it is already running.

If you see the following error when running 'drush cron' command:


WD cron: Attempting to re-run cron while it is already running. [warning]
Cron run failed.

then you can try:


drush --yes vset cron_semaphore 0
drush cron

If it doesn't help then fire up:


drush sqlc
DELETE FROM variable WHERE name="cron_semaphore";
DELETE FROM variable WHERE name = "cron_last";
exit
drush cc all
drush cron

Tags:

Another MySQL daemon already running with the same unix socket.

After upgrading to CentOS 5.6 MySQL deamon on my server didn't want to start complaining about Another MySQL daemon already running with the same unix socket. Firing up service mysqld restart didn't help. So I had to


root@ns1:/root#
rm -rf /var/lib/mysql/mysql.sock
root@ns1:/root#
service mysqld restart
Stopping mysqld: [ OK ]
Starting mysqld: [ OK ]
root@ns1:/root#

Tags:

Pages

Subscribe to Front page feed