User:Dan Nessett/Technical/How to set up a CZ clone on CentOS 5

This page provides instructions describing how to set up a Citizendium clone on the CentOS 5 operating system. Creating a CZ clone is useful for a number of purposes, including:


 * Storing a local copy of Citizendium on a lap-top or other device so articles are accessible when there is no available network connection.
 * Creating a local copy of Citizendium for the purpose of fixing bugs in the modified version of Mediawiki that forms its software base or developing extensions to that code.

Installing the necessary software infrastructure
CZ is implemented by a modified version of the Mediawiki software. This software relies on several software components that underly its operation, specifically:


 * PHP - an object-oriented interpreted language. Mediawiki is written in PHP and its software modules execute when accessed through a web server.
 * Apache2 - an open source industrial grade web server.
 * Postgres - an open source industrial grade database system.

Together, these are frequently referred to as a LAPP stack (Linux Apache2 Postgres PHP stack). Note that many Mediawiki implementations use the MySQL database system, rather than Postgres. While it might be possible to install Citizendium's wiki content using a MySQL database, doing so would represent experimental development. This how-to presumes the installer uses Postgres.

There are a number of different platforms that support a LAPP stack and potentially any of them could be used to support a CZ clone, While these instructions describe how to set up a CZ clone on the CentOS 5 operating system, it is possible to install CZ's software on other Linux platforms and even on other operating systems (e.g., Mac OS X, Windows). There are instructions for setting up a CZ clone on Ubuntu. Those interested in using using a OS platform other than Ubuntu or CentOS 5 will have to do the research necessary to accomplish that.

It must be noted that unlike Ubuntu and other Debian Linux variants, CentOS is much more expert friendly and much less novice friendly. For those without significant experience with Linux systems (specifically, installing and administering them), the recommended OS for a CZ clone is Ubuntu. However, the production version of the CZ wiki runs on Fedora, the same base used for CentOS, so for those with the requisite experience and skills, implementing a CZ clone for development work on CentOS has certain advantages. But with those advantages comes risks. The yum software installation system on CentOS is prone to significant configuration problems, especially when setting up its repositories. So, those choosing to use CentOS do so at their own risk. Caveat Emptor.

These instructions have been tested on a fresh CentOS 5.4 install.

Installing postgres
The version of postgres we want is not available through the normal CentOS software repositories. So, we have to modify the repository information to direct yum to install the correct version. (Note: these instructions are based on those given at Yet Another Guide.

First find out what is the latest install package for postgres 8.3 (install packages for CentOS have the suffix rpm). Using a new tab or browser window, follow the link postgres rpms. Three files should display in the browser window. One of these will have the name pgdg-centos-8.3-x.noarch.rpm, where x will be a number, such as 6. Now download the appropriate yum repository configuration by entering the following at a terminal command prompt (replacing the x in the file name with the integer just discovered):

cd /tmp sudo wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-x.noarch.rpm

Then install this information using the following command (again changing the x to the appropriate integer):

sudo chmod +x pgdg-centos-8.3-x.noarch.rpm sudo rpm -ivf pgdg-centos-8.3-x.noarch.rpm

If you are working on a CentOS installation on which some other software has already been installed, it is possible that other repositories are indicated in the yum configuration files that may interfere with the installation of postgres 8.3. You can determine this as folows. Execute the following commands:

cd /etc/yum.repos.d sudo gedit CentOS-base.repo &

If this file is non-empty, then do the following. (If the file is empty, simply close it without making any changes). There are sections in the configuration file each headed by a word in square brackets. If there are two sections labeled  [base]  and  [updates]  then at the bottom of those sections add the line:

exclude=postgresql*

Click on the Save button at the top of the edit window and close it.

Now execute the following commands:

sudo yum install postgresql sudo yum install postgresql-server

For each command a bunch of text is displayed followed by a line that specifies the total download size. The next line is a prompt: Is this ok [y/N]:. You must type y. The default is N, which (of course) means no and taking it will abort the install.

The install of postgres on CentOS does not initialize the directory that postgres uses to store database information. So, the next step is to do this. Execute the following commands:

sudo /etc/rc.d/init.d/postgresql initdb

Installing postgres doesn't mean the server starts up when the system boots. We have to configure the system to do that. First, check that chkconfig is in your execution path. At a command prompt enter:

chkconfig

If the error bash: chkconfig: command not found is returned, you will have to add /sbin to $PATH. This requires editing .bash_profile (remember to cd to your home directory):

gedit .bash_profile &

In the edit window there should be a line starting with $PATH. At the end of this line add :/sbin (don't forget the colon at the beginning of this text and there should be no space between the colon and the rest of the line). Then save the edit, exit the editor and type:

source .bash_profile chkconfig

This should result in an error message about usage. When chkconfig is working, enter the following commands:

sudo chkconfig --add postgresql sudo chkconfig postgresql on

Now reboot your system and when that completes open a terminal window. Type:

su su postgres psql

A welcome message should display, followed by hints on psql commands and then the prompt postgres=#. At this prompt type \q.

Your terminal identity was changed from your CentOS username to root and then to postgres. Get back to root by typing:

exit

You should see a # prompt. There is one more thing we have to do before proceeding. In CentOS, the default trust model is ident based. This causes problems when configuring the postgres databases using pgAdmin III. So, we need to make one change to the postgres configuration file. Execute the following commands at a terminal window prompt:

cd /var/lib/pgsql/data gedit pg_hba.conf &

An edit window should appear. Scroll to the end of the file and find the entry with the comment "local" is for Unix domain socket connections only. The next entries control access when connections to the postgres server come from the local host. Copy the text below and replace the corresponding text. The entry should now look like the following:

local  all         all 				trust host   all         all         127.0.0.1/32          trust
 * 1) "local" is for Unix domain socket connections only
 * 2) local  all         all                               ident sameuser
 * 1) IPv4 local connections:
 * 2) host   all         all         127.0.0.1/32          ident sameuser

