Thursday, February 21, 2008

Page redirection in php with header('Location...') : Blank page vs Working redirection

This kind of errors are what make debugging sometimes a very frustrating part of the developement, if you're suffering a blank page when trying to make a header('Location..'), give this a try:

This is a good redirection:


And this is a wrong redirection:

header('Location :');

Notice a space between 'Location' and ':' this makes the redirection not to work!!!!

Simple errors likes this consume a lot of time :( , hope helps someone else...

Monday, February 11, 2008

.htaccess: order not allowed here

I was getting an 500 Internal Server Error when trying to access Drupal after installing it, when I checked the http error log it said : .htaccess: order not allowed here.

After adding this to the httpd.conf and restarted apache it worked:

< directory "/home/httpd/html/drupal" >
AllowOverride FileInfo Limit Options Indexes
< /directory >

change "/home/httpd/html/drupal" to wherever your document root is.

Friday, February 08, 2008

Apache Error: No space left on device

Apache doesn't start and the error log contains:

[emerg] (28)No space left on device: Couldn't create accept lock
[crit] (28)No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed

After checking your disk it shows that you have plenty of space. The problem is that apache didn't shut down properly, and it's left myriads of semaphore-arrays left, owned by 'apache' user.


ipcs -s | grep apache

Removing these semaphores immediately should solve the problem and allow apache to start.

ipcs -s | grep apache | perl -e 'while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}'

where 'apache' is the owner of the apache process, if that's not the name of the user on your server change it.

How to check running queries and stats in postgres ?

You want to know what query is slowing the database or want to check what's going on with a query you
just run, well in mysql just need to type 'show processlist;', but in postgres you must enable two variables
to check this and other stats.

Edit your postgres.conf which should be on /var/lib/pgsql/data/postgresql.conf for *nix installations and add or change this:

stats_start_collector = true

This must be set to true for the statistics collector to be launched at all.

stats_command_string = true

This enables monitoring of the current command being executed by any server process. The statistics collector subprocess need not be running to enable this feature.

After restarting postgres the following query will show currently running queries

/etc/init.d/postgresql restart

psql -U postgres template1 -c "select * from pg_stat_activity"

only as user "postgres"