Friday, 13 March 2009

To make writable session save path

Just put the following code in your .htaccess


php_value session.save_path ‘/tmp’

Thursday, 12 March 2009

Cannot edit DNS zone after cPanel update

Issue :

After updating all the cPanel software, following error occurs when trying to Edit a DNS zone :

Unable to parse zone: Error while parsing zonedata for *DOMAIN NAME HERE*.com: expected valid rname, line 4 …propagated at /usr/local/cpanel/Cpanel/CPAN/Net/DNS/ZoneFile/Fast.pm line 142.

Fix :

The error means that the dns zone has invalid data in it and it cannot be loaded. So you need to recreate the zone to fix this.

You can use the following cPanel script to do this :

/scripts/pkgacct accountname ( just to backup the account)

/scripts/killdns domainname

/scripts/adddns –domain domainname

Please note that while recreating the domain using the above script it will not create the sub-domain. It will create the default DNS records. You can also specify the ip address using ” –ip X.X.X.X ” option

After running the scripts, you can manually add the entries for the sub-domains .

Cannot send emails- RoundCube just shows “Sending Message”

I found a problem with Roundcube, it shows sending message and hangs up there and actually it doesn’t send message anymore. I found the following solution here.

Problem with Roundcube, installed when updated to newest CURRENT release. – Page 3 – cPanel Forums:

vi /usr/local/cpanel/base/3rdparty/roundcube/config/main.inc.php

and changed

$rcmail_config['smtp_user'] = ‘%u’;
to
$rcmail_config['smtp_user'] = ”;

Tuesday, 10 March 2009

Wordpress mod_rewrite rules taking over mod_status

While working on setting up a monitoring solution for a big wordpress installation, I realized that the server-status url was not working as expected even ifmod_status was configured correctly:

ExtendedStatus On

SetHandler server-status
Order deny,allow
Deny from all
Allow from some_ips


The .htaccess wordpress rules were taking over this and the server-status url was returning a page not found error from within wordpress. This was happening because of the way how the rewrite rules are setup to handle all the permalinks on the site, and for any non-existing file send it to index.php:
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

This works fine with any aliases defined in apache, but the mod_status handler was going to the rewrite rules first, hence the problem. This is not a wordpress problem, and should happen with any other application (like zend framework is one other example that comes to my mind right now) that uses the same type of catch-all rewrite rules to handle all the urls inside the application. The solution in this case is to specifically add a rewrite rule to not have the server-status url processed and sent to the default rule:
RewriteCond %{REQUEST_URI} !=/server-status
and the wordpress rewrite rules should look like this:
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=/server-status
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

How to use gmail with mutt

For sending and receiving you mails, with the famous mail client mutt, insert the following lines into your ~/.muttrc

set smtp_url = “smtp://username@smtp.gmail.com:587/”
set smtp_pass = “password”
set from = “username@gmail.com”
set realname = “Your Real Name”

you can also use fetchmail to get your mail automatically.
so, edit the ~/.fetchmailrc and add the following :

poll smtp.gmail.com protocol imap user “username” password “password” mda “/usr/bin/procmail -d %T” ssl

That’s great if we will receive notification when a new mail arrived.
for that add the following lines into a shell script, we will name it checkmail.

$ cat >checkmail<<EOF
#!/bin/sh
if [ "$1" = "-v" ]; then
EXTRAARG=”-v”
fi
fetchmail -a -K $EXTRAARG >/dev/null 2>&1

if [ "$?" = "0" ]; then
DISPLAY=:0.0 /usr/bin/notify-send -t 0 -u critical -h “int:x:168? -h “int:y:100? -i /home/mezgani/photo/mail.jpg “?????? ????” “New mail received”
fi
EOF

Ok, right now we will define an entry to crontab, which will call the checkmail script every 5min.
of course change the path /home/handrix/bin/checkmail by the emplacement of the script in you host.

*/5 * * * * /home/mezgani/bin/checkmail

How to Enable Sound in VMWare Server 2.0



So I had switched from VirtualBox to VMWARE since its free and has much easier bridging behind the scenes for my virtual machines. Currently I run Linux as my main computer and well the necessities of certain office windows products I was missing and their Linux counterparts didn’t work as well. I had created a windows xp virtual machine from my computers license key since I no longer have the thing installed.

Creating the virtual machine and setting up Linux went fine and smooth. Once in windows I started to tweak it and noticed there is no sound. I had shut down the machine and tried to add a sound device on “auto detect” was my only option. Booting the virtual machine I received an error that the sound was not able to be initialized, where I started to search the internet with no luck.

Finally I had figured it out and I have SOUND! Below you can find the steps I took and hope they work out as well for you as for me.

First is first – figure out what your device is for sound. I loaded up amarok and went to the configuration. From there to “Engine” and there it beholds “Device:”. For me there were two options:










1/dev/dsp










2/dev/sound/dsp




I had restarted amarok with each as my device and figured out that /dev/dsp was the one for me.

Then go to “/var/lib/vmware/Virtual Machines/” and open “.vmx” and look for the following lines:










sound.present = "TRUE"











sound.allowGuestConnectionControl = "FALSE"










sound.fileName = "/dev/dsp" (changed from -1)











sound.autodetect = "FALSE" (changed from TRUE)










sound.pciSlotNumber = "36"










sound.startConnected = "TRUE"




Save the file and reboot the virtual machine and there we have sound! Isn’t that fantastic?!? If you have comments or suggestions please leave them as others might be experiencing the same issues as you.

Wednesday, 4 March 2009

Upgrading PostgreSQL

To upgrade a PostgreSQL installation start by dumping all the existing databases. You should do this before stopping the current database server
$ PGUSER=postgres /usr/bin/pg_dumpall > dump.sql
$ sudo /etc/init/d/postgresql stop
$ sudo mv /usr/local/pgsql /usr/local/pgsql.old


Build and install your new version. Be sure to create a PGDATA directory that is owned by the postgres user. Initialize the PGDATA directory with initdb
$ sudo mkdir /usr/local/pgsql/data
$ sudo chown postgres:postgres /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data


Once you have created your new database, start the new database server and populate the new database with the data you dumped from your old system:

$ sudo -u postgres /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
$ sudo -u postgres /usr/local/pgsql/bin/psql -d postgres -f dump.sql