Save the file and exit the editor. Now restart the postgres server with the following command:

/etc/rc.d/init.d/postgresql restart

This change allows you to manipulate postgres through pgAdmin III without changing your CentOS user identity using su or sudo. The install of postgres is now complete. You can exit from root or remain at root and ignore the sudo prefixes in the next section.

Installing apache2 and PHP
Installing postgres is a lot of work. Fortunately, installing the other two components of the LAPP stack takes much less effort. First, we will install the apache2 web server. In a terminal window execute the following command:

sudo yum install httpd

Follow the normal install procedure by answering y to the question. You may be prompted with a question whether it is OK to import a GPG key. If so, answer y.

After the install completes, execute the following two commands:

sudo chkconfig --levels 235 httpd on sudo /etc/init.d/httpd start

Then in your favorite browser, create a new tab or window and in the URL field type: http://localhost. An apache2 test page should display. If so, apache2 is installed. If not, then make sure you correctly executed all of the commands specified above.

To install PHP5 is even simpler. Execute the following commands:

sudo yum install php sudo yum install php-pgsql

If you want to test that PHP5 is working properly, execute:

cd /var/www/html sudo gedit phpinfo.php &

When the empty edit window appears, enter the following information:



Save the edit and then execute:

sudo /etc/init.d/httpd restart

This command restarts the apache2 server so it is aware that PHP5 is available. Now in a browser create a new tab or window and in the URL field type:

http://localhost/phpinfo.php

A page containing information about the PHP5 installation should appear, followed by information about installed PHP5 extensions.

Installing the Subversion client
In order to install the CZ software, the installer must use the subversion client. CentOS 5.4 doesn't come with subversion, so it must be manually installed. At a terminal prompt execute:

sudo yum install mod_dav_svn subversion

After this installation completes, the LAPP stack and other software for creating a CZ clone is available.

Configuring the LAPP stack
Once the LAPP stack is installed, the installer must configure it.

Configure Postgres
The first thing to do is assign a password to the postgres user of the postgres database. This step may be somewhat confusing to a novice user of postgres, so some explanation is in order. On the operating system that runs postgres is a user named postgres. This user is also listed as a Login Role for the postgres database system. The next step uses a feature of postgres that stipulates if you access the database (through the utility psql) as a particular user, you are automatically logged into postgres as that user. So, the first step is to use sudo to login as root and then change the user identity with the -u parameter. The command executed by sudo will use psql to connect to the postgres database (which, while having the same name, is different than the postgres Login Role). Once psql is connected to the postgres database using the Login Role postgres, it is possible to change the password for (the Login Role) postgres. Execute the following command at a terminal prompt:

sudo -u postgres psql postgres

This should result in a welcome message, followed by some command hints and then followed by the prompt:

postgres=#

At this prompt type:

\password

psql will prompt you for a password and then prompt you to reenter it (remember this password, because you will need it later). If you successfully enter the same password twice, psql returns a new prompt. Type "\q" (without the quotes), which should return you to a Ubuntu command prompt.

The above instructions use the term postgres in three different ways. There is the postgres database system, which is the software that implements postgres. There is the postgres database, which is a collection of tables managed by the postgres database system. Finally, there is the postgres Login Role, which is an identify used by the postgres database system to make access control decisions. It is necessary to keep these distinctions in mind. Later in these configuration instructions, we willl create a cz Login Role and a cz database.

For the novice, using postgres can be a frustrating experience. The main command line utility for interacting with postgres is "psql". Psql has two sets of commands. The first always begin with the character '\' (the backslash, not the slash). The second are SQL commands. Frequently, when using the second category of commands, a new user fails to enter the required semicolon (";") at the end. (The semicolon is not used at the end of the first category of commands). After entering an SQL command, psql returns a prompt and the user thinks the command has been executed. However, it hasn't. A semicolon must be entered (it can be entered after the command on the subsequent prompt). To make things even more confusing, psql uses a "query buffer". This concatenates all input until the requisite semicolon is typed. This also makes things difficult for the novice user, since many times he/she will type multiple commands and then remember to type one with a semicolon. This almost always results in an error. It is good practice to clean out the query buffer using the command "\r" (without the quotes) before entering a new SQL command. It is recommended that those unfamiliar with psql read this good tutorial on its use.

