Top posts

Latest articles


Upgrade to WordPress 2.5

Posted by Jongerius under Development, Webdevelopment
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

ScreenshotAs some of you may know WordPress is one of the most popular blogging packages out there. Many websites offer it, in fact this entire website is running on WordPress.

One of the things I am always very carefull and slow in is upgrading to a newer version of WordPress. One of the main reasons is because I always hack in the code of WordPress to add some neat custom features. But a couple of days back I heard that there was an entirely new version available for download, namely WordPress 2.5

I decided today to attempt and upgrade WordPress. And to my suprise after uploading all the files the website still worked. No error pages, no crashes or weird lay-out issues. Can’t believe it, every time I upgraded in the past the website looked like shit. And I had to rewrite most of the theme to get it working again.

Only after I logged in to the admin section I got a warning that my database was out of date and needed updating to the new version. Which again was smooth sailing, no errors at all. I got to say that I really like the new look of the admin section. It’s a lot more clear and clean!

So if you are working with WordPress and haven’t upgraded yet it’s sure worth the effort and time. A lot of things have improved!

PS: do backup your files and database before upgrading, you never now what may go wrong ;)


Setting up logrotation with AWStats

Posted by Jongerius under General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (1 votes, average: 4 out of 6)
Loading ... Loading ...

One of the first things I did on my new server was setting up log rotation and AWStats. You may be wondering why. Well its easy, logs tend to grow. And I prefer to have a daily log for Apache projects, rather then one large file for the entire time of running.

Setting up the logrotation

By default most servers have this build in. It’s a program called logrotate, which is pretty handy. It consists out of one general configuration file (/etc/logrotate.conf) and several smaller ones (/etc/logrotate.d/*).

I have added my Apache log rotation configuration to the /etc/logrotate.d/Apache file. What you need to do is set how often and what location to perform the log rotation on. The second thing you can set is steps that must be performed before and after the log rotation, which will come in handy later on.

Add something similar to the following for each website:

/export/log/domain.com/*.log {
   daily
   missingok
   rotate 100
   compress
   notifempty
   create 640 root adm
   sharedscripts
   prerotate
      /usr/lib/cgi-bin/awstats.pl -config=domain -update
      cd /export/log/domain.com/
   endscript
}

These settings will rotate the log files once a day, saving up to 100 files maximum. The notifempty setting makes sure empty files never get rotated and missingok prevents the thing from crashing if files are missing. The part between prerotate and endscript I will explain a bit later on, so be patient.

The next step is setting up AWStats

Which should not be difficult as it can be done with:

apt-get install awstats

After this easy step you are going to need to configure it per project, which is not so easy. You will need to copy a default configuration file. This is located in /etc/awstats/ and called awstats.conf.

Copy this for each log file you wish to keep statistics of. The file names are to be like:

awstats.<project>.conf

If you’ve done this then all you need to do is change the LogFile location to the location of your apache file. And set the LogType=w to the file for indicating a website. And set the SiteDomain to the name you want AwStats to display.

Keep in mind that you should not change the location of the configuration files, since this will crash AwStats. Also make sure that the project name you choose is identical to the domain name set up in the log rotate step with -domain.

Setting up awstats on Apache

Now that the log files are being processed by AwStats it’s time to make them available through apache. To do that you will need to add the following to the VirtualHost in httpd.conf.

ScriptAlias /awstats/ /usr/lib/cgi-bin/
Alias /awstats-icon/ /usr/share/awstats/icon/
<Directory /usr/share/awstats/icon>
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
Now you can access the statistics by browsing to http://domain.com/awstats/awstats.pl?config=domain.


Multithreading is more then just creating threads

Posted by Jongerius under Development
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

I’ve spent some time recently to update the Jong-Soft libraries to support multithreading a bit better. I’ve had this request from a developer that used the library. He loved to use more then one thread and still be able to use some of the key features like ErrorHandling.

To bo honest I can’t blame him. I just hadn’t kept it in mind when I wrote my error handling classes. So the problem was simple. If a new function call was added in multithreading I could not guarantee that the logging would be in the right order. Let me explain by an example:

Thread one calls a function:                                  - error handler creates a function node 1
Thread one creates a thread:                               - nothing happend in the error handler
Thread one calls a function:                                  - error handler creates a function node 2
Thread two calls a function:                                  - error handler creates a function node 3
Thread one leaves function:                                  - error handler closes function node 3

Hey that ain’t right. Why is function node 3 closed ;). See the problem, well that is what I am trying to solve right now. Of course there are more problems with multi threading, but this is the one causing the most headaches right know. Especially since I know need to keep track of every started thread to add nodes to the right parent node.

There are probable some more problems I will need to fix in the time to come related to the multi threading setups. I’ll keep you up to date with some of the advances I’ve made with the multi threading solutions.


Better posts to come soon

Posted by Jongerius under General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

You may have noticed that over the past three weeks my postings were a bit light. Well that had a very good reason. Some three weeks back I moved. One week before moving I ordered a new DSL line to be put in. I should have known this was too late, but any way.

As of this day I finally have my internet connection. No more writing quick posts on the job and posting them. Now I can finally spent some time on the posts again and improve the quality back to the level it once was.

PS: I did have some internet connection at home, but my neighbors don’t have that fast a connection ;)


Why It’s good to have the directory structure match namespace structure

Posted by Jongerius under Development, General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Before I dive to deep into a point bullet list as to why this is important let’s first explain how I got to this point. For the past year or so I’ve been working in Java. One of the few languages that I know of that automatically creates a new directory for each package created (similar to C++ namespace). If you don’t pay any attention to it you’d never even know it does this.

But when you want to look at files in the file explorer you might have some trouble finding the right file, and you may find expanding all the directories annoying (I know I did ;)). Especially when you are browsing the SVN or CVS when each folder takes forever to load :D.

As I noted in the first paragraph were over a year further and I must say that I like structuring the folder structure the same as the namespaces in the code. Let me explain why.

Easier to find a class
Though you may not notice it at first, but it is easier to find a class when the directory structure is similar to that in the source code. After all you already know the namespace it’s in. So locating the files becomes a lot easier.

You instantly know what classes belong to which namespace
I don’t know about all off you but I don’t always have my projects open when I’m documenting on trac. So to figure out which classes are part of a namespace I simply open the directory and find out. That way I don’t have to load the entire project every single time.

Moving of classes to other namespaces becomes easier
When you come to the point that you need to refactoring having all classes from a namespace in one directory makes it a lot easier to refactor. No longer do you have to open each file to find out in which namespace it’s located, just look at the directory structure.

This also introduces the downside that you need to move the classes in the SVN or CVS since the namespace has changed, but hey everything has it’s downsides ;).

 

Let me know if you now any good reasons, or have some strong reasons against.