Skip to content

TheHippo

if (i=1) throw null;

Archive

Category: Server

Today I discovered that a while back on a PHP/HTML/MySQL project I made some serious mistakes on my database design. To explain it in short:

I have one a table, lets call it “table1″, and another table, lets call it “table2″. Table1 references a row from table2, but I didn’t used foreign keys in these days. (I don’t if I didn’t know that they are exist or if InnoDB wasn’t available.) The Website has an admin tool which edits all the tables through some HTML forms. My mistake was that it is possible to delete a row from table2 which leaves all the rows in table1 referencing this row in table2 somehow broken. Today someone discovered this mistake I needed to clean this up. My idea was to create a simple query which cleans table1 and the alter the PHP which deleting rows from table2 to also clean up table1.

I started which the following query:

  1. DELETE FROM table1 WHERE id IN (
  2.   SELECT t1.id
  3.   FROM table1 AS t1
  4.   LEFT JOIN table2 AS t2 ON t1.key = t2.key
  5.   WHERE t2.key IS NULL
  6. )

Which leads to the following error:

#1093 - You can't specify target table 'table1' for update in FROM clause

I was some kind of shocked because I had no idea whats wrong with this query. After searching the web for a while I found out that it is some kind of bug in MySQL but there is a weird looking workaround: continue reading…

A while ago I used VMware server to running a few virtual instances for testing purposes. Everything worked really flawless. Yesterday I wanted to have some virtual server on my home computer again and encountered many problem with the current version of VMware Server on my Ubuntu 10.04 LTS.
There where some problems with the installation, some to get the VMware console running and also a few the keyboard input on the console.

It took a while to get everything running and I pulled all the information I needed from many different sites. So pulled them all together in this blog entry: continue reading…

Just for fun I looked at the headers generated by website I made and where I am responsible for the administration of the Apache server I discovered this:

HTTP/1.1 200 OK
Date: Sun, 06 Sep 2009 11:44:56 GMT
Server: Apache/2.2.8 (Ubuntu) DAV/2 SVN/1.4.6
X-Powered-By: PHP/5.2.4-2ubuntu5.7
Connection: close
Content-Type: text/html

Actually I think no one needs to know which PHP version is running on this machine and that there also a Subversion is running on that machine. Even the name of the operating system and the version of the Apache is not needed in most cases.

So how suppress these information?

continue reading…

In my last post I wrote about some problems that I had with my virtual server that freezes under heavy load. The improvements I suggested worked really nice but the server still sometimes freezes – not often as before but it still happened. So I “googled” around and also asked at ServerFault.com.

It seems that keeping up the the apache mpm_prefork and mod_php will not be the solution anymore. Most sites suggested to use mpm_worker instead, because it uses less memory (and my problem was, that my Apache consumed all my memory). On the other hand there could be some problems with thread-safety, but I liked to give it a try. PHP will not me used as an Apache module any more. Instead we will run PHP as a FastCGI script. continue reading…

After leaving my last company I rented a small virtual server at 1und1. I took the XL vHost package which contains:

  • 20 GB Raid 5 Storage
  • 512 MB RAM, max 2 GB RAM
  • 2 TB Traffic

At this time I thought it would be nice to install every thing by myself, so I choose a plain “Ubuntu 8.04 LTS 64 bit minimal” as operating system for my vHost. I installed Apache2, PHP5, MySQL and all the stuff I needed. It all works fine and I was really impressed by the speed of this virtual server.

Then I moved sportinleipzig.de, which I made during the time at my last company to this new server. This page does not have a very high traffic (200 unique visitors a day), but a lot of content (at least 5000 “static” pages). After 2 days the server crashed the first time, whereas crash means, that he is still alive, but does not respond to anything more then a simple ping. I restarted the server over the admin panel. Half a week later the server crashed the next time. Investigating the cause for these crashed I found out a few interesting things. continue reading…

On the last blog I wrote for was an article which described who to install eAccelerator on a Ubuntu server. As this blog entry had a lot of visits I decided to put it on this blog again:

PHP is not the fastest scripting language, that truly a fact. Except from optimizing the scripts there a few possibilities to speed everything up. One is to install a byte code optimizer and cache on your server. They cache the byte code created by the PHP parser and try to optimise it. So every time some one requests for a page on your server the script does not have to be parsed again. This brings a speedup of 120 – 250% depending on you script. There are several byte code caching program available, the one I like most is eAccelerator. Sadly eAccelerator is not available through the Ubuntu repositories so you have install them yourself. Here is a short description how to archive this!
continue reading…