Gentoo and awstats
I’ve always had some issues getting awstats to work the way I want. I used the tutorial found here to and it was *perfect*. I wanted to simply paste it here as a resource.
from: http://www.pkdavies.co.uk/blog/addingawstatstogentoo
I followed the following basic steps:
USE=”vhosts” emerge -p awstats
Remove -p pretend after you’ve seen what dependancies are required.
Create conf file:
ln -s /usr/share/webapps/awstats/6.9-r1/postinst-en.txt /etc/apache2/vhosts.d/awstats.conf
Edit the apache conf file:
nano /home/dev/apache/conf/vhosts.conf
Add something similar like this, changing the default location of awstats for security. Further access restrictions are set below:
ScriptAlias /pkd-stats “/usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/”
Alias /pkd-stats-icons “/usr/share/webapps/awstats/6.9-r1/htdocs/icon/”
<Directory /usr/share/webapps/awstats/6.9-r1/hostroot/cgi-bin/>
Options +ExecCGI +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory /usr/share/webapps/awstats/6.9-r1/htdocs/icon/>
Options +ExecCGI +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Duplicate the config file creating a new for the domain that your running and edit:
cd /etc/awstats/
cp awstats.module.conf awstats.www.pkdavies.com.conf
nano /etc/awstats/awstats.www.pkdavies.com.conf
Set the following:
LogFile=”/usr/bin/logresolvemerge.pl /home/dev/apache/logs/pkd-*.log |”
SiteDomain=”www.pkdavies.com”
DNSLookup=1
DirCgi=”/pkd-stats”
DirIcons=”/pkd-stats-icons”
AllowFullYearView=3
AllowToUpdateStatsFromBrowser=1
SkipHosts=”127.0.0.1 REGEX[^192\.168\.] REGEX[^10\.]“
Change the owner of the files:
cd /usr/share/webapps/awstats/6.9-r1/hostroot
chown -R apache:apache datadir
chown -R apache:apache cgi-bin
Now update the stats from existing log files
perl awstats.pl -config=www.pkdavies.com -update
Now password protect the access.
Create the password file (replace the word username & password with anything you like)
htpasswd -bc /etc/awstats/.htpasswd username password
In my case it involved editing the main httpd.conf file and adding the awstats.conf file uncommenting:
<Location “/pkd-stats/awstats.pl”>
AuthType Basic
AuthName “AWStats authenticated zone”
AuthUserFile /etc/awstats/.htpasswd
Require valid-user
</Location>
Reload Apache
apache2ctl configtest
apache2ctl graceful
Pure-FTPd SSL with GoDaddy Issued Certificate
GoDaddy offers some very cheap inexpensive ssl certificates. Unfortunately not every client out there *trusts* GoDaddy so you have to do some magic to *prove* that the certificates are in fact valid and from a trusted authority (valid CA).
In order to do this in Pure-FTPd you need to gather your key, certificate as provided by GoDaddy, and the appropriate intermediate certificate chain from GoDaddy (most likely this one).
Now create your new /etc/ssl/private/pure-ftpd.pem file and build it like so:
private key goes here
—–END RSA PRIVATE KEY—–
—–BEGIN CERTIFICATE—–
domain cert goes here
—–BEGIN CERTIFICATE—–
intermediate cert goes here
Now set “-Y 1″ or “-Y 2″ in MISC_OTHER of pure-ftpd section to enable ssl.
Zend Framework and Propel


