MediaWiki:Welcome to the Howto page/FreeBSD/Xwiki

From wiki
< MediaWiki:Welcome to the Howto page‎ | FreeBSD
Revision as of 19:16, 29 December 2013 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction


Creating the Jail


The first thing we need to do in order to get Xwiki up and running is create the jail that the software will reside in. First of all I'm going to position this jail in my ZFS pool and call it wiki and then I will start on the jail creation itself:

Test-BSD# mkdir /zfs/jail/wiki
Test-BSD# setenv D /zfs/jail/wiki
Test-BSD# mkdir -p $D
Test-BSD# make installworld DESTDIR=$D
Test-BSD# make distribution DESTDIR=$D
Test-BSD# mount -t devfs devfs $D/dev


Once the jail has been created we can now add it to the /etc/rc.conf file:

ifconfig_de0_alias1="inet 192.168.0.151 netmask 255.255.255.0"
jail_list="dns wiki"
jail_wiki_rootdir="/zfs/jail/wiki"
jail_wiki_hostname="wiki.nova-tech.com"
jail_wiki_interface="de0"
jail_wiki_ip="192.168.0.151"
jail_wiki_devfs_enable="YES"


and then start the newly built and configured jail:

Test-BSD# /etc/rc.d/jail start wiki
Configuring jails:.
Starting jails: wiki.nova-tech.com.


From there we can test to see if it has been successfully activated:

Test-BSD# jls
   JID  IP Address      Hostname                      Path
     1  192.168.0.149   ns1.nova-tech.com             /zfs/jail/dns
     2  192.168.0.151   wiki.nova-tech.com            /zfs/jail/wiki


and now mount the ports collection inside it:

Test-BSD# sh
# D=/zfs/jail/wiki
# mkdir -p $D/usr/ports
# mount_nullfs /usr/ports $D/usr/ports
# mount | sort
/dev/ad0s1a on / (ufs, local)
/usr/ports on /zfs/jail/wiki/usr/ports (nullfs, local)
ZPOOL_1 on /zfs (zfs, local)
devfs on /dev (devfs, local, multilabel)
devfs on /zfs/jail/dns/dev (devfs, local, multilabel)
devfs on /zfs/jail/wiki/dev (devfs, local, multilabel)


From here we can login to the jail and build the applications we need starting with the Nano text editor:

Test-BSD# jexec 2 tcsh
wiki# cd /usr/ports/*/nano
wiki# make install clean


The next task is to setup the /etc/rc.conf, /etc/hosts, and /etc/resolv.conf files while taking some prerequisites into consideration:

wiki#cat /etc/rc.conf
defaultrouter="192.168.0.254"
hostname="wiki.nova-tech.com"
tomcat60_enable="YES"
postgresql_enable="YES"
postgresql_user="root"
jail_sysvipc_allow="YES"


wiki#cat /etc/hosts
# $FreeBSD: src/etc/hosts,v 1.16.34.1.2.1 2009/10/25 01:10:29 kensmith Exp $
#
# Host Database
#
# This file should contain the addresses and aliases for local hosts that
# share this file.  Replace 'my.domain' below with the domainname of your
# machine.
#
# In the presence of the domain name service or NIS, this file may
# not be consulted at all; see /etc/nsswitch.conf for the resolution order.
#
#
::1			localhost localhost.my.domain
127.0.0.1		localhost localhost.my.domain
#
# Imaginary network.
#10.0.0.2		myname.my.domain myname
#10.0.0.3		myfriend.my.domain myfriend
#
# According to RFC 1918, you can use the following IP networks for
# private nets which will never be connected to the Internet:
#
#	10.0.0.0	-   10.255.255.255
#	172.16.0.0	-   172.31.255.255
#	192.168.0.0	-   192.168.255.255
#
# In case you want to be able to connect to the Internet, you need
# real official assigned numbers.  Do not try to invent your own network
# numbers but instead get one from your network provider (if any) or
# from your regional registry (ARIN, APNIC, LACNIC, RIPE NCC, or AfriNIC.)
#

