Installation on Mac OS 10.4 with MAMP and PostgreSQL


(Basil Shkara) #1

Installation of MySource Matrix on Mac OS 10.4 with MAMP and PostgreSQL
-----------------------------------------------------------------------



Hi there,



I recently installed MySource Matrix for testing and development on a standard Mac OS 10.4 installation with MAMP and the PostgreSQL package at http://www.postgresqlformac.com/.



Here are the steps I took to getting it working with this configuration.



Set up PostgreSQL

-----------------

  1. Download the unified installer from http://www.postgresqlformac.com/ (found on the left hand nav pane about half way down the page). I used v8.2.4.
  2. Unpack and run the Server installer (there is no need to unpack the Client or Developer files). It will install PostgreSQL into /Library/PostgreSQL8 which is not unix-like but will still suffice for our purposes. It will also plant itself in /Library/StartupItems but you can delete the instance there if you do not want it to start up with Mac OS.
  3. Navigate to terminal and check to see if postgres is currently running by using "top".
  4. If it is, great - you can proceed to the next section. If it isn't you will have to start it. The postgres unified installer sets up all required users on your Mac system. Before you can use any of these postgres commands, you will need to switch to the postgres user by typing, "su - postgres".
  5. Still in terminal, navigate to /Library/PostgreSQL8/bin and type "./pg_ctl start -D …/data". /Library/PostgreSQL8/data is where this installation of postgres keeps its database directory. You can also run "./pg_ctl --help" for other options which you can use to control your installation of postgres. For now, all you need to do is ensure that the postgres daemon has started.
  6. Follow instructions on http://www.postgresqlformac.com/ by using your recently installed postgres tools located in /Library/PostgreSQL8/bin.



    Preparing Apache, Pear and PHP

    ------------------------------
  7. Instead of messing around with Apple’s pre-installed versions of Apache, Pear and PHP, you can drop the MAMP bundle into your /Applications folder which will have most things we need already neatly set up for you. To download it, go to http://www.postgresqlformac.com/ and download just the standard MAMP. You don’t really need MAMP Pro.
  8. Unpack and drop it into your /Applications folder.



    Setting up Pear modules

    -----------------------
  9. Bear in mind that MySource Matrix only suppports PHP4 at this stage. With that in mind, it is time to set up all required Pear packages needed by MySource Matrix.
  10. My version of MAMP (1.4.1) did not have a working version of php4 pear and from scouring the MAMP forums, it seems this is a common issue. The simple fix is to copy the /Console and /Archive directories in /Applications/MAMP/bin/php5/lib/php to /Applications/MAMP/bin/php4/lib/php
  11. Next, navigate to /Applications/MAMP/bin/php4/bin and compare your output of “./pear list” with the required packages listed in http://www.postgresqlformac.com/. Then it’s just a matter of typing: “./pear install <package name>” until you have all the required packages.
  12. You will probably run into issues with Mail_Mime spitting out stuff like “pear/Mail_Mime requires PEAR Installer (version >= 1.6.0), installed version is 1.4.9”. The solution is to go to http://www.postgresqlformac.com/ and download and unpack manually into /Applications/MAMP/bin/php4/lib/php/Mail.
  13. NOTE: It is very important that you always use MAMP's php4 pear installation and not OSX's pear which can be invoked by just typing "pear". Always ensure that you are running MAMP's version by prefixing the "./" to ensure that you are running "pear" in the current directory and not the system wide version.
  14. Once you have got all pear packages installed you can now proceed to configuring MySource Matrix.



    Configure MySource Matrix

    -------------------------
  15. It's probably a good time to ensure that MAMP is running in the background. Launch the MAMP control panel from /Applications/MAMP in Finder. Click on "Preferences", click on the "PHP" tab and ensure that the PHP version is "PHP 4".
  16. Download and unpack MySource Matrix into your directory of choice. I unpacked into /Users/Basil/Sites/mysource_matrix. Wherever your unpack it into, ensure that your MAMP Apache settings correspond. Do this by going into MAMP's preferences and clicking on the "Apache" tab. Specify your document root folder accordingly. E.g. my document root folder is /Users/Basil/Sites.
  17. Now you can begin to follow the instructions on http://www.postgresqlformac.com/ with one caveat. You must always use MAMP’s php4 version of php located in /Applications/MAMP/bin/php4/bin. E.g. you would execute step 1 by typing: “/Applications/MAMP/bin/php4/bin/php install/step_01.php .” provided you were already in /Users/Basil/Sites/mysource_matrix.



    Apache aliases

    --------------
  18. You will need to edit MAMP's httpd.conf file located in /Applications/MAMP/conf/apache.
  19. Since MAMP uses port 8888 to run its instance of Apache, you must ensure that any virtual hosts you set up include this port number. As well ensure that you are using fully-qualified domain names, i.e. "127.0.0.1." rather than just simply "localhost".
  20. As an example, here is my configuration:



    [codebox]

    <VirtualHost *:8888>

    DocumentRoot /Users/Basil/Sites/mysource_matrix/core/web

    ServerName 127.0.0.1.



    <Directory "/Users/Basil/Sites/mysource_matrix">

    Options Indexes FollowSymLinks

    Order deny,allow

    Deny from all

    </Directory>

    <Directory "/Users/Basil/Sites/mysource_matrix/core/web">

    Options Indexes FollowSymLinks

    Order allow,deny

    Allow from all

    </Directory>

    <Directory "/Users/Basil/Sites/mysource_matrix/core/lib">

    Options Indexes FollowSymLinks

    Order allow,deny

    Allow from all

    </Directory>

    <Directory "/Users/Basil/Sites/mysource_matrix/data/public">

    Options Indexes FollowSymLinks

    Order allow,deny

    Allow from all

    </Directory>

    <Directory "/Users/Basil/Sites/mysource_matrix/fudge">

    Options Indexes FollowSymLinks

    Order allow,deny

    Allow from all

    </Directory>



    Alias "/__data" "/Users/Basil/Sites/mysource_matrix/data/public"

    Alias "/__lib" "/Users/Basil/Sites/mysource_matrix/core/lib"

    Alias "/__fudge" "/Users/Basil/Sites/mysource_matrix/fudge"

    Alias "/" "/Users/Basil/Sites/mysource_matrix/core/web/index.php/"



    </VirtualHost>

    [/codebox]


  21. Also ensure that your SQ_CONF_SYSTEM_ROOT_URLS variable in data/private/conf/main.inc corresponds to your virtual host settings. E.g. define('SQ_CONF_SYSTEM_ROOT_URLS', '127.0.0.1:8888');
  22. Restart Apache from MAMP's control panel because we have made changes to httpd.conf.
  23. You can then start using your development version of MySource Matrix by navigating to http://www.postgresqlformac.com/ and logging in with username: root, password: root.



    Uninstall

    ---------
  24. To uninstall, all you need to do is trash the MAMP folder in /Applications and trash PostgreSQL from /Library and /Applications. Simple, clean and easy.

