Gallery3:Installation on MacOS X - Gallery Codex
Personal tools

Gallery3:Installation on MacOS X

From Gallery Codex

Introduction

This page describes how to install gallery3, using Apache2 via MacPorts, starting with the minimum environment. While it attempts to cover everything you need, it may not cover everything, so you may still need to dig a little. At the same time if you see room for improvement of the instructions, please feel free to update them - maybe you will run into the exact same problem a year from now, so you may be helping your future self.

Required Ports

The first step (other than installing MacPorts) is to install the various ports you will need, which are listed below. Generally you just run 'sudo ports install <port_name>', though details on use of MacPorts are best delegated to the MacPorts Guide. Also, be sure to read and follow any instructions after each port is installed. Not following them will potentially lead to to some problems and wasted hours.

  • apache2
  • mysql5
  • mysql5-server
  • php5
  • php5-mysql
  • php5-mbstring
  • php5-iconv
  • imagemagick

Setting up MySQL

Create a user called gallery3 (you can use something else, but avoid using root). See: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html , though for convenience:

Connect to mysql5 console by typing, and then specifying the password for the 'root' database account when asked:

mysql5 -u root -p

Now from within the console, adjusting the values for user and password as appropriate:

CREATE DATABASE gallery3;
CREATE USER 'gallery3' @'localhost' IDENTIFIED BY 'xxxxxx';
GRANT ALL PRIVILEGES ON *.* TO 'gallery3'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Make note of the database name, username and password, since you will need this later on.

Tweaking PHP

Next, there was some configuring of php.ini to do.

  • Create a symbolic link between /opt/local/etc/php5/php.ini-production and /opt/local/etc/php5/php.ini .
  • Define a value for the date.timezone (pick one from the list here: http://www.php.net/manual/en/timezones.php ). For example America/Montreal
  • Specify short_open_tag = On
  • Modify settings for MySQL, if you have haven't already. This avoids the error "No such file or directory (trying to connect via unix:///tmp/mysql.sock)'",
    • mysqli.default_socket = "/opt/local/var/run/mysql5/mysqld.sock"
    • pdo_mysql.default_socket = "/opt/local/var/run/mysql5/mysqld.sock"
  • There are some other settings that you can add to php.ini file, suggested in gallery3/php.ini

Apache2

Editing the configuration

The Apache2 config file can be found at /opt/local/apache2/conf/http.conf

By default MacPorts uses /opt/local/apache2/htdocs for the served files. If you want to use /Library/WebServer/Documents folder you will need to update the update http.conf file as appropriate.

For php5, add the following lines to the config file:

# Use for PHP 5.x:
AddHandler php5-script	.php 

# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php

AddType text/html	.php

# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps

Extracting Gallery 3

Download the latest version of Gallery 3 and extract the the zip into the documents directory of Apache2 ( /opt/local/apache2/htdocs if using default folder ). You should end up with a folder called gallery3.

Restart Apache 2

First Launch

At this point you should be ready to access to your gallery for the first time.

Assuming that you are connecting from the same host as which the web server is running, enter http://localhost/gallery3 into your web browser and follow the steps.

Note, that if you have a computer setup with IPv6, then you may need to specify '127.0.0.1' instead of 'localhost' for the mysql server address.

Troubleshooting

During my troubleshooting I had to create gallery3/local.php, which I removed when everything started working:

<? defined("SYSPATH") or die("No direct script access");
error_reporting(E_ALL);
ini_set('display_errors', true);
date_default_timezone_get();

Note that when you see error pages you should display the source, since often the top-level error is not the real error. The stack trace usually is closer to the cause.

You can also take a look at the Gallery3:FAQ.

advertisements