192.168.0.151		wiki.nova-tech.com	wiki
192.168.0.151		wiki.nova-tech.com.


wiki# cat /etc/resolv.conf
nameserver 192.168.0.149


Now that the jails internals has been setup it is time to start adding the software needed to run Xwiki.


Apache Tomcat Installation


The installation of Tomcat will be version 6 built from the ports repository.

wiki# cd */tomcat6
wiki# make install clean


If all went to plan there should be an error message at the tail end of the install:

 Please open http://java.sun.com/javase/downloads/index.jsp
 in a web browser and follow the "Download" link for
 "JDK US DST Timezone Update Tool - 1_3_18" to obtain the
 time zone update file, tzupdater-1_3_18-2009k.zip.

 Please download the patchset, bsd-jdk16-patches-4.tar.bz2, from
 http://www.eyesbeyond.com/freebsddom/java/jdk16.html.

 Please place the downloaded file(s) in /usr/ports/distfiles 
 and restart the build.

*** Error code 1

Stop in /usr/ports/java/jdk16.
*** Error code 1

Stop in /usr/ports/java/jdk16.
*** Error code 1

Stop in /usr/ports/www/tomcat6.


This basically tells us that we need to install the JDK US DST Timezone Update Tool and also the JDK16 environment in order to proceed. Since both these packages have license agreements they cannot be downloaded directly using a utility such as wget so one has to actually open up a browser interface in order to navigate to the links, accept the license agreements and download the packages.


Timezone.png


For the JDK US DST Timezone Update Tool go here and for the JDK16 go here although depending on how new the port is, it may complain and ask for a different set of downloads.


Once downloaded, upload the files to the server using ftp, sftp, scp, rsync, or another method then move the files into the ports directory:

scp tzupdater-1_3_31-2010i.zip mark@192.168.0.150:/usr/home/mark/
scp diablo-jdk-freebsd7.i386.1.6.0.07.02.tbz mark@192.168.0.150:/usr/home/mark/
ssh mark@192.168.0.150
$ su -
Test-BSD# cd /usr/home/mark
Test-BSD# mv diablo-jdk-freebsd7.i386.1.6.0.07.02.tbz /usr/ports/distfiles/
Test-BSD# mv tzupdater-1_3_31-2010i.zip /usr/ports/distfiles/


From there we need to login to the jail again and build the JDK port:

wiki# cd /usr/ports/java/diablo-jdk16/
wiki# make install clean


Again the system may blow up and come up with an error meaning that the directions on screen need to be followed:

Because of licensing restrictions, you must fetch the distribution
 manually.

 Please access

     http://www.FreeBSDFoundation.org/cgi-bin/download?download=diablo-caffe-freebsd7-amd64-1.6.0_07-b02.tar.bz2

 with a web browser and "Accept" the End User License Agreement for
 "Caffe Diablo 1.6.0".

 Please open http://java.sun.com/javase/downloads/index.jsp
 in a web browser and follow the "Download" link for
 "JDK US DST Timezone Update Tool - 1_3_18" to obtain the
 time zone update file, tzupdater-1_3_18-2009k.zip.

 Please place the downloaded file(s) in /usr/ports/distfiles.

*** Error code 1

Stop in /usr/ports/java/diablo-jdk16.
*** Error code 1

Stop in /usr/ports/java/diablo-jdk16.


Once downloaded again scp or other method can be used to upload the package to the server:

scp diablo-caffe-freebsd7-amd64-1.6.0_07-b02.tar.bz2 mark@192.168.0.150:/usr/home/mark/
ssh mark@192.168.0.150
$ su -
Test-BSD# cd /usr/home/mark
Test-BSD# mv diablo-caffe-freebsd7-amd64-1.6.0_07-b02.tar.bz2 /usr/ports/distfiles/

wiki# cd /usr/ports/java/diablo-jdk16/
wiki# make install clean