(Avi Miller) #2

Awesome post, thanks. However, I would take out the "Options Indexes" on a production system, otherwise Apache may display a list of files to a remote user instead of just denying access to the folder.


These days, I don't even bother adding any of those <Directory> blocks. I just use the Alias lines.


(Mat Griffin) #3

nice write up. However I always find serving from OS X slow, similar hardware running CentOS seems faster IMHO


(Avi Miller) #4

The new Intel MacOS X Servers are about as fast as a RHEL4 box with the same hardware, if you compile your own binaries for Apache, PostgreSQL and PHP.

(Basil Shkara) #5

Thanks! Although I wouldn't use MAMP as part of a production stack. I posted the instructions for people who want to test or develop on Matrix.



I believe living-e (makers of MAMP) are coming out with a production version of MAMP soon though.


(Masoudutube) #6

Is it possible to get an update instruction with the following:
Mac OS 10.5.3

PostgreSQL 8.3.1 http://www.postgresqlformac.com/.

MAMP 1.7.1 with PHP5 http://www.postgresqlformac.com/

Mysource Matrix 3.18.2



I finally got all the steps working however when I login to _admin I get the following error:

Fatal error: DAL::require_once() [function.require]: Failed opening required ‘/Users/masoud/Sites/mysource_matrix/core/lib/DAL/Oven/authentication_default/authentication_defaultQueries.inc’ (include_path=’.:/Users/masoud/Sites/mysource_matrix/php_includes:/Applications/MAMP/bin/php5/lib/php:/Applications/MAMP/bin/php5/bin/:/applications/mamp/bin/php5/bin/pear:/applications/mamp/bin/php5/lib/php/pear’) in /Users/masoud/Sites/mysource_matrix/core/lib/DAL/DAL.inc on line 1575



I’ve checked for mysource_matrix/core/lib/DAL/Oven/authentication_default/authentication_defaultQueries.inc, there is no such dir or file.



Any ideas?



Thanks



Masoud


(Basil Shkara) #7

The instructions provided for 10.4 should be fairly similar for 10.5 however I have not tested this setup on Leopard.


Those files which are missing are generated whilst running step_03.php.



If there are no files in /Users/masoud/Sites/mysource_matrix/core/lib/DAL/Oven then the baking process that occurs during step_03 was unsuccessful.



You may want to check your permissions. Are you running step_03 as user masoud? Presumably that would allow you write access to /Users/masoud/Sites/mysource_matrix/core/lib/DAL/Oven.


(Masoudutube) #8

[quote]The instructions provided for 10.4 should be fairly similar for 10.5 however I have not tested this setup on Leopard.


Those files which are missing are generated whilst running step_03.php.



If there are no files in /Users/masoud/Sites/mysource_matrix/core/lib/DAL/Oven then the baking process that occurs during step_03 was unsuccessful.



You may want to check your permissions. Are you running step_03 as user masoud? Presumably that would allow you write access to /Users/masoud/Sites/mysource_matrix/core/lib/DAL/Oven.[/quote]

Thanks for the reply Basil.



I'll try step 3 again, however I didn't see any errors.



Yes I'm running step 3 as masoud. should I try sudo?



Is there a way to manually add these files, or any files that's missing?



Thanks



Masoud


(Avi Miller) #9

Yes, try as sudo so that you have no permission issues when running step_03.php

[quote]Is there a way to manually add these files, or any files that's missing?[/quote]

No -- the step_02.php and step_03.php scripts create configuration files based on the state of your system during installation and which packages you are installing. They need to be successfully created by the installation process.

(Bel) #10

I'm very new to this and am trying to install Matrix (v3.18.2) in order to evaluate it. I'm running OS X 10.5.3 and following your instructions above.


In terms of the PostgreSQL setup, I should note that I couldn't seem to get the 'postgresqlformac' installation to work but Mark Liyanage's one was successful. I've created the database and users (http://matrix.squiz.net/resources/installation/postgresql-setup) but stopped at the DSN bit - I figured I did this after running step_01.php. I've also installed MAMP, the additional components and configured Apache - all seemed well.



I then followed the install guide (http://matrix.squiz.net/resources/installation) but got stuck at step_01.php - I can't seem to generate a main.inc file. Given the latest Matrix uses PHP5 I changed my MAMP prefs accordingly, I did try this running 4 and 5 but neither seems to generate a file.



This is probably so basic… but am I supposed to be able to see the main.inc file in my list of files (in Finder) immediately after running step_01.php or is this some sort of hidden file in the data/private/conf directory?

I'm not very familiar with working in Terminal so didn't know how to start editing after typing $ vi data/private/conf/main.inc it just gave me a blank screen.



I'm not sure how to proceed, any help would be really appreciated as I really want to test the CMS.


(Avi Miller) #11

main.inc is not a hidden file, so depending on where you unpacked Matrix, it should be visible in Finder after you have run step_01.php. Can you give us more information about where you unpacked the files and what output you see in the Terminal when you run step_01.php?

(Bel) #12

Hi, it seems nothing happens when running install/step_01.php in either Terminal or running it through the browser (blank screen). I get no error messages, or any sort of progress indicators at all. I’ve double-checked that PHP (v5.2.5) is working as I can see my phpinfo file at http://localhost:8888/ and at http://localhost:8888/


I put the unpacked mysource_matrix folder in /users/belinda/sites and updated the MAMP Apache document root to “/users/belinda/sites”. I could get to the MAMP start page fine.



Is there something I need to do in Apache prior to running step_01.php? I thought maybe I needed to set up Apache Aliases first so tried pasting your code at the end of the httpd.conf file, restarted the server and ran step_01.php again. Still nothing. I noticed however, after adding the alias in httpd.conf that MAMP’s start page then displayed a blank screen - as did any references to PHP files (at localhost or 127.0.0.1:8888). I’ve now reverted back to the original httpd.conf just in case I wasn’t supposed to edit it yet.



I hope this helps to elaborate on some of the possible issues!



Thanks

Belinda


(Avi Miller) #13

The installation is always run on the command-line (not via a browser). You should be running the command like so:

    $ cd /Users/belinda/sites/mysource_matrix
    $ php install/step_01.php /Users/belinda/sites/mysource_matrix


That should create /Users/belinda/sites/mysource_matrix/data/private/conf/main.inc for you to edit with your specific settings.

Once you have successfully run the installation, you can then setup the Apache Aliases so that you can access MySource Matrix via a browser.

(Bel) #14

I will try this tonight when I’m back in front of the Mac. I should say that during this process I’ve always been referencing MAMP’s php as noted in the instructions:
[indent]3. Now you can begin to follow the instructions on http://matrix.squiz.net/resources/installation with one caveat. You must always use MAMP’s php4 version of php located in /Applications/MAMP/bin/php4/bin. E.g. you would execute step 1 by typing: “/Applications/MAMP/bin/php4/bin/php install/step_01.php .” provided you were already in /Users/Basil/Sites/mysource_matrix.[/indent]

Example:

    $ cd /Users/belinda/sites/mysource_matrix
    $ /Applications/MAMP/bin/php5/bin/php install/step_01.php /Users/belinda/sites/mysource_matrix


I hope just referencing "php install/step_01.php" does the trick (and would be the simplest solution ever - doh!). Will let you know how it goes. Thanks again.

(Avi Miller) #15

Yes, that should work. :) If not, please try and post the output you get in the Terminal so we can see what happens.

(Bel) #16

Thanks, that sorted it :slight_smile:


I got through to step_02 (had a few errors which were solved previously in these forums), however now stuck with this one:


    ------------------------------------
    PGSQL SECONDARY AND TERTIARY USER PERMISSIONS FIXED
    ------------------------------------
    
    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42883]: Undefined function: 7 ERROR:  function sq_grant_access(unknown) does not exist
    LINE 1: SELECT sq_grant_access($1)
    			   ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.' in /Users/Belinda/Sites/mysource_matrix/core/lib/DAL/DAL.inc:601
    Stack trace:
    #0 /Users/Belinda/Sites/mysource_matrix/core/lib/DAL/DAL.inc(601): PDOStatement->execute()
    #1 /Users/Belinda/Sites/mysource_matrix/core/lib/db_install/db_install.inc(724): DAL::execPdoQuery(Object(PDOStatement))
    #2 /Users/Belinda/Sites/mysource_matrix/install/step_02.php(121): grant_secondary_user_perms()
    #3 {main}
      thrown in /Users/Belinda/Sites/mysource_matrix/core/lib/DAL/DAL.inc on line 601


I have checked plpgsql language on postgres and got "createlang: language "plpgsql" is already installed in database "mysource_matrix" "

Here's my db.inc if this helps:

<?php
$db_conf = array (
'db' => array (
'DSN' => 'pgsql:dbname=mysource_matrix',
'user' => 'matrix',
'password' => '',
'type' => 'pgsql',
),
'db2' => array (
'DSN' => 'pgsql:dbname=mysource_matrix',
'user' => 'matrix',
'password' => '',
'type' => 'pgsql',
),
'db3' => array (
'DSN' => 'pgsql:dbname=mysource_matrix',
'user' => 'matrix_secondary',
'password' => '',
'type' => 'pgsql',
),
'dbcache' => array (
'DSN' => 'pgsql:dbname=mysource_matrix',
'user' => 'matrix',
'password' => '',
'type' => 'pgsql',
),
);
return $db_conf;
?>

Any ideas?

(Avi Miller) #17

Have you created the matrix_secondary user for PostgreSQL using the "createuser" command?

(Bel) #18

Here's the user list:
List of roles

Role name | Superuser | Create role | Create DB | Connections | Member of

------------------±----------±------------±----------±------------±----------

matrix | no | no | no | no limit | {}

matrix_secondary | no | no | no | no limit | {}

postgres | yes | yes | yes | no limit | {}

(3 rows)


(Bel) #19

I don't know if this helps troubleshoot, but the first time I ran step_02.php, I got the error message:

    -----------------------------------------------------------------------------------------------------------------------+
    | PHP Warning																										   |
    |-----------------------------------------------------------------------------------------------------------------------|
    | require_once([SYSTEM_ROOT]/data/private/conf/messaging_service.inc): failed to open stream: No such file or directory |
    +-----------------------------------------------------------------------------------------------------------------------+
    
    Fatal error: require_once(): Failed opening required '/users/belinda/sites/mysource_matrix/data/private/conf/messaging_service.inc' (include_path='.:/users/belinda/sites/mysource_matrix/php_includes:/Applications/MAMP/bin/php5/lib/php') in /Users/Belinda/Sites/mysource_matrix/core/include/messaging_service.inc on line 18
    Macintosh:mysource_matrix Belinda$ /applications/mamp/bin/php5/bin/php install/step_02.php /users/belinda/sites/mysource_matrix


so then I changed the line in my main.inc file from:
define('SQ_CONF_SYSTEM_ROOT_URLS', '127.0.0.1/mysource_matrix');
[b]to:[/b]
define('SQ_CONF_SYSTEM_ROOT_URLS', 'localhost/mysource_matrix');

This seemed to get me further although I'm not sure if it's caused this current "Uncaught exception 'PDOException'..." error?

(Avi Miller) #20

The Matrix installation is not very forgiving of errors. I would erase everything (and drop the database) and start again. You can keep the two PostgreSQL users though.