My FreeBSD 7.0 installation of TimeTrex

Ask your questions regarding TimeTrex installation here.
Locked
Kris Jacobs
Posts: 3
Joined: Thu Aug 28, 2008 11:06 am
Location: Calhoun County, MI
Contact:

My FreeBSD 7.0 installation of TimeTrex

Post by Kris Jacobs »

First thing I did after I downloaded the manual installation zip file was to come here and look over system requirements, search the forums for 'freebsd', etc.

I found and read several entries, in particular Bill Tillman's struggle with TT on FreeBSD.

So I figured I would document my installation and post it here.

First off, I have an existing FreeBSD 7.0 server, running the following:

apache-2.2.9
mysql-server-5.1.26
php5-5.2.6_1
phpMyAdmin-2.11.8.1

Those are the latest versions as of this week - I keep up on my patches and updates regularly.
Getting those basic things installed & running is beyond the scope of this post - these forums are about TimeTrex, and this post is specifically about getting TimeTrex running in my environment.

So, I read the forums a bit, and found I needed a few extensions to PHP. I checked them like this:

#pkg_version -v | grep extension-name

I found that I did not have these installed:

php-soap
pear
php-bcmath

FreeBSD has a wonderful thing called the Ports Collection.
Pretty much any software you want to use can be found in and installed from Ports.
Read more about it here: http://www.freebsd.org/doc/en_US.ISO885 ... using.html
While you're there, check out the Handbook in general. I find that FreeBSD is many times more documented, logical, and structured than any Linux distribution I've ever had my hands on. In my not-so-humble opinion, FreeBSD is superior to Linux in every way. ;)

So, to find out where those three things I need are located in the ports tree, I simply went here and searched for them:
http://www.freebsd.org/ports

Soap is in /usr/ports/net/php5-soap, so that's where I go on my box to install it:

Code: Select all

cd /usr/ports/net/php5-soap
make install clean distclean
...lots of output...
...done!...
#/usr/etc/rc.d/apache22 stop
#/usr/etc/rc.d/apache22 start
Whenever I add anything to my web infrastruture, I always stop & restart Apache afterwards.

On to the next one, again searching on http://www.freebsd.org/ports.
OK, Pear is in /usr/ports/devel/pear - here we go:

Code: Select all

cd /usr/ports/devel/pear
make install clean distclean
...lots of output...
...done!...
#/usr/etc/rc.d/apache22 stop
#/usr/etc.rc.d/apache22 start
Finally, the bcmath extension to PHP -- http://www.freebsd.org/ports says it's in /usr/ports/math/php5-bcmath:

Code: Select all

cd /usr/ports/match/php5-bcmath
make install clean distclean
...lots of output...
...done!...
#/usr/etc/rc.d/apache22 stop
#/usr/etc.rc.d/apache22 start
A quick explanation of my make commands:
make install clean distclean means "install the software, clean up the work area, and clean up the downloads when you're done (distribution files)"

So now that I've got all that squared away, I'll go check my phptest.php file to see if those extensions are present...
http://mywebserver/phptest.php

The phptest.php file has some very simple code in it, that when run in a browser will dump all kinds of cool details about your PHP environment. Here's the code:

Code: Select all

<?php
phpinfo();
?>
I just loaded that in a browser, and all looked well - I saw Soap, but I didn't see BC_Math... aha, I have not stopped & restarted Apache since I installed BC_Math... done. OK now it shows up just fine.

OK I'll verify a bit further, and run the pkg_version command to see that those three packages are indeed installed, and what versions:

Code: Select all

#pkg_version -v | grep soap
php5-soap-5.2.6_1                   =   up-to-date with port
#pkg_version -v | grep pear
pear-1.7.2                          =   up-to-date with port
#pkg_version -v | grep math
php5-bcmath-5.2.6_1                 =   up-to-date with port
Great, looks good! the -v switch makes the pkg_version command check the installed version against the version that is in the Ports Tree. Since my ports tree is updated automatically via a cron job, I know that I'm all up to date and the versions are good to go.