A GUI for accessing postgress databases, pgAdmin III, can help the novice user avoid many of the frustrations experienced when using psql. To install pgAdmin III, use Ubuntu's Add/Remove application facility. This is accessed by clicking at the top left of the desktop on the "Applications" tag (Postgres Figure 1). Select All available applications in the Show drop down menu and type postgres in the Search box (Postgres Figure 2). When the search finishes, scroll down to the bottom and select the pgAdmin III application by checking the box to the left. Then click on Apply Changes. This will install pgAdmin III on your system. (The system may request you to enable community applications. If so, click "Enable"). You will also have to enter your superuser password in a prompt window.

Once installed, pgAdmin III requires configuration. Start pgAdmin III (it should appear in the Applications menu under System Tools. If you have come to these instructions from the CentOS LAPP installation page, pgAdmin III may appear under Programming). The application window appears. In the left window pane is an icon labeled Servers(0). It is necessary to connect to a postgres server in order for the tool to operate. Under the File menu, select Add Server. A New Server Registration window pops up (Postgres Figure 3).

We are going to use the tool to connect to the database server on the local system. So, fill in the Name field with an appropriate name (e.g., Local Host) and fill in the Host field with the value localhost. The Username field is filled in by default to postgres. We will use this identity to access the database system until we have other Login Roles established. So, it is necessary to fill in the password created for the postgres Login Identity previously. Once this is filled in (leave all other selections at their default values), the OK button becomes active. Click it. You may see a hint displayed. If you find these annoying, there is a check box that turns them off. The result of this is a new entry under Servers(1) appears called Local Host (note the number of servers has changed from 0 to 1). Click on the + sign to the left of Local Host and a number of other labels appear.

