CONFIGURIATION INSTRUCTIONS

 

 

Components

As you already know Photo Organizer is based on several software components that have to be configured in order to fully support Photo Prganizer. This document attempts to list the configuration options for each software component apart.

There are four software components to be configured:

  1. PostgreSQL Client Authentication
  2. PHP Configuration
  3. Apache HTTP Configuration
  4. Photo Organizer Customizations

 

PostgreSQL Client Authentication

There is only one thing that must be configured for the PhostgreSQL server, and that's the client authentication. Whitout proper client authentication PHP cannot access the PostgreSQL database and therefore Photo Organizer will not work.

Consider the following setup. The PostgreSQL server is up and running with the database system stored at /export/pgdata/db listening on 192.168.42.20:5432. The Photo Organizer database is po_database created and used by po_user protected with po_password.

The Apache HTTP server is running on 192.168.42.22 with mod_php. By default it's not possible to access po_database from any host via TCP/IP. To enable TCP/IP access you have to edit the pg_hba.conf file and add a single entry.

[balint@mamba ~]$ cd /export/pgdata/db
[balint@mamba db]$ ls
base    pg_clog      pg_ident.conf  pg_xlog          postmaster.opts
global  pg_hba.conf  PG_VERSION     postgresql.conf  postmaster.pid
[balint@mamba db]$

The pg_hba.conf file contains an impressive description of the possible options. For a strict password protected client authentication add the following line to the end of the file:

# TYPE  DATABASE     USER        IP-ADDRESS        IP-MASK           METHOD
host    po_database  po_user     192.168.42.22     255.255.255.255   password

 

PHP Configuration

One of the most frequent problem that occurs when using a fresh Photo Organizer installation is that the file upload fails. This is because PHP has a built in protection against unusual client behaviour and Photo Organizer does lot's of unusual things.

There are few configuration directives that have to be set in your /etc/php.ini.

  • file_uploads = On|Off - This enables HTTP file uploads, make sure it's on.

    file_uploads = On

  • upload_max_filesize = integer - The maximum size of an uploaded file in bytes.

    upload_max_filesize = 150M

  • max_execution_time = integer - This sets the maximum time in seconds a script is allowed to run before it is terminated. This helps prevent poorly written scripts from tying up the server. The default setting is 30 which might not be enough to perform a 100Mb bulk upload that can take several minutes. Set this value according to your needs. In my case this is set to 5 minutes.

    max_execution_time = 300 ; 5 minutes

  • post_max_size = integer - Sets the maximum size of post. This setting also affects file upload, therefore to upload large files, this value must be larger than upload_max_filesize.

    post_max_size = 155M

  • memory_limit = integer - This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server. When doing a 100Mb bulk upload the script needs to allocate over 100Mb since memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. Set this value according to your needs.

    memory_limit = 170M

  • upload_tmp_dir = /tmp - This sets the temporary directory where the uploaded file will be stored until the upload script lives. Usually, you don't have to set this directive, but we had at least one case when the upload mysteriously failed and after setting this directive to /tmp - which should be the default value - suddenly everything worked. If you run into trouble with file uploads and your file sizes and memory limit is right, try to set this directive.

    upload_tmp_dir = /tmp

  •  

    Apache HTTP Configuration

    Apache has several configuration directives that might limit Photo Organizer's operation. For instance by default Apache limits the number of HTTP request fields to 100. If you display more than 100 photos on a page and you want to move all of them into a different folder only the first 98 photos will be moved (since Photo Organizer uses 2 fields to identify the destination and source folders).

    Verify your apache configuration usually located at /etc/httpd/conf/httpd.conf.

  • LimitRequestBody integer - This directive specifies the number of bytes from 0 (meaning unlimited) to 2147483647 (2GB) that are allowed in a request body. The default value is 0 and you should make sure that it is not set or it's set to 0 since you have already specified this parameter via the post_max_size directive in PHP.

  • LimitRequestFields integer - This directive limits the number of HTTP request header fields that will be accepted from clients (like Photo Organizer), ranging from 0 (meaning unlimited) to 32767. The default value is defined by the compile-time constant 100. Normally the number of request header fields used by a client rarely exceeds 20, but in case of Photo Organizer this might become much larger depending on your settings. The value should be increased if you get an error response from the server that indicates too many fields were sent in the request.

    LimitRequestFields 250

  • LimitRequestFieldsize integer - This directive specifies the number of bytes from 0 to the value of the compile-time constant 8190, that will be allowed in an HTTP request header. Should you need to change the LimitRequestFields directive, make sure to allow more space for the increased number of request fields.

    LimitRequestFieldSize 16380

  •  

    Photo Organizer Customizations

    Photo Organizer uses several helper applications which might not be accessible by PHP in certain environments. You can specify the full path to these applications via the PO configuration file located at include/config.php - the path is relative to your PO installation.

  • IMAGEMAGICK - This utility program is used to scale images. If on your system ImageMagick is installed at a custom location please specify the full path to the convert utility.

    $sys_convert = "/usr/bin/convert";

  • JPEGTRAN - This utility program is used to rotate and flip images because it works by rearranging the compressed data (DCT coefficients), without ever fully decoding the image, therefore, its transformations are lossless. If you leave this directive unset ImageMagick will be used instead.

    There is a good reason to leave this directive unset. Unfortunately JpegTRAN cannot transform images perfectly. As a workaround I tried to generate images of dimensions multiple of 16 and 8, but the result was always the same. The image was shifted in one or both directions and the overflow appeared on the other side of the image. If you have a newer version of JpegTRAN, that fixes this issue you should use it instead of ImageMagick.

    $sys_jpegtran = "/usr/bin/jpegtran";
    $sys_jpegtran = ""; // if you want to use ImageMagick instead

  • DCRAW - This utility program is used to convert RAW image files (produced by digital cameras) into temporary PPM files that are scaled afterwards with ImageMagick to produce a thumbnail and a preview. This is new software so you will have to compile and install this program separately, but it will allow you to store the original RAW images in your Image Repository and still have a preview. Please note: dcraw changes its behaivor and allowable command-line arguments from release to release. Photo Organizer's integration tested with dcraw v8.15.

    $sys_dcraw = "/usr/local/bin/dcraw";

  • PS2PDF - This utility program is used when printing PDF documents. Photo Organizer generates PS documents that are converted into PDF using this program.

    $sys_ps2pdf  = "/usr/bin/ps2pdf";

  • TAR and ZIP - These utility programs are used during bulk upload. The files to be uploaded have to be zipped or tared and uploaded at once. Than Photo Organizer will use these utilities to unzip and untar the uploaded file. It is important to mention that the tar utility must support the -z and -j options. If on your system tar doesn't support these options, install gtar and specify the path accordingly.

    $sys_tar     = "/bin/gtar";
    $sys_unzip   = "/bin/unzip";

  • Comments and corrections are welcome at balint@k-i-s.net.