If the system starts complaining about the JDK US DST Timezone Update Tool it means that either the older version needs to be found or alternatively a port upgrade must be performed. Of course an easier way would be to just turn it off altogether however we will proceed as per the dialogs.


Since an older version of the JDK US DST Timezone Update Tool isn't available and the port upgrade didn't manage to solve the problem either, even after having a production build with the same packages the best way to proceed at this point was to disable the tool.

# cd /usr/ports/java/jdk16
# make config


Then unselect the tzupdate and press OK. After another attempt at building the JDK environment the system again complains with this error:

wiki# make install clean
===>  Vulnerability check disabled, database not found
===>  Found saved configuration for jdk-1.6.0.3p4_12

IMPORTANT: To build the JDK 1.6.0 port, you should have at least
2.5Gb of free disk space in the build area!


 Due to licensing restrictions, certain files must be fetched manually.

 Please download the Update 3 Source from
 http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar
 and the Source Binaries from
 http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar
 and the Mozilla Headers from
 http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar
 .

 Please download the patchset, bsd-jdk16-patches-4.tar.bz2, from
 http://www.eyesbeyond.com/freebsddom/java/jdk16.html.

 Please place the downloaded file(s) in /usr/ports/distfiles 
 and restart the build.

*** Error code 1

Stop in /usr/ports/java/jdk16.
*** Error code 1

Stop in /usr/ports/java/jdk16.


Meaning that we need to fetch each and every one of those components and drop them into the /usr/ports/distfiles directory. A trick however is to use the wget tool in the directory itself meaning that no other work needs to be done:

wget  http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar

wget  http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar

wget  http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar


Once all that is done and finished we can run the make install clean command again from within the JDK port. If there are any more errors that pop-up just follow the on-screen instructions in order to overcome them. The majority of the errors will be to build Java components without the tzupdate enabled.


And finally install Tomcat6 into the system:

wiki# cd /usr/ports/*/tomcat6
wiki# make install clean


Postgresql


The next stage in getting the Xwiki system up and running is to install the Postgresql database backend. Many different types of databases are compatible with Xwiki however for FreeBSD the Postgresql is the only database that has been functional and able to be tested.


So now let's start by installing both server and client components; the version that is going to be installed is: 8.2.17_1. This is a simple procedure that will be done from the ports collection.

wiki# cd /usr/ports/databases/postgresql82-client
wiki# make install clean
wiki# cd ../postgresql82-server
wiki# make install clean


Now it's a good idea to restart the jail:


Test-BSD# /etc/rc.d/jail restart wiki


and login again:

Test-BSD# jls
   JID  IP Address      Hostname                      Path
     1  192.168.0.149   ns1.nova-tech.com             /zfs/jail/dns
     4  192.168.0.151   wiki.nova-tech.com            /zfs/jail/wiki
Test-BSD# jexec 4 tcsh


From here create the database cluster:

wiki# su pgsql
$ /usr/local/bin/initdb /usr/local/pgsql/data
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale C.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers/max_fsm_pages ... 400kB/20000
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... FATAL:  could not create shared memory segment: Function not implemented
DETAIL:  Failed system call was shmget(key=1, size=1818624, 03600).
child process exited with exit code 1
initdb: removing data directory "/usr/local/pgsql/data"


As can be seen there is an error which is specifically caused by running Postgresql in a jail environment. This can be overcome by adding: jail_sysvipc_allow="YES" to the /etc/rc.conf file in the base install:

wiki# su pgsql
$ /usr/local/bin/initdb /usr/local/pgsql/data
The files belonging to this database system will be owned by user "pgsql".
This user must also own the server process.

The database cluster will be initialized with locale C.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 40
selecting default shared_buffers/max_fsm_pages ... 28MB/179200
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    /usr/local/bin/postgres -D /usr/local/pgsql/data
or
    /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start


Now let's start the Postgresql service:

wiki# su - pgsql
$ /usr/local/bin/postgres -D /usr/local/pgsql/data


The process can be further tested using the: ps -aux | grep postgres command. Now that the service is up and running we can go on to creating the Xwiki user and database:

$ createuser xwiki -S -D -R -P -Upgsql
Enter password for new role: 
Enter it again: 
CREATE ROLE

$ createdb xwiki -Eunicode -Oxwiki -Upgsql 
CREATE DATABASE


From here the final stage in Postgresql configuration is to add a line trusting the interface in the /usr/local/pgsql/data/pg_hba.conf file so that the bottom of the file looks like this:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust

host    all         all         192.168.0.151/32      trust


All that is needed to be done now is the Postgresql service restarted and for security the database can even be listed to ensure it's creation:

wiki#/usr/local/etc/rc.d/postgresql restart


$ su -
Password:
Test-BSD# jls
   JID  IP Address      Hostname                      Path
     1  192.168.0.149   ns1.nova-tech.com             /zfs/jail/dns
     2  192.168.0.151   wiki.nova-tech.com            /zfs/jail/wiki
Test-BSD# jexec 2 tcsh
You have mail.
wiki# su - pgsql
$ psql -l
       List of databases
   Name    | Owner | Encoding  
-----------+-------+-----------
 postgres  | pgsql | SQL_ASCII
 template0 | pgsql | SQL_ASCII
 template1 | pgsql | SQL_ASCII
 xwiki     | xwiki | UTF8
(4 rows)


Installing Xwiki


To start with let's download the Xwiki war file:

wiki# wget http://download.forge.objectweb.org/xwiki/xwiki-enterprise-web-2.4.war
--2010-09-11 20:56:48--  http://download.forge.objectweb.org/xwiki/xwiki-enterprise-web-2.4.war
Resolving download.forge.objectweb.org... 88.191.79.12, 2a01:e0b:1:79:2e0:f4ff:fe1b:b525
Connecting to download.forge.objectweb.org|88.191.79.12|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 99642511 (95M) [text/plain]
Saving to: `xwiki-enterprise-web-2.4.war'

100%[======================================>] 99,642,511   406K/s   in 4m 15s  

2010-09-11 21:01:04 (382 KB/s) - `xwiki-enterprise-web-2.4.war' saved [99642511/99642511]


This will now get renamed to xwiki.war and moved to the $TOMCAT_HOME/webapps directory:

wiki# mv xwiki-enterprise-web-2.4.war xwiki.war
wiki# mv xwiki.war /usr/local/apache-tomcat-6.0/webapps/


From this moment we can look at starting Tomcat6 and looking at the WAR file extracting into the webapps directory:

wiki# ls /usr/local/apache-tomcat-6.0/webapps
ROOT		examples	manager
docs		host-manager	xwiki.war
wiki# /usr/local/etc/rc.d/tomcat6 restart
tomcat60 not running? (check /var/run/tomcat60.pid).
Starting tomcat60.
wiki# ls /usr/local/apache-tomcat-6.0/webapps
ROOT		examples	manager		xwiki.war
docs		host-manager	xwiki


The next part sees us installing the Tomcat connector into Xwiki:

wiki# cd /usr/local/apache-tomcat-6.0/webapps/xwiki/WEB-INF
wiki# cd lib
wiki# wget http://jdbc.postgresql.org/download/postgresql-8.3-606.jdbc4.jar
--2010-09-11 21:11:19--  http://jdbc.postgresql.org/download/postgresql-8.3-606.jdbc4.jar
Resolving jdbc.postgresql.org... 200.46.204.71
Connecting to jdbc.postgresql.org|200.46.204.71|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 476213 (465K) [application/octet-stream]
Saving to: `postgresql-8.3-606.jdbc4.jar'

100%[======================================>] 476,213      151K/s   in 3.1s    

2010-09-11 21:11:24 (151 KB/s) - `postgresql-8.3-606.jdbc4.jar' saved [476213/476213]


