php: image manipulation

Categories: php, unix

Tags: fedora, gd, image, php, ubuntu

the gd image library provide functions to manipulate image files.

on some installations, this does not come as default and needs to be installed.

on fedora, the command is

yum install php-gd

on ubuntu, the command is

sudo apt-get install php5-gd


php: increase memory limit

Categories: php, unix, apache2

Tags: memory, php

errors like ‘allowed memory size of x bytes exhausted’ or ‘zero size reply’ usually means there’s not enough memory allocated for php. you need to increase the value.

if you have admin access, you can edit /etc/php.ini, locate and update ‘memory_limit’ to values like 16M, 32M, 64M. this change is global to the system. restart apache after update.

if not, add this in php script:

PHP:

ini_set("memory_limit""32M");

unix time to human readable format

Categories: unix, bookmark

Tags: awk, time, unix

some log files such as squid log uses uses unix time as timestamp, which looks like some random number and doesn’t make sense.

you can use this online conversion tool.

to run from unix command line, to convert to human readable format, eg in yyyy-mm-dd hh:mm:ss format,

Code:

echo <timestamp> | awk '{print strftime("%Y-%m-%d %H:%M:%S", $1);}'

replace <timestamp> with the unix timestamp. the format for strftime is similar to php function with the same name.

i put this in a shell script so i don’t have to remember the awk command. if there’s a simpler way to do it, please post in comment.


mediawiki: blank page after install

Categories: php, unix, wiki

Tags: fedora, mediawiki

after installing the lastest version of MediaWiki (V1.12.0), a blank page is displayed when accessing the site.

php error log shows:

PHP Fatal error: Class ‘DOMDocument’ not found in /path/to/wiki/includes/Preprocessor_DOM.php on line 566, referer: http://path/to/wiki/config/index.php

previous versions didn’t have this problem.

this was installed on fedora core 5 server. after some researches, i found that you need to install php-xml component to run (as root):

$ yum install php-xml
$ /etc/init.d/httpd restart

i don’t have root access to that particular server, so i found an alternate quick fix. add the following to LocalSettings.php:

PHP:

$wgParserConf['preprocessorClass'] = 'Preprocessor_Hash';

linux server version info

Categories: unix

Tags: linux, ubuntu, version

to find out the ubuntu version the server is running, the information can be found in file /etc/issue.

alternatively, run this command:

$ lsb_release -a

to find out the kernel version, run this command:

$ uname -a

these commands are probably applicable to other linux builds.


1 2 »

Affliates

Spreadfirefox Affiliate Button