Thursday, August 4, 2011

How to compile Image::Scale 0.06 on Solaris

Useful when installing slimserver 7.6 ....

===
Download tarball from http://svn.slimdevices.com/repos/slim/7.6/trunk/vendor/CPAN/
Then compile;

cd Image-Scale-0.06
/opt/csw/bin/perl Makefile.PL

Edit the Makefile

$ diff Makefile Makefile.orig
34,35c34,35
< CC = gcc
< CCCDLFLAGS =
---
> CC = cc
> CCCDLFLAGS = -KPIC
41c41
< LD = gcc
---
> LD = cc
283,284c283,284
< CCFLAGS = -D_REENTRANT -I/opt/csw/bdb44/include -I/opt/csw/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
< OPTIMIZE =
---
> CCFLAGS = -D_REENTRANT -xO3 -xtarget=generic -xarch=generic -I/opt/csw/bdb44/include -I/opt/csw/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
> OPTIMIZE = -xO3 -xtarget=generic -xarch=generic

make

===

Ta-da!

Sunday, March 27, 2011

Gallery 3 install

This week I decided it was high time I upgraded from gallery2 to gallery3.

So here are my crib notes. Very rough outline as it assumes you have a webserver and mysql database already up and running but it covers the tricky stuff. The gallery3 install wizard should just work after this.

Create the mysql database
# mysql -u root -p
mysql> create database gallery3;
mysql> create user 'g3user'@'localhost' identified by 'mypass';
mysql> grant all privileges on gallery3.* to g3user@localhost;

Install gallery3
Copy zipfile to /webserverhome/html and unzip
cd gallery3
mkdir var

Configure php
NB: The location of the php.ini file can be found by running a phpinfo test page on your webserver. ie create a file called t.php;

Now load this page - http://mywebserver/t.php - and check the "Loaded Configuration File " setting.
Edit the config file with the following settings.
vi /opt/csw/php5/lib/php.ini
short_open_tag = On
; Maximum allowed size for uploaded files.
upload_max_filesize = 24M
[Date]
; Defines the default timezone used by the date functions
date.timezone = Europe/London

Edit apache config to allow index.php to be a default loadable page
This is required for the setup wizard to work.
vi /etc/opt/csw/apache2/httpd.conf
<IfModule dir_module>
DirectoryIndex index.csw.html index.html index.php
</IfModule>

Restart apache and change the gallery3 file permissions to be world writeable

svcadm restart cswapache2
pfexec chmod -R o+rwX gallery3

Run the setup wizard

Just point your browser at http://mywebserver/gallery3

When complete, fix those file permissions
Finally, change gallery3 ownership to the apache user and lock down file permissions.
Check you can browse and upload pictures. If it doesn't work then you've probably made a bungle with the file perms.

Monday, January 31, 2011

Adding ZFS swap dynamically

If we have a ZFS swap device and we discover that it is not big enough then we have two options to add more swap.

The supported option is to create a new swap device and then activate it with swap -a. The disadvantage of this option is that we have to add the new device to the vfstab which makes the file and future swap -l outputs untidy as we will now have swap and swap2.

The unsupported option is to grow the existing swap and then add the new area as a second swap device. No editing of the vfstab is required and after the reboot we only have one swap device.

Here are the steps for the second option. Note that the offset is calculated by (swaplo + blocks);

# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
# zfs list rpool/swap
NAME USED AVAIL REFER MOUNTPOINT
rpool/swap 2G 102G 791M -
# zfs set volsize=4G rpool/swap
# env NOINUSE_CHECK=1 swap -a /dev/zvol/dsk/rpool/swap $((16+4194288))
# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
/dev/zvol/dsk/rpool/swap 256,3 4194304 4194304 4194304

Note that if we want to remove this second device and resize the volume back down then we can use the "/usr/sbin/swap -d swapname [swaplow]" syntax and then resize the volume. Obviously this only works before we reboot.
# swap -d /dev/zvol/dsk/rpool/swap 4194304
# swap -l
swapfile dev swaplo blocks free
/dev/zvol/dsk/rpool/swap 256,3 16 4194288 4194288
# zfs set volsize=2G rpool/swap