Edit the hibernate.cfg.xml file and comment out there rest of the config that doesn't apply:

    <!-- PostgreSQL configuration.
         Uncomment if you want to use PostgreSQL and comment out other database configurations. -->
    <property name="connection.url">jdbc:postgresql://localhost:5432/xwiki</property>
    <property name="connection.username">xwiki</property>
    <property name="connection.password">xwiki</property>
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="connection.provider_class">com.xpn.xwiki.store.DBCPConnectionProvider</property>
    <property name="connection.pool_size">2</property>
    <property name="statement_cache.size">2</property>
    <mapping resource="xwiki.hbm.xml"/>
    <mapping resource="feeds.hbm.xml"/>
    <mapping resource="activitystream.hbm.xml"/>


Restart Tomcat again:

wiki# /usr/local/etc/rc.d/tomcat6 restart
Stopping tomcat60.
Waiting (max 10 secs) for PIDS: 7591, 7591.
Starting tomcat60.


Point the web browser to the URL: wiki.nova-tech.com:8180/xwiki at this point and the page should appear!!


If for some reason an error is given in the browser:


Error.png


then add this to the: /usr/local/apache-tomcat-6.0/conf/catalina.policy file:

grant codeBase "file:${catalina.base}/webapps/xwiki/-" {        
     permission java.security.AllPermission; 
     permission java.io.FilePermission "${catalina.base}/webapps/xwiki/-", "read,write,delete";
     permission java.io.FilePermission "/var/log/tomcat60/-", "read,write";
     permission java.io.FilePermission "/WEB-INF/xwiki.cfg", "read";
     permission java.io.FilePermission "/WEB-INF/hibernate.cfg.xml", "read";
     permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
     permission java.util.PropertyPermission "user.name", "read";
     permission java.util.PropertyPermission "office.*", "read";
     permission java.util.PropertyPermission "file.encoding", "read";
     permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory.HashtableImpl", "read";
     permission java.util.PropertyPermission "org.quartz.properties", "read";
     permission java.util.PropertyPermission "ANTLR_DO_NOT_EXIT", "read";   
     permission java.util.PropertyPermission "ANTLR_USE_DIRECT_CLASS_LOADING", "read";
     permission java.util.PropertyPermission "org.apache.xerces.xni.parser.XMLParserConfiguration", "read";
     permission java.net.SocketPermission "127.0.0.1:3306", "connect,resolve";
     permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
     permission java.lang.RuntimePermission "getClassLoader";
     permission java.lang.RuntimePermission "createClassLoader";  
     permission java.lang.RuntimePermission "setContextClassLoader";
     permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina";
     permission java.lang.RuntimePermission "accessDeclaredMembers";
     permission java.lang.RuntimePermission "getenv.ProgramFiles";
     permission java.lang.RuntimePermission "getenv.APPDATA";
};


If still getting errors after this then update the ports tree until the Tomcat and Postgresql versions are the latest up-to-date ones; information on upgrading the ports tree can be found [MediaWiki:Welcome_to_the_Howto_page/FreeBSD/Ports here].


Once Xwiki is up and running the initial screen should look like this:


Wiki-Startup.png


Initial Configuration


As claimed by Xwiki it currently doesn't have any pages or templates in it meaning that we manually have to do this. To start with access the Administration section of the Xwiki interface:


Xwiki-Admin.png


Then download the Xwiki templates from here, and upload them into the Xwiki instance:


Template.png


After the Xar file has been selected from a folder in your computer click the Upload button:


Template2.png


Click the link on the Xar file itself to reveal the package contents and click on Import:


Template3.png


The screen will finally display confirmation that the templates have been loaded into the Xwiki instance and that it is time to login:


Template4.png


Finally go back to the Xwiki homepage and test that everything has been loaded as planned:


Full-Wiki.png


Then login as the Administrator:


Full-Wiki-login.png


And begin customizing your new install of Xwiki:


Full-Wiki-login2.png