This information may or may not be meaningful to anyone but me. I was new to Zend Framework and Propel, so attempting to get them to place nice was twice the undertaking. I am happy to report that all went relatively smoothly.
The first problem I encountered was just getting Propel to do what I wanted since I had 2 databases I was dealing with. I have a ‘global’ database and also a ‘local’ database. The local database actually is one of several dbs that all share the same schema, but is simply specific to which customer is using the system. The global db is, well, global to the application.
Here is a copy of my runtime-conf.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<config>
<propel>
<datasources default="global">
<datasource id="local">
<adapter>mysql</adapter>
<connection>
<dsn>mysql:host=localhost;dbname=local</dsn>
<user>localuser</user>
<password>localpass</password>
<settings>
<setting id="charset">utf8</setting>
</settings>
</connection>
</datasource>
<datasource id="global">
<adapter>mysql</adapter>
<connection>
<dsn>mysql:host=localhost;dbname=global</dsn>
<user>globaluser</user>
<password>globalpass</password>
<settings>
<setting id="charset">utf8</setting>
</settings>
</connection>
</datasource>
</datasources>
</propel>
</config>
The next thing was to get my schema files setup for each database. I created a global-schema.xml and a local-schema.xml. Below you will see the database node lines, which is all that really needed manipulation.
<database name="global" heavyIndexing="true" defaultIdMethod="native" package="orm.global">
<database name="local" baseClass="hvBaseClassLocal" heavyIndexing="true" defaultIdMethod="native" package="orm.local">
Make sure that you specify the package names. This will result in the following file structure:
orm
global
{generated class files}
local
{generated class files}
Note above that I am specifying hvBaseClassLocal as the baseclass. This will make all generated class files extend from my hvBaseClassLocal class. This is great functionality if you have common methods you want available for all your classes (logging, etc).
Before you propel-gen you will want to make sure the files are going to be where and how you want them. This is specified in build.properties.
build.properties
propel.project = safetrax
propel.database = mysql
propel.targetPackage = orm
propel.mysql.tableType = InnoDB
propel.home = .
propel.projhome = /Users/jhansen/Sites/safetrax-zend
propel.output.dir = ${propel.projhome}/application/models
propel.schema.dir = ${propel.projhome}/config/schema
propel.conf.dir = ${propel.projhome}/config/conf
propel.phpconf.dir = ${propel.projhome}/config/conf
propel.sql.dir = ${propel.projhome}/config/sql
propel.runtime.conf.file = runtime-conf.xml
propel.php.dir = ${propel.projhome}/application/models
Note that there is no database connection information there. That info is used if you are going to have propel create your schema files for you (not recommended) or you want propel-gen to manage rebuilding the schema in your databases. It works fine when you have one database, but as soon as you add the second you are hosed, as it can only do one at time… therefore you end up hacking the file and running propel-gen again. So, we just avoid that whole mess by creating our schema.xml files manually and using a separate means for dealing with the databases you will see next.
Ok, next step is to run propel-gen script. This will go ahead and created all your object class files and peer classes. I wrote a little shell script that I use for development that does at bit more:
#!/bin/bash
propel-gen .
echo "DB Destroy & Recreate...";
mysql -u root -pmypassword < config/sql/setup.sql
echo "DB Loading Schema...";
mysql -u globaluser -pglobalpassword global < config/sql/global-schema.sql
mysql -u localuser -plocalpassword local < config/sql/local-schema.sql
echo "Loading Fixtures...";
cd config/fixtures; php populate.php;
echo "Done"
My setup.sql looks like this:
DROP DATABASE IF EXISTS `local`;
DROP DATABASE IF EXISTS `global`;
CREATE DATABASE `local` ;
CREATE DATABASE `global` ;
So, in essence when I execute ./regen.sh my databases are completely destroyed and recreated using setup.sql. Then the schema for both databases is loaded back in using the sql files generated from propel-gen. The next step is running populate.php which is a script I wrote for loading up fixtures that I need in place while in development.
populate.php
<?php
// Set the include
set_include_path("../../application/models" . PATH_SEPARATOR .
"../../application/models/orm" . PATH_SEPARATOR .'../../library' .
PATH_SEPARATOR . get_include_path());
include_once '../../library/hvTools.class.php';
include_once("propel/Propel.php");
Propel::init("../../config/conf/safetrax-conf.php");
$u = new User();
$u->setName("Jeff Hansen");
$u->save();
?>
Populate.php keeps getting larger as I add new objects to the project and load them up when regenerating. I have become very fond of this approach as it tests your code while it is working, therefore you will know right away if you have errors in any overloaded save methods or others that do more than just set attributes on the objects.
The last thing to do is to start acutally integrating this baby w/in the Zend Framework. This really couldn’t be easier. Open up your bootstrap file – index.php and add the following (adjust paths as necessary.):
index.php
set_include_path('.' . PATH_SEPARATOR . '../library' . PATH_SEPARATOR . '../application/models'. PATH_SEPARATOR . '../application/models/orm' . PATH_SEPARATOR . get_include_path());
include_once("propel/Propel.php");
Propel::init("../config/conf/safetrax-conf.php");
That’s it! Byahh! You will now be able to access your classes from both databases in a sane fashion. Below is an image of my project layout in Zend Studio for Eclipse. Click on it for full size.
If you have any questions feel free to ask.
Zend Framework, Propel, jQuery
This is long overdue. I have been considering this post for quite some time but have been so wrapped up in development that I just haven’t taken the time to get it done.
Recently I was confronted with some difficult development decisions. It was time to totally redo a project that was getting… well, stale. The original code base was my first stab with PHP 5 object oriented goodness. I rolled my own classes and peers using a php script that connected to the mysql databases (2). There was no MVC framework involved. I used multiple PEAR classes including HTML_AJAX and MDB2.
The new project would need to accomplish the same things as the old… Only in a way that was more modular and easier-to-manage.
I started by analyzing different PHP frameworks. I spent at least 3 full days with each framework. In each case I followed tutorials and eventually attempted to build a simple site that would resemble my scenario.
Frameworks