Alright, now I guess I'm ready to drop in the TimeTrex code and get it going.
Since I've done a few of these php-front with a MySQL-back things before, I'll just pop into phpMyAdmin and create a database for TimeTrex: http://mywebserver/phpMyAdmin

Once logged in, I goto Privileges>Add A new User. Fill in the user details: username, localhost, password twice - then I am sure to select the radio button Under Database For User entitled Create Database with same name and grant all privileges.

Done! I've got all the prequisites installed and verified, and I've got an empty database waiting and ready to go.

Now I just drop the TimeTrex code into my webserver's root directory, and edit the timetrex.ini.php file as decribed from Step 4 onward in the README.txt file.

That covers it for getting the environment ready. I'll post again for how I setup a virtual host in Apache specifically for TimeTrex.

-Kris
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Post by shaunw »

Thanks for your detailed tutorial on getting TimeTrex to work on FreeBSD, I'm sure it will be helpful to many of our users.
Kris Jacobs
Posts: 3
Joined: Thu Aug 28, 2008 11:06 am
Location: Calhoun County, MI
Contact:

Post by Kris Jacobs »

Alright, now it's time to get the code in the right spot for Apache to serve it up.

I serve several different sites off this server, so I have Apache configured for Virtual Hosts / host headers.

Each site is in the format of /usr/local/www/host.domain.com

So for TimeTrex, I started out by SCP'ing the zip file from my Windows workstation over to my FreeBSD server. I use WinSCP for this, and the file ends up in my home directory on the server.

So now I have to unzip it, make a directory for it in /usr/local/www, and copy it all over.

Code: Select all

#cd /usr/home/kjacobs
#unzip TimeTrex_Standard_Edition_v2.2.13.zip
#cd TimeTrex_Standard_Edition_v2.2.13
#mkdir /usr/local/www/timetrex.mydomain.com
cp -R * /usr/local/www/timetrex.mydomain.com
FreeBSD is very good about keeping ownership and permissions squared away - but I check anway.
Yep, everything in /usr/local/www/timetrex.mydomain.com is user:group=root:wheel, and read/write/execute all looks good. I check it because after extraction in my home directory, it was all user:group=root:kjacobs. root:wheel is what I need it to be.

Now it's time to edit my httpd.conf file.
By default on FreeBSD, all Apache22 config files are located in /usr/local/etc/apache22.

For a new VirtualHost, I just copy my base root site VirtualHost entry in httpd.conf and make the appropriate edits:

Source:

Code: Select all

# Main basic site -- freebsd2.mydomain.com
<VirtualHost *:80>
        ServerName freebsd2.mydomain.com
        DocumentRoot "/usr/local/www"
        ServerAdmin kjacobs@mydomain.com
        ErrorLog /var/log/freebsd2.mydomain.com.error_log
        Include etc/apache22/httpd-basics.conf
        Alias /phpmyadmin "/usr/local/www/phpMyAdmin"
</VirtualHost>
After editing for TimeTrex:

Code: Select all

# timetrex.mydomain.com
<VirtualHost *:80>
        ServerName timetrex.mydomain.com
        DocumentRoot "/usr/local/www/timetrex.mydomain.com"
        ServerAdmin kjacobs@mydomain.com
        ErrorLog /var/log/freebsd2.mydomain.com.error_log
        Include etc/apache22/httpd-basics.conf
</VirtualHost>
Now I'll need to add a resource record on our DNS server for Timetrex. Since freebsd2.mydomain.com already has an A Record, I just put in a CNAME record for timetrex.mydomain.com that points to freebsd2.mydomain.com.

Now to edit the timetrex.ini.php file
I made a copy of it from the example file like this:

Code: Select all

#cd /usr/local/www/timetrex.mydomain.com
#cp timetrex.ini.php-example_linx timetrex.ini.php
I'm familiar with VI and have used it in the past, but by default there is a program on FreeBSD called EE - Easy Editor. It's really lots more intuitive to edit text files than VI is, and I use it 100% the time I'm on a FreeBSD system. Editing timetrex.ini.php is as simple as:

Code: Select all

ee timetrex.ini.php
Hmmm... for the base_url, I think I'll change that to just a single slash, since I'm running TimeTrex in the root of a virtual host.
base_url = /

Log directory looks fine, storage does not. FreeBSD does not use /var like Linux systems do, I'll change that to: storage = /usr/local/timetrex/storage

PHP CLI Binary path is a bit different as well: php_cli=/usr/local/bin/php

Database connection settings... I've never seen 'mysqlt' before - what is the 'T' for?
Leaving it alone for now, while I set hostname, dbname, dbuser, dbpass

Cache settings looks fine, debug I'll leave alone for now - if I need to troubleshoot it's nice to know I can come here and turn it on.

I'll leave everything else as-is, save the file, and stop/start Apache again.

Time to load that install.php script and see what it wants to do...
http://timetrex.mydomain.com/interface/ ... nstall.php

Aha! Got a couple things yet to do, getting a couple errors:

/usr/local/www/timetrex.mydomain.com/interface/install/../../templates_c is NOT writable by your web server!

OK, with those two dot-dots in there, that equates to /usr/local/www/timetrex.mydomain.com/templates_c - easy enough!

Code: Select all

cd /usr/local/www/timetrex.mydomain.com
chmod -R 775 templates_c
chmod works the same here as it does on Linux. the -R is for recursive mode, meaning "apply to this directory and everything in it" and the 775 means: 7=read/write/execute for owner; 7=read/write/execute for group; 5=read/execute for other(aka everyone else)

PHP GetText extension is not installed, TimeTrex requires GetText to be installed.

Oops! Looks like I missed a prerequisite.
http://www.freebsd.org/ports says PHP GetText is in: /usr/ports/devel/php5-gettext

Code: Select all

#cd /usr/ports/devel/php5-gettext
#make install clean distclean
...lots of compiling output...
===>  Installing for php5-gettext-5.2.6_1
===>   php5-gettext-5.2.6_1 depends on file: /usr/local/include/php/main/php.h - found
===>   Generating temporary packing list
===>  Checking if devel/php5-gettext already installed
===>   Registering installation for php5-gettext-5.2.6_1
****************************************************************************

The following line has been added to your /usr/local/etc/php/extensions.ini
configuration file to automatically load the installed extension:

extension=gettext.so

****************************************************************************
===>  Cleaning for php5-gettext-5.2.6_1
===>  Deleting distfiles for php5-gettext-5.2.6_1
Ain't it cool how FreeBSD ports automatically make the right change in your php extensions.ini file for you? ;)

Your web server is unable to create directories inside of: /usr/local/www/timetrex.calhouncountymi.gov/interface/install/../../templates_c, please give your webserver write permissions to this directory.
This one should be taken care of by the chmod change I did above. BTW, my templates_c folder only had owner=rwx, group=rx, other=rx. Since Apache is a member of the wheel group, and everything in the web root is owner:group=root:wheel, I just had to give write to group and now it should work OK.

With those three problems addressed, it's time to stop and restart Apache again.

Code: Select all

#/usr/local/etc/rc.d/apache22 stop
Stopping apache22.
Waiting for PIDS: 28744.
# /usr/local/etc/rc.d/apache22 start
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22.
Time to check in the browser again...
It works! I'm now looking thru the License Accpetance screen. :)

Have fun, & I hope this helps someone a bit!

-Kris
Kris Jacobs
Posts: 3
Joined: Thu Aug 28, 2008 11:06 am
Location: Calhoun County, MI
Contact:

Post by Kris Jacobs »

shaunw wrote:Thanks for your detailed tutorial on getting TimeTrex to work on FreeBSD, I'm sure it will be helpful to many of our users.
You're welcome - I hope someone finds it useful, and it was a good exercise for me in documenting a process.
Locked