Thoughts Electrique

Custom php.ini and URL rewriting in Plesk 9 with fastcgi

March 19th, 2009

For a current hosting server I’m using the Plesk control panel 9.0.1 for Ubuntu 8.04. Since version 9 Plesk allows the usage of Postfix as an MTA and PHP via FastCGI. This is very nice and much more secure than the old model using mod_php.

The Problem

One problem with the current Plesk version (as with most Plesk versions :/) is that it has some nasty bugs. For example mod_rewrite doesn’t work with the FastCGI configuration. The problem is that the generated virtual host configuration has a small but important problem. The generated host looks something like this:

<VirtualHost 88.198.164.10:80>
  ServerName   playground.himberger.de:80
  ServerAlias  www.playground.himberger.de

  <IfModule mod_fcgid.c>
    <Files ~ (\.php)>
      SetHandler fcgid-script
      FCGIWrapper /usr/bin/php5-cgi .php
      Options ExecCGI
      allow from all
    </Files>
  </IfModule>
</VirtualHost>

The issue with this configuration is the line “Options ExecCGI“. This line enables the execution of CGI scripts for this particular directory but overrides all the Options set earlier. These are in parts needed for mod_rewrite. To fix this the line should be “Options +ExecCGI“. Sadly changing the configuration doesn’t help because at the next opportunity Plesk will regenerate the config file and your change is gone.

Luckily there is a way around this…

Read the rest of this entry »

Static IPs and default route on 1und1 CentOS 5 Servers

March 11th, 2009

I’ve been experiencing some serverdowns at a client who uses 1und1 CentOS 5 Servers. After some investigation I discovered that cronjobs were still running although the server appeared to be down. Checking the syslogs showed me a bunch of failed DHCP requests which remebered me of the fact that 1und1 uses DHCP to configure the server machines. I don’t think this is a good idea so I changed the setup to static IPs.

Since 1und1 puts every server behind a dedicated firewall the setup is not as easy as you think. I’ll document it here because It may be useful for other people and certainly for myself after a couple of months.

Configure a static IP address

Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 and edit it to look like the following:

DEVICE=eth0
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
HWADDR=$YOURMACADDRESS
NETMASK=255.255.255.255
IPADDR=$YOURIP
GATEWAY=10.255.255.1

Save the file.

Configure static routes

This is the tricky part. Configuring a default gateway using the GATEWAY= setting is not enough. You have to setup the routes yourself. To do so create a new file /etc/sysconfig/network-scripts/route-eth0 with the following contents:

10.255.255.1 dev eth0
default via 10.255.255.1 dev eth0

Now you only have to reload the networking configuration via

service network reload

and you are done!

This post helped me a lot with the solution.

OpenCms Apache integration: The simplest solution

March 11th, 2009

My OpenCms Apache Integration Howto for OpenCms 6 still get’s a lot of visitors. Many things have changed since I first wrote this howto and certainly things are a lot easier now. I always wanted to rewrite the howto but till then I will just publish a short update on how to integrate OpenCms 7 with Apache and to remove the /opencms prefix with the most recent software.

Read the rest of this entry »

I’m choosing Tomcat (again)

February 26th, 2009

As you may remember from my last blogpost I’m currently setting up a new hosting Server. Since this server will also host some OpenCms and JEE sites I need to set up a Servlet Container. In almost all of my projects until today Tomcat was successfully used for this purpose. Be it stand alone or embedded in a JEE application server (e.g. JBoss).

I must admit that I always had some kind of a love-hate relationship with Tomcat. The classloader had some bad issues when reloading a webapplication too often and often killed the complete server. Taking down all of the other webapplications too. Although this has gotten a lot better recently it’s still bothering me a bit.

Since I had some time after my last project I started investigating other open source alternatives. I often heard of Jetty, praised for it’s speed and simplicity, it seemed like a great alternative and I played around with it a bit. I really liked it since it was simple to use and easy to deploy but as I started to google for things like performance measurements or how to use it with a security manager I didn’t really found a lot of documentation (compared to Tomcat) and the performance doesn’t really doesn’t seem to differ from Tomcats.