Eventually I decided that Zend Framework was best for me. First, I am a fan of Zend. I like their products and think they deliver on their committments. Having the framework backed by a company helps as well. Second, I liked how I could as much or little of the framework as I wanted. Third, it just made sense to me.
I actually liked symfony quite a bit, but got frustrated when working with components… as I was getting some unusual results. CakePHP didn’t really appeal to me at all since it was based on PHP 4.
Unlike the other frameworks, Zend does not really come with the full blown ‘model’. I looked at 2.
ORMs

Both of these products are fantastic. I personally think that PHPDoctrine is the way of the future. At the time of my review they were at 0.10 release… so obviously not ready for production use at this point. Once it is stable, it could become the preferred ORM. For now however it is Propel. Propel is stable and has been in use for some time (1.3 beta is what I am using). I appreciate that fact that I can just use
$user = UserPeer::retrieveByPk(1);
instead of what propel requires
$user = $conn->getTable('User')->find(1);
Two problems for me in the above. First, I am dealing with 2 connections that are both being used simultaneously on every page (global and local). I dislike having to have a $conn around to make calls on… let alone make sure it is the right one. Second, I prefer the shorter static calls available with propel.
Also, I like the documentation for Propel better… it is actually much shorter and to the point. Again, like Zend Framework, it just made sense to me.

Last but not least I chose to use jQuery to replace HTML_AJAX and scriptaculous. Thus far I am very impressed with it and the many plugins that are available. Again, the documentation is great as well.
The great thing is that there are quality options to choose from. Each of the above mentioned products are great for different projects. I simply appreciate all the hard work that goes into all of them…
I will be posting some follow-ups on my specific usage of the above.
Access to MySQL
Let me start by saying that I despise Windows. I mean, I REALLY can’t stand using it or even worse supporting it (sorry Mom).
I have been working recently on a SecurityTrax import – where we move the companies old data into our system. The old data in this case is stored in Microsoft Access… which means you have to have a Windows machine (with Office installed) to deal w/ the data at all. That’s enough to make me sick. All of the data in our systems is stored in MySQL… which is great as it runs on pretty much *any* operating system.
Anyway, I found this great tool that allows me to dump direct from Access to MySQL. It creates the schema and all the data automatically… and the best part is that I installed it on the customer’s Windows server (that just doesn’t sound right) and pointed it direct to our servers. Therefore, I didn’t have to install Windows anywhere!
Did I mention this wonderful software is free? I do intend to donate however as it has saved me hours of Windows-induced heartache.

Access to MySQL by Bullzip
Random Shallow Thoughts
My Cadillac CTS is real-wheel drive. What is up with that? It really doesn’t help when there is a foot of snow on the ground… glad I have a Chevy Silverado as a backup.
I benched 360 this week… thanks to some SuperPump 250 (wife cringes).
I have still been coaching the vault at BYU. It has been going rather well. Believe it or not I actually vaulted for the first time in 4 1/2 years a week or so ago. I jumped on small poles from a short run… but I think I surprised some people, including myself.
Looks like I’ll be traveling to the BYU track meets to coach.
My brother Jared and his family flew in from Baltimore last week. They were supposed to leave 3 days ago for Denver. Thanks to the weather there they won’t be getting there until the day AFTER Christmas now.
SafeTrax signed 2 companies up this month.
AlarmTrax added a customer as well.
Battlefield 2 is a great game… especially when you are playing it when you don’t really have time to get all your real work done. Here are my stats.
I spoke in church last Sunday. Topic: Faith, Hope, Charity. Went well, glad its done.
The MacBook Pro is treating me awesome.
BYAAAAAHH
That is what I said – Howard Dean Style – after benching 350 yesterday. That was my goal for the year, so now I can kick back and lift lighter, focusing on trying to get my grip out w/o hurting my shoulder. Feels good.
Now for a quick report on the Mac Book Pro. One word: Sweeeet. If you haven’t tried a Mac, you should. The major things that I like are: quality hardware, intuitive design in OS and hardware, terminal, good app selection (coming from linux that is). If you are like I was and just think: eh, Mac is not for me… then you should think again.
My precious…
Well… hm, how to start this post? Things change. Big time. Today I bit the bullet and bought a Macbook Pro. That’s right, a Mac. Why do I feel like I am confessing my sins? Probably only because it cost too much money… oh well, sunk cost.
That being said, let me explain the logic behind the decision. As many of you know, I have been a fairly avid linux user for the past year. Before that, it was windows through and through (barf). The last year of my life has been one of love and hate. I love the power of linux, the ability to configure and easily manage things all from the simple command line. The power to do anything remotely that I can do locally… easily. It just works… for server-side stuff. That is where the love gets complicated. The desktop. Now, don’t think that I hate the desktops on linux (Gnome for me). They have come a L-O-N-G way in a very short period of time… and deserve some love from all for that. However, there are certain annoyances that must be overcome:
- X needs to be auto-configurable… with remote displays and projectors
- Give me a decent graphics editing program… please (no, gimp doesn’t count)
- Hibernate is still borked
- Evolution? I mean seriously
- About a handful of ‘other’ apps that make my life easier that aren’t available
Again, this is not a linux hate post. I love it. It is sweet and is getting sweeeeeter. But for me, right now, I need to be productive. I need to spend time doing the things that make me money. I don’t want to spend 10 minutes every morning trying to get my display outputting properly on my external LCD.
Anyway, this IS my first time actually owning and using a Mac, so I’ll be sure to keep you informed on the journey. So far, it has been surprisingly great. Getting apache / php / pear / mysql on has been a cinch.
By the way… all my servers run gentoo linux and I wouldn’t have it any other way… so long as Travis is around.
Winblows… really, it does
Get out your pitchforks. It’s time for all you Microsoft loving, animated paperclip using, uneducated computer users to stalk me down and kill me. Why? Because I am going to tell you something that liitle voice that wispers to you at night that you don’t want anyone else to know.. but is true: “YOU DON’T HAVE A CLUE”. Luckily for you I am in a good mood and am prepared to defend you. You have been bred, and raised in bands of all things Microsoft. In school, you used their crap, in your job today, you are sitting at some Pentium II (don’t ask what that is) machine reading this using Internet Explorer. I suppose you are listening to your iPod.
It really is time to shed yourselves of the burden of M$. Look in the mirror and repeat after me: “I am NOT a moron.” (repeat until it sinks in). Feeling better? Ok, now please listen to me carefully. I know how you feel, I used to be in your shoes – er, fingers. (Is there such a thing as Microsoft Anonymous?). The first things you need to know are:
- There are viable alternatives
- They are often free
- They are compatible with what you are doing now (aka, you can share your ‘Word’ docs)
- You are not a moron, you CAN learn something new
- You just might realize, like I have, that the alternative is MUCH better than M$
If you are waiting around for Microsoft to release VISTA, read this.
In the meantime, if you are brave enough to step outside your M$ prison you should give Linux a try. Its free and works… better (did I mention no blue screens of death).
Novell’s SuSE Linux Enterprise Desktop (what I use)
Ubuntu Linux (‘Linux for Human Beings’)
Die paperclip.

