Archive

Archive for the ‘Learn’ Category

Drupal: 500 Internal Server Error on Modules Page

September 19th, 2009

When enabling Drupal modules a 500 Internal Server Error can often appear with the default installation. Too identify the cause of the problem look in the error_log file for your web server.

Each time I have encountered this problem the cause has been due to the PHP memory limit being exceeded. The typical error message if you have allocated 16MB is:

PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried to allocate 77824 bytes) in /xxx/yyy/zzz/xxx/drupal/modules/node/node.pages.inc on line 221

There are several very easy ways to fix this by increasing PHPs memory limit:

  • memory_limit = 16M to your php.ini file (recommended, if you have access)
  • ini_set('memory_limit', '16M'); in your sites/default/settings.php file
  • php_value memory_limit 16M in your .htaccess file in the Drupal root

See: http://drupal.org/node/76156 for more details.

PHP , , , , ,

How to do a recursive chmod all PHP files in a site or folder

May 6th, 2009

If you want to do a recursive chmod on a set of files below a given directory or folder using the bash shell you can do the following:

find . -type f -name ‘*.php’ -exec chmod 644 {} \;

This command can be easily adapted to work for other file types or modes. The ‘.’ following ‘find’ specifies the root directory for the operation.

How to chmod all folder/directories below the current directory…

find . -type d -exec chmod 755 {} \;

Alternatively, chmod on all directories below a given directory (./somedir)

find ./somedir -type d -exec chmod 755 {} \;

PHP , , , ,

Getting the local host name using Java

April 24th, 2009

A quick example of how to get the name of the localhost using the Java InetAddress class.

String hostname = null;
try {
InetAddress localhost = Address.getLocalHost();
if (localhost != null) {
hostname = localhost.getHostName();
}
} catch (UnknownHostException e) {
e.printStackTrace();
}
System.out.println(”Hostname is ” + (hostname != null ? hostname : “Unknown”) );

Java ,

Configuring a Local CVSNT Repository and Eclipse

April 21st, 2009

Configuring the Eclipse IDE to use a local CVS (CVSNT) repository on windows isn’t an entirely obvious procedure since CVS and Eclipse are geared to working on Linux/Unix. It is actually quite simple to do but if you miss a couple of points you could spend hours fiddling with it without any luck.

The following article by Seth Thompson walks you through the process:

Seth Thompson’s CVSNT + Eclipse = Pain FAQ

CVS , , ,