So I’m once again going the Tomcat route. It has a big community and is even used in military and government organizations. It’s really not a technology decision (although I think Tomcat is solid) but more political thinking.

It will also save me some time which I can invest in trying out other technologies. Meow…

Securing a host using the Shoreline firewall / Shorewall

February 25th, 2009

Since I’m currently setting up a new server for hosting purposes I want to share some of my favourite sysadmin tools and practices.

The first featured tool is the shoreline firewall or shorewall. You can find the project at: http://www.shorewall.net/

Shorewall basically is a set of nice configuration files for iptables. Another benefit of shorewall is that it has no runtime part. You just fire up the tool, it configures your iptables and quits. This reduces the load and increases security. Additionally to the technical features there is one thing that makes shorewall really stand out: It has extensive, well-written and understandable documentation. You rarely find a use-case which is not already described in the documentation.

Read on to find out how to set up shorewall in minutes.

Read the rest of this entry »

Using jQuery UI themes for your own applications

February 23rd, 2009

It’s often the case that you need icons and graphics for your own applications, but there is no real style guide available and the customer just wants something decent and coherent. I recently started using the jQuery UI wizard to create the look and feel for my entire application. So far I am very pleased with the results.

You can even create the CSS and images using a wizard: http://jqueryui.com/themeroller

The resulting themes are dual licensed under the GPL and MIT license.

Winter time is illness time …

January 12th, 2009

First of all a happy new year to all of you.

If you’ve been wondering why there was so little activity on my blog here is the answer: Unfortunately I was ill between christmas and the 4th of january. This of course means lots of work and stuff to catch up with. I already have some drafts written for new posts and hope to publish them soon.

Thanks very much for your patience,

Sebastian

A case against the almighty project document

December 20th, 2008

To create good documentation is an art for itself and most often underestimated by us fellow software developers, architects and software project management folks. I won’t go into the detail of what makes a good documentation (in my point of view) in this blog post too deeply (maybe in the future, if you are interested?). Instead I want to point out a negative point which I run into quite frequently: The almighty project document.

Read the rest of this entry »

Manipulating OpenCms XMLContent programatically (some examples)

December 12th, 2008

Because someone asked on the mailing list and I keep forgetting the respective API calls to manipulate an OpenCms XMLContent programatically.

This is just a raw code dump not a step by step tutorial.

You can also download a ZIP file for importing it into OpenCms. But you have to adjust the paths manually.

Read the rest of this entry »

Use the power of JSP tag files in OpenCms

December 12th, 2008

Since version 7 OpenCms is a Servlet 2.4 and JSP 2.0 conforming application. In addition to the improved expression language (EL) JSP 2.0 also brings in the possibility of developing custom tags(actions) using JSP rather than writing Java code. This allows for some pretty neat things and enables you to go one step further towards cleaner view code. I’ve used this in one of my last projects extensively to refactor common code like pagers and link generation. For example:

<cms:include file="/system/modules/com.example.ocms.commons/elements/pager">
  <cms:param name="currentPage">
    <c:out value="${model.currentPage}"/>
  </cms:param>
  <cms:param name="pageCount">
    <c:out value="${model.pageCount}"/>
  </cms:param>
</cms:include>

Became:

<wt:pager model="${model}"/>

Not does it only look cleaner and is much more focused, it also decouples your view more from the underlying CMS solution. Of course you could also develop a custom tag library using Java (which I have done a few times) but using a JSP the advantage that code can be changed on the fly and even from a web designer. You can always refactor your JSP taglib into a Java one if you need to do it. There are some limitations of JSP tag files (like you can’t use scriptlets in the body) but they are easy to get around.

But as always: This is no silver bullet. There are problems with tag files which may not be obvious at the first glance.

Read the rest of this entry »