We will use pgAdmin III to create two new Login Roles. The first is a role corresponding to your user name. This will allow you to use psql from your user account without specifying a username and password. Click on Local Host so it is highlighed and then click on the Edit menu and select New Object. A pop out menu appears to the right. Select New Login Role.... Fill in the form as follows (Postgres Figure 4):


 * Role name - your user name on the system. For example if you login to Ubuntu as jdoe, fill in jdoe into the Role name field.
 * Password - enter a password for your postgres Login Role.
 * '''Password (again) - enter the same password.
 * Role Privileges - click all of the boxes. This gives you all privileges for database administration.

Click on OK.

To check that you successfully created a Login Role with the same username as your Ubunutu name, type the following command at a terminal window prompt (don't close pgAdmin III. We will use it again below):

psql postgres

This should result in the postgres welcome message, command hints and then the prompt: postgres=>. Type \q to exit psql (if you wish, you can stay in psql rather than quitting, since we will return to it after some more work in pgAdmin III).

Going back to pgAdmin III, we will create another Login Role as well as a new database. To create the Login Role follow the steps given above, except use the Role Name cz and leave the password fields blank. While it is unnecessary to give the cz Login Role all privileges, this clone of CZ will be used by only you and it is therefore convenient to do so. If you were creating an installation of CZ that would be accessed by others, you would spend much more time configuring it so it is secure. How to configure a CZ installation so it is secure in a multi-user environment is outside the scope of these instructions.

We nave to modify the cz role and using psql is the easiest way to do so. In a terminal window at a prompt type:

psql postgres

This should result in the postgres welcome message, command hints and then the prompt: postgres=#. Now enter the following information at the postgres prompt. (note: you can simply copy and past the information below into the terminal window).

ALTER ROLE cz SET "TimeZone" TO 'GMT'; ALTER ROLE cz SET search_path TO mediawiki, public; ALTER ROLE cz SET "DateStyle" TO ISO, YMD; ALTER ROLE cz SET client_min_messages TO 'error';

If you enter this information one line at a time, you will have to type a return each time (don't forget the semicolon after each line). If you copy and paste the information, you will need to type a return after the last line. As each line is executed, psql will return ALTER ROLE. To check that these commands executed correctly, use pgAdmin III to navigate to the cz Login Role (i.e, expand the + sign next to Login Roles). Double click on cz. A pop-up window should appear with the information for cz. Select the Variables tab and the variable values set by psql should display (Postgres Figure 5). You may need to refresh the information displayed by pgAdmin III by selecting Refresh from the View menu. You can exit psql by typing "\q".

Now that a cz Login Role is established with the correct initialization information, it is possible to create a cz database. In the main pgAdmin III window click on Databases so it is highlighted and either right click on it and select New Database or from the Edit Menu select New Database (in some versions of pgAdmin III New Database is a selection in the New Object submenu). Fill in the Name field with cz. Select cz using the right hand down-arrow of the Owner field (Postgres Figure 6). Click OK. The Databases field should change from Databases(1) to Databases(2). Click on the + sign to the left of the Databases field and two databases should be displayed: 1) postgres, and 2) cz (Postgres Figure 7).

There is one last bit of configuration necessary to set up postgres as the wiki's backend database server. (Note: If you came to this point via the CentOS 5.4 thread, skip to the next section. You have already configured pg_hba.conf.) We have to modify the postgres authentication configuration data so it trusts commands executed from the local server. In a terminal window execute:

sudo su - postgres cd /etc/postgresql/8.3/main gedit pg_hba.conf &

Note: if you get the message:

cannot open display:

you need to set the DISPLAY environmental variable for the postgres user. Execute:

DISPLAY=:0.0 export DISPLAY

You should then be able to succesfully execute the gedit command.

An edit window should appear. Scroll to the end of the file and find the entry with the comment "local" is for Unix domain socket connections only. The next entries control access when connections to the postgres server come from the local host. Copy the text below and replace the corresponding text. The entry should now look like the following:

local  all         all 				trust host   all         all         127.0.0.1/32          trust
 * 1) "local" is for Unix domain socket connections only
 * 2) local  all         all                               ident sameuser
 * 1) IPv4 local connections:
 * 2) host   all         all         127.0.0.1/32          md5

Save the file and exit the editor. Now restart the postgres server with the following commands:

exit sudo /etc/init.d/postgresql-8.3 restart

This completes the configuration of postgres. We will return to postgres when we cover how to import the CZ dump data into the installation.

Configure Apache2
Configuring the apache2 web server requires less sophisticated tools than those used to configure postgres. Basically, a text editor is all that is required. These instructions use gedit, which is a nice GUI editor that comes pre-configued on Ubunutu. However, the directories used in an Ubuntu installation are slightly different than those used in a CentOS 5.4 installation. The instructions covers both cases, providing the Centos 5.4 instructions second.

Configuration of the original apache server required editing one large file (httpd.conf). Fortunately, the apache2 server software has separated the configuration information into several files, which makes configuration much easier. On Ubuntu, the main configuration file is located in /etc/apache2. It is named apache2.conf. There is no need to edit this file when setting up a CZ clone. In fact, no configuration of the apache2 server is necessary to enable the LAPP stack. To test that the apache2 server and PHP are correctly installed, in a terminal window execute (Note: if you have followed the instructions for installing LAPP on CentOS 5.4, it isn't necessary to execute these commands. The file they create already exists. Otherwise, CentOS 5.4 installers should cd to /var/www/html, rather than /var/www):

cd /var/www sudo gedit phpinfo.php

This will pop an edit window. Enter the following text into the file:



Then save the file and exit the editor. Now restart the apache2 server to ensure it has read the installed configuration files:

sudo apache2ctl restart

On CentOS 5.4 restart apache2 using:

sudo /etc/init.d/httpd restart

In a web browser, create a new tab or a new window. In the url field at the top enter:

http://localhost/phpinfo.php

If the apache2 server and PHP are correctly installed, a page of information about PHP should display. At the top will be the PHP Version and in the subsequent graphical boxes will be information about PHP and the PHP extensions installed. It is useful to keep the phpinfo.php file in this location because occasionally it is helpful to test the apache2/PHP installation to ensure it retains integrity.

Some additional configuration of the apache2 server is necessary to utilize the CZ software that implements the wiki. There are two ways to configure the apache2 server for the CZ clone. One way is to assume there is only one copy of the CZ software on the machine. This is normally true for those who are cloning CZ for personal use. The other way is to assume multiple copies of the CZ software exist on the machine. This is normally the case if the CZ clone is used for software development. While setting up the machine for multiple copies of the CZ software is unnecessary for a local use clone, it really doesn't introduce any overhead to do so. Consequently, these instructions describe how to set up the apache2 server to access more than one copy of the CZ software.

The CZ software will be stored in subdirectories of /usr/local/src. The first step is to cd to that directory and create a subdirectory called mediawiki. Change the permissions on mediawiki to 777 (i.e., in /usr/local/src execute sudo chmod 777 mediawiki). In a production environment, the adminstrator would use more careful access control permissions. However, since this CZ clone is intended for local use, making the software world r/w is an acceptable configuration strategy. Change directories to mediawiki and create a CZ_1_13_2 subdirectory. Also make this directory world r/w. The commands are:

cd /usr/local/src sudo mkdir mediawiki sudo chmod 777 mediawiki cd mediawiki sudo mkdir CZ_1_13_2 sudo chmod 777 CZ_1_13_2

If the CZ clone is used for development purposes, the developer would create additional subdirectories of the /usr/local/src/mediawiki directory to hold different versions of the CZ software. In fact, it is possible to host copies of the non-modified mediawiki software by downloading them into subdirectories of mediawiki. For example, if it is desirable to download a copy of the mediawiki software on which CZ is based, the developer could create a subdirectory of mediawiki, say MW_1_13_2, and use it to hold the non-modified version.

Once this directory structure is created, it is possible to make the changes to the apache2 configuration information necessary to support the CZ software. In a terminal window exectute:

cd /etc/apache2/sites-enabled sudo gedit 000-default

(Note: If you have come to these instructions from the installing a LAPP stack on CentOS 5.4 page, you must edit the file /etc/httpd/conf/httpd.conf, rather than /etc/apache2/sites-enabled/000-default, and add the indicated information to its end. When viewing the result, no  statement will display).

This will open an edit window displaying the contents of the sites-enabled file. At the end of this file right before the  delimiter, enter the following information:

Alias /mediawiki/ "/usr/local/src/mediawiki/"  Options FollowSymLinks AllowOverride None 

Alias /CZ_1_13_2 "/usr/local/src/mediawiki/CZ_1_13_2/phase3/index.php"

After doing so the end of the file should contain the following text:

Alias /mediawiki/ "/usr/local/src/mediawiki/"  Options FollowSymLinks AllowOverride None 

Alias /CZ_1_13_2 "/usr/local/src/mediawiki/CZ_1_13_2/phase3/index.php"



Save the file, close the editor and restart the apache2 server by executing:

sudo apache2ctl restart

On CentOS 5.4 restart apache2 using:

sudo /etc/init.d/httpd restart

We can't test whether the apache2 server properly executes the CZ software because that software isn't installed yet. However, we can test the configuration changes we just made. In a terminal window type:

sudo su cd /usr/local/src/mediawiki/CZ_1_13_2 mkdir phase3 chmod 777 phase3 cd phase3 cp /var/www/phpinfo.php. mv phpinfo.php index.php chmod 777 index.php exit

On CentOS 5.4 first su to root and then use:

cd /usr/local/src/mediawiki/CZ_1_13_2 mkdir phase3 chmod 777 phase3 cd phase3 cp /var/www/html/phpinfo.php. mv phpinfo.php index.php chmod 777 index.php exit

The first command moves the terminal session to the root identity. We do this because there are a lot of commands that require root access and typing sudo before each is inefficient. The last command exit takes the session back to your Ubunutu identity.

These commands make a copy of the phpinfo.php file in /usr/local/src/mediawiki/CZ_1_13_2/phase3 and rename it index.php. When we install the CZ software we will have to remove this file before loading it, since there is already an index.php file in the CZ software distribution.

Now we are prepared to test the new apache2 server configuration. Open a browser and either open a new tab or a new browser window. In the URL field enter:

http://localhost/mediawiki/CZ_1_13_2/phase3/index.php

The same PHP configuration information should appear as before. Now enter in the URL field:

http://localhost/CZ_1_13_2

Again the PHP configuration information should appear. If either of these tests fail, recheck the edits and the directory structure created above. In the latter case, the directories /usr/local/src/mediawiki, /usr/local/src/mediawiki/CZ_1_13_2 and /usr/local/src/mediawiki/CZ_1_13_2/phase3 should exist with 777 permissions.

Download the CZ wiki software
Installing the CZ wiki software requires access to the main CZ repository. In this repository is stored various versions of the software including the currently deployed version and others undergoing development. The version control system used to manage these versions is Subversion. We must install the Subversion software in order to access the repository.

Create a terminal window and enter the following command (Note: those following the CentOS 5.4 path have already installed subversion, so they should skip this step):

sudo apt-get install subversion

Once the installation completes, we can download the current CZ software release. But, first we have to clean up some detritus left from testing the apache2 configuration. Execute the following commands in a terminal window:

sudo su cd /usr/local/src/mediawiki/CZ_1_13_2 rm -fr phase3 exit

This removes the phase3 directory and everything in it. Now we have to find out which release version we will checkout. Execute:

svn list http://m-aurelius.citizendium.org/czrepo/tags

The result is a list of releases for the CZ software. These instructions assume the latest version is called CZ_1_13_2_1.

The next step is to checkout this version. For those new to version control, a checkout from a repository makes a local copy of whatever branch is specified. This local copy retains information about where it comes from in the repository, but the repository itself keeps no state about the local copy. Consequently, you can do anything you want with the local copy, even delete it. The repository is unaware of these changes until you attempt to check in the local copy.

To checkout CZ_1_13_2_1 into the directory CZ_1_13_2 (which is where will configure the apache2 server to find it), execute:

cd /usr/local/src/mediawiki svn checkout http://m-aurelius.citizendium.org/czrepo/tags/CZ_1_13_2_1 CZ_1_13_2

The result of this command is a very large number of lines starting with the letter A (which stands for Add). After the command completes, there is a copy of the latest CZ released software in /usr/src/local/mediawiki/CZ_1_13_2.

Setting up the CZ database
The next step is to create the database schema. In an unmodified version of the mediawiki software the schema is created using a utility called update.php. However, CZ runs a modified version of the mediawiki software and so this utility doesn't correctly setup the database. So, we must use psql to import the schema.

The directory /usr/src/local/mediawiki/CZ_1_13_2 has two subdirectories: 1) database, and 2) phase3. The latter contains the PHP modules that implement the wiki. The former contains information specific to the wiki database. In particular, it contains a dump of the CZ database schema. We will use psql to import this into the cz database.

In a terminal window execute:

cd /usr/local/src/mediawiki/CZ_1_13_2/database psql -d cz -U cz -f schema_1_13_2.pg

If an error occurs with the following text:

FATAL: Ident authentication failed for user cz

then you haven't correctly changed the file pg_hba.conf. Go back and ensure that both local and host entries are specified as trust.

Before configuring the CZ wiki software, we will make one modification to the CZ database. It isn't clear why this change is necessary, but if it isn't executed, the database import will not work. Furthermore, this action creates a dummy user with a user id of 0. A real user cannot have this user id, since the software will not allow such a user to login.

Start pgAdmin III. Double click the localhost icon and if they are not already expanded, click on the + button to the left of the cz icon and then on the + button to the left of the Schemas icon and then on the + button to the left of the mediawiki icon. Under mediawiki click on the + button to the left of the Tables icon. Scroll down to the mwuser entry. Single click mwuser and then click on the icon that looks like a table at the top of the window shown in Postgres Figure 8.

In the first row under user_id, enter the integer 0. In the next column, user_name, enter the text "dummy" (without the quotes). Select File in the upper left-hand corner and then select save. The result should look like Postgres Figure 9. These actions create a dummy user that cannot be used to login to the wiki, since it has no password associated with it.

In order to adjust the wiki state for the dummy user, we must now make a change to a database sequence variable. This category of database information provides consequtive values that aid in labeling other database data. Click the - to the left of Tables and then click the + to the left of Sequences. Scroll down to user_user_id_seq and double click it. Change current value from 0 to 1 and click OK. Close pgAdmin III.

Configuring the CZ wiki software
Most configuration of the CZ wiki software occurs through edits to the file LocalSettings.php. In a non-modified version of the Mediawiki (MW) software, after an initial software install using Subversion, the installer access the wiki through a web browser and a special PHP routine guides him/her through the steps necessary to achieve an intial configuration. However, since the CZ wiki uses a different database schema than MW, the CZ software distribution comes with a copy of LocalSettings.php that is already properly configured. It is only necessary to get a copy of LocalSettings.php into the phase3 directory of the CZ software distribution. In a terminal window execute:

cd /usr/local/src/mediawiki/CZ_1_13_2/phase3 cp config/LocalSettings.php.

Now, open a browser window and in the URL field type:

http://localhost/CZ_1_13_2

The wiki main page should appear. If so, congratulations! You have successfully installed the CZ wiki software. If you wish, you can bookmark this URL and save it under a more informative title, such as "CZ clone" or "Local CZ clone". If the main page did not appear, go back and review the instructions in this section to ensure you executed them correctly.

Establishing the first user
User registration in a CZ wiki requires an administrator to approve them. This is to ensure they are using the real names and they provide a short description of themselves that goes on their user page. However, when the software is first installed, no users exist (ignoring the dummy user, which has no login capability). So, the first user is established using a one-off procedure. This involves using a utility in the maintenance directory of the wiki software. This utility installs a user with specified privileges.

In a terminal window execute:

cd /usr/local/src/mediawiki/CZ_1_13_2/phase3/maintenance php createAndPromote.php --bureaucrat Wikiadmin Wikiadminpw

For "Wikiadminpw" you can substitute any password you wish. If the createAndPromote call exits with the error:

cz: Creating and promoting User:Wikiadmin...PHP Warning: pg_query: Query failed: ERROR:  duplicate key value violates unique constraint "mwuser_pkey" in /usr/local/src/mediawiki/CZ_1_13_2/phase3/includes/db/DatabasePostgres.php on line 552

you forgot to change the current value of user_user_id_seq to 1. If you execute the call again it should work.

Post wiki software installation and configuration
While all of the software necessary to create a CZ clone is described in the previous sections, there is other software installation and configuration required to support optional, but commonly provided features. Specifically, we must install and configure the texvc software in order for mathematical equations to display and we also must configure the email feature of the mediawiki software.

Configuring local email
In order to logon to your CZ clone, your account must have a valid email address configured. The way the CZ software judges that this condition obtains is to send you a confirmation email when you first register. This applies to all users, including the Wikiadmin user created using createAndPromote.php. So, in order to continue, we must first configure email. Normally, email is configured by a system admin to allow users to send and receive messages from other users on the internet. If your system already is configured to do this, nothing else is required. Skip the next sub-section and proceed to Setting up your email address. Otherwise, you must complete the steps in the next section.

Setting up local host email
Setting up local email on a system is not hard. Since there is a good set of instructions that describe how to do this elsewhere, they are not duplicated here. The installer should proceed to How to set up email in CentOS 5. There is one thing to note, however. Since we are setting up local email, there is no need to remove the comments from the two lines:


 * 1) inet_interfaces = all
 * 2) mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

The configuration file is already set up for local email. The only change required is to uncomment the line:


 * 1) home_mailbox = Maildir/

so it reads:

home_mailbox = .Maildir/

Don't forget to put a period before Maildir/ (i.e., it should be .Maildir/ not Maildir/). This means the mail directory will not appear in a vanilla ls listing.

Setting up the email client
Once local email is enabled, we must set up an email agent to read the local email spool file. (If you already can send and receive email on your system, skip this section and proceed to Installing and configuring texvx.

From the Applications menu at the top left corner of the Desktop, select Internet and then Email. This displays the Evolution email client configuration window.

From the Welcome page click Forward and Forward again. The Identity page should display. In the window type @localhost. For example, if your username on the system is jdoe, then enter jdoe@localhost. Click the Forward button. The next window should be labeled Receiving Email. From the pop-down menu labeled Server Type select Maildir-format mail directories (this assumes you followed the instructions in the previous section and selected Maildir formated email). From the Configuration pop-down menu select Other... and when the Mailbox location window appears, type ~/.Maildir in the Location: field. Click Forward. In the next (Receiving Options) window, select how often you want Evolution to check for email. Then click Forward. In the Sending Email window choose Sendmail from the pop-down menu. Then click Forward. In the Account Management window select the name that you want to appear for this account in Evolution. Then click Forward. In the Timezone window select your time zone. Then click Forward and Apply.

Evolution should launch and in the left-hand column will be the name you chose in the Account Management window. You should be able to send and receive email from this account.

Configuring the CZ clone with your email address
If you have used the CZ wiki at Citizendium, you should already know how to configure your email address. However, for completeness this section describes that task.

Access your local CZ clone wiki using a browser and login. At this point there is only one user - Wikiadmin, so login with this identity. When login completes, click on the Preferences tab at the top of the browser window. When your preferences window displays, enter your email address in the User profile field and click Save. A message informing you that a confirmation email has been sent appears. If Evolution is not running, start it (if it is running, click Send/Receive at the top left-hand corner). A confirmation email should appear in your account inbox. Follow its instructions. This will confirm your email address.

Installing the required software
TeX support on the mediawiki software (on which the CZ software is based) requires the installation and configuration of several software packages. While for some this may go smoothly, others have had significant problems getting math equations to appear properly on wiki pages. Since this functionality is pretty basic to much of the content on CZ, there really is no option but to support it. However, be prepared for some frustration in getting this to work properly.

The software we need is not available on the software repositories that ship with CentOS 5.4. So, we need to add one. Note: third party yum software repositories can be hazardous to use. The original author of this article once added several third party repositories of questionable quality and after updating the system software, yum stopped working (yum is a python script and the update corrupted the python subsystem). So, you should be very careful when adding repositories to your yum configuration information.

In this case, we will add RPMForge. This third party repository has a good reputation and so should not be dangerous to use. However, there are no guarantees and since those installing a CZ clone on CentOS 5.4 should be experienced CentOS installers, they are expected to have the skills to get out of problems caused when a third party repository corrupts their system.

The first thing to do is to install yum priorities. In a terminal window execute:

sudo yum install yum-priorities

As always, when prompted whether you wish to continue, answer y.

Make sure priorities are enabled (they are in a fresh CentOS 5.4 install) by executing:

cat /etc/yum/pluginconf.d/priorities.conf

This should produce the following output:

[main] enabled = 1

If enabled is not set to 1, edit the file and change it so it is.

Now, cd to /etc/yum.repos.d and edit each file by setting the priority for each repository listed. The recommended settings (given by the CentOS wiki at http://wiki.centos.org/AdditionalResources/Repositories/RPMForge) are:

[base], [addons], [updates], [extras] ... priority=1 [centosplus],[contrib] ... priority=2 Third Party Repos such as rpmforge ... priority=N (where N is > 10 and based on your preference)

For example, execute the following in a terminial window:

cd /etc/yum.repos.d sudo gedit CentOS-Base.repo

When the edit window opens, you will see sections labeled by the section identifiers given above. For example:

[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 * 1) baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

[updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
 * 1) released updates
 * 1) baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/

After the gpgkey line add priority=1. These two sections should now look like:

[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 priority=1
 * 1) baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

[updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 priority=1
 * 1) released updates
 * 1) baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/

Make sure you set the priorities correctly for all of the sections.

For the [centosplus],[contrib] sections, ensure the variable enabled is set to 1. That is:

enabled=1

Set the priority variable on sections in all other .repo files in the directory.

Now determine what is the machine architecture:

uname -i

This should return either i386 or x86_64. Depending on this value in a terminal window execute:

cd /tmp

i386: sudo wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

x86_64: sudo wget http://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

rpm packages are signed, so in order to use them we have to download the key for RPMForge. In a terminal window execute:

sudo rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

Then verify the package:

sudo rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm

Now install the repository into the systems repository list:

sudo rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm

Check that the installation completed properly:

yum check-update

RPMForge should appear in the list of repositories and there should be activity showing the information associated with it is updated.

Now that RPMForge is added to the repository list, we must set its priority correctly. In a terminal window execute:

cd /etc/yum.repos.d sudo gedit rpmforge.repo

At the end of the [rpmforge] section add:

priority=11

Save the file and exit the editor.

Texvc depends on other software on the system. Particularly, ImageMagick, Ghostscript, latex and dvips must be installed. These utilities are installed by default in CentOS 5.4. To ensure this, execute:

whereis ImageMagick whereis ghostscript

(make sure to capitalize the I and M in ImageMagick). This should result in the following output:

ImageMagick: /usr/share/man/man1/ImageMagick.1.gz

ghostscript: /usr/bin/ghostscript /etc/ghostscript /usr/lib/ghostscript /usr/share/ghostscript /usr/share/man/man1/ghostscript.1.gz

or something similar.

If one or the other of these utilities is missing, you will have to install them with yum, i.e.,

sudo yum install ImageMagick

and/or

sudo yum install ghostscript

Normally latex and dvips are not installed on a standard CentOS 5.4 system. This is easily checked with the following commands:

whereis latex whereis dvips

Generally either both will be available or neither. To install both, in a terminal window execute:

sudo yum install tetex tetex-fonts tetex-dvips tetex-latex

After ensuring the availablity of ImageMagick, Ghostscript, latex and dvips we must install ocaml. In a terminal window execute:

sudo yum install ocaml

Ocaml requires the availability of the gcc compiler. Check whether it exists by executing in a terminal window:

gcc

If this returns:

gcc: no input files

gcc is installed. Otherwise, execute:

sudo yum install gcc gcc-c++ autoconf automake

and answer y at the appropriate time.

We are finally in a position to build texvc. In a terminal window execute:

cd /usr/local/src/mediawiki/CZ_1_13_2/phase3/math make

Configuring texvc
Configuring texvc is simple, but non-intuitive. The reason is texvc is written in Ocaml and it calls various utility functions. In order for these to work correctly, certain environmental variables, permissions and directories must be properly set-up. This is the first step in getting texvc to work. In a terminal window execute:

cd /usr/local/src/mediawiki/CZ_1_13_2/phase3 chmod -R 777 images

These command set the permissions on the images directory and all its subdirectories to world read-write-execute. For a production wiki installation this is probably not recommended, but since this is your personal wiki, it shouldn't be a problem.

Next, edit LocalSettings.php and change $wgTexvc to equal $IP/math/texvc. That is:

$wgTexvc ="$IP/math/texvc";

We now have to set up some directories. Execute:

cd /var/www sudo mkdir .texmf-var sudo chgrp apache .texmf-var sudo chmod 775 .texmf-var cd .texmf-var sudo mkdir web2c sudo chgrp apache web2c sudo chmod 775 web2c

Finally, there is a slight mismatch between CentOS 5.4 and texvc that we must accommodate. Specifically, the apache2 web server is launched by root at system boot. Consequently, it inherits root's HOME environmental variable. Regrettably, latex (called by texvc) uses HOME when looking for some format information. To correctly direct latex to the proper directory, we must modify the HOME environmental variable that is passed to apache when it starts. Fortunately, there is a simple way to do this. In a terminal window, execute:

cd /etc/sysconfig sudo gedit httpd

An edit window appears. At the end of the file add the following line (don't put spaces between the characters):

HOME=/var/www

Save the file and close the edit window. We now have to restart the apache2 server. Execute:

sudo /etc/init.d/httpd restart

The server should stop and then start. To test texvc, open a browser window in your CZ clone and create a page to edit (e.g., create a sandbox subpage for the Wikiadmin user). Edit the page and enter:

$$\alpha^2+\beta^2=1$$

Click Show preview. The result should be:

$$\alpha^2+\beta^2=1$$

If the equation above appears, then texvc is working properly. However, you may get one of several errors:

Failed to parse (Cannot write to or create math temp directory):

This occurs because the math/ and tmp/ directories in phase3/images are not accessible to the apache2 server. Check to ensure you have executed the first set of commands correctly.

Another common error is:

Failed to parse (Missing texvc executable; please see math/README to configure.):

If so, make sure you have correctly modified LocalSettings.php and have saved the results.

A pernicious error is:

Failed to parse (PNG conversion failed; check for correct installation of latex, dvips, gs, and convert)

This means the CZ wiki software is having trouble calling all of the installed software necessary to render the markup. Make sure you have executed the third and fourth set of commands properly.

The four command sets given above properly configure a fresh CentOS 5.4 install so texcv works. If you are installing texvc on a system that is not a fresh install, you may have to work through other configuration problems. A good source of advice for doing that is found on the Mediawiki site. Good luck!