Monday, July 28, 2008

Installing Matrix on Centos 5 - part 2 - Matrix Install

In the previous post, we installed a basic CentOS 5.1 system with the requirements for installing MySource Matrix 3.18+. In this post, we'll install Matrix itself... If you haven't read the previous post, please do, paying particular attention to the caveats at the beginning of the post.

Let's continue:

23. Set permissions on PostgreSQL. To do this we need to edit the file /var/lib/pgsql/data/pg_hba.conf and restart Postgresql. Using your favourite editor (there is a link to a vi tutorial in the previous post) edit /var/lib/pgsql/data/pg_hba.conf. We want to add two lines above the line that begins with 'local'. When you begin to edit, the end of the file should look like this:

We want to change it to look like this:

So we've added the two lines to allow the 'matrix' and 'matrix_secondary' users to access the database named 'matrix', but only from the local machine, and only with password authentication. You can use md5 as the authentication method if you like, but since we're only using unix sockets on a local machine, plaintext password authentication is ok.

24. Now we want to create the 'matrix' and 'matrix_secondary' users within postgres. To do this we need to become the postgres user. We use the 'su' command to do this, and then run the createuser command to create the db user accounts:


lets take a look at what happened there...

* the 'su' command changed the active user from 'root' to 'postgres'.
* the 'cd' command changed the current working directory to /var/lib/pgsql (it avoids a niggling warning about being in the /root directory)
* the 'createuser -P matrix' command tells postgres to create a db user account called 'matrix' and prompt for a password to authenticate the user. (For the purpose of this post I've used 'password' as the password. Not very original, I know ;) )
* we don't want the matrix user to be a superuser (security reasons)
* we don't want the matrix user to be able to create databases (security reasons)
* we don't want the matrix user to be able to create new roles (security reasons)
* we create another db user account called 'matrix_secondary' with the same options as the 'matrix' user

25. Now it's time to create the database where matrix will store its data. We do this using the postgres user as well...


lets take a look at what this does... the 'createdb -O matrix -E SQL_ASCII matrix' command tells PostgreSQL to create a database called 'matrix', owned (-O) by the db user 'matrix', and using the SQL_ASCII encoding scheme for its data.

26. We need to add the plpgsql programming language to the newly created database. We use the 'createlang' command to do this. This command is self-explanatory ;)


Now that we've done that, we need to 'exit' so that we are logged in as 'root' again, and restart the postgresql server to make the changes to pg_hba.conf 'stick'. To do this we use '/etc/init.d/postgresql restart' from the prompt...


Now we need to grant permissions to the matrix_secondary user to access the database. The matrix user will have access permissions already.

We'll access the database as the postgres user (so we'll need to 'su postgres' again) use the 'psql' sql shell, and run the 'grant all on database matrix to matrix_secondary;' command, and then '\q' to exit psq, and 'exit' to become the root user again.


27. With that done, we can go ahead and download Matrix. First, we'll 'exit' to get back to being the root user, then we'll use wget to download the 3.18.3 version of Matrix. I got the url for the download from the Matrix website.


This downloads the tarball of the matrix install into /root.

28. Now we create the directory /home/websites to throw our matrix install into, change into the directory, and extract matrix there:


Running this command will create the mysource_matrix directory as it extracts. When it's done, we can get into the interesting stuff...

29. Change directories into the mysource_matrix directory, and run the php script in install/step_01.php. We need to pass the matrix root directory as the first argument, so we use `pwd` (it's shorter). Please note that the ` is not a normal inverted comma, it's the reverse inverted comma found (usually) next to the '1' key.


This will generate a whole bunch of "interesting" information that you can basically ignore, unless it indicates that there are errors.

If it returns successfully, you'll see something like this:


30. Now, we need to edit some configuration files... First, we'll set up /home/websites/mysource_matrix/data/private/conf/db.inc. Using your favourite editor, make it look like this (with the appropriate password set, of course, and I haven't removed the lines at the end, they're just not showing on the screen...)


31. Now we need to edit /home/websites/mysource_matrix/data/private/conf/main.inc. You'll need to change the following:

* You need to set at least one System root url. The system root urls are a list of URLs that Matrix will answer to. In the following, I've set 3 system root urls that Matrix will respond to:

Down the track, we'll configure apache to answer to these URL's. If these are hostnames that will not resolve to the machine using DNS (in my example I'm just creating a testing system) you'll need to add host entries to any machines that you want to connect to the matrix system.

* You need to set default and tech email addresses:


* You probably want to set your web and cron memory limits to something larger than 16Mb, I've chosen 64:


* You may also want to set a different System Name, I've chosen 'Matrix Test System':

* I've chosen to leave the system owner field empty, but you can put in a personal or company name there if you like.

When you're happy with the main.inc configuration, save your changes.

32. Now we run step_02.php by running 'php install/step_02.php `pwd`'. Check to make sure you are in the /home/websites/mysource_matrix directory before you do this.


This will (again) generate a large amount of interesting information. Again, you can ignore it unless it indicates an error. If it's successful you'll see something like this:


33. Now we run compile_locale.php using 'php install/compile_locale.php `pwd`'. We will have to do this again after step_03.php.


It will give a warning about not having specified a locale, which can be ignored. When it completes you should see something like this:


34. Now we run step_03.php with the command 'php install/step_03.php `pwd`'.


While it's running you'll get a warning about call by reference being deprecated. You can ignore the warning. When it's done, you'll see something like this:

35. Once more through compile_locale...


36. We need to fix the filesystem permissions so httpd has write access to the data and cache directories. To do this we run three commands: 'chown -R apache:apache *', 'chmod -R 500 *', and 'chmod -R 700 data cache'.


37. Now we need to configure apache to send requests to our system root urls to the matrix system. To do this, we create the file '/etc/httpd/conf.d/matrix.conf' and put in the content as described on the the Squiz Matrix installation page.

38. Now we just need to reload apache to activate the changes, and we're away!

39. A couple more things need to be done... Adding cron entries is one, we need to add one for Matrix's core/cron/run.php script, and one for session_cleanup.sh... To do this we use 'crontab -e -u apache', and configure it like so (pls excuse the line breaks):


40. The other thing that should be done is postgresql optimisation. However, this is an arcane art, with many twists and turns. Matrix will run without postgresql optimised, but when your site gets large it will slow down. You'll either need to get help on this one, or read up the Postgresql documentation and forums and have a stab at it yourself.


That aside, we now have a running Matrix system. We should be able to access it on the url we assigned it in the virtualhost entry (you may need to add a hosts entry to get it resolving correctly). The administration interface is reached by appending /_admin to the URL.

Enjoy!

1 comment:

  1. Unfortunately with version 3.22.3 of MSM something has gone wrong I get the error:

    MySource Error
    [ASSERT EXCEPTION] Asset "session_handler_default" is not installed on the system, unable to include its source file [SYS0320]

    When attempting to log into the MSM system.

    ReplyDelete