PHP Notice: Undefined variable: _SERVER in ..

I upgraded Linux on this server a while back and in the course of that upgrade PHP was upgraded too, to version 5.5.9.

Since I had a modified php.ini it asked me to check over any new options. There were a few but I fixed anything that looked like it might break things. I saved the php.ini and let the upgrade go on.

Clearing up bugs

Some time later I saw odd notices in the PHP error log. Usually it referred to wp-comments-post.php but files outside of WordPress raised the warning too:

PHP Notice: Undefined variable: _SERVER in ..

It turns out the fix is rather easy. Jacques Marneweck on his blog posted a solution. Simply switch off “auto_globals_jit” in your php.ini and restart Apache (if required).

From the PHP manual entry for auto_globals_jit:

When enabled, the SERVER and ENV variables are created when they’re first used (Just In Time) instead of when the script starts. If these variables are not used within a script, having this directive on will result in a performance gain.

The PHP directives register_globals, register_long_arrays, and register_argc_argv must be disabled for this directive to have any affect. Since PHP 5.1.3 it is not necessary to have register_argc_argv disabled.

A bug

It looks like the bug is ancient although I’m not using APC, and the JIT compiler can be fooled if you access the super globals like _SERVER through variable variables. Sneaky!

The default for auto_globals_jit is “On” so next time you upgrade PHP keep an eye on the error log.

Linux: when the /boot is all full

I tried to install fdupes this morning on my Ubuntu Linux server but the install bombed out with this error, followed by a string of other warnings before dpkg rolled back everything:

gzip: stdout: No space left on device

What? I’d installed a 500GB drive in that machine recently. It was /boot/. A quick look in there revealed a number of old Linux kernels but luckily there’s an easy way to get rid of them.

This showed me a list of all my installed kernels, and “uname” told me the name of the current kernel which I shouldn’t remove.

dpkg -l linux-image-\* | grep ^ii

Removing them was as easy as this:

apt-get purge linux-image-3.8.0-29-generic linux-image-3.8.0-31-generic linux-image-3.8.0-32-generic linux-image-3.8.0-33-generic linux-image-3.8.0-34-generic linux-image-3.8.0-35-generic linux-image-3.8.0-36-generic

When I finally installed fdupes it kindly removed all the kernel headers saving me a further 505MB of space. I’m pretty sure this is the first time /boot has filled up on me.

fdupes is pretty nice too. It finds duplicate files by comparing file sizes first and then does MD5 checks.

Where does Nautilus store it’s folder share info?

Using a GUI is nice and all but sometimes I want to know where configuration data is stored.

The Gnome file manager, Nautilus, allows Linux users to share folders on a Windows network. Users of other operating systems will find this hard to believe but before this it was difficult to do as you needed to be an administrator and edit a configuration file called /etc/samba/smb.conf (Users of other desktop managers use similar tools).

This was convenient but I wanted to know where Nautilus puts this configuration data. I searched my home directory, I looked in /etc/samba/ (just in case) and eventually found this page:

I located the config files.

It appears as though /var/lib/samba/usershares holds a text file for each share that has been created.

The usershares directory is owned by root:sambashare and the files inside are owned by the user sharing the folder, so I guess it’s a compromise between a system process (Samba) and users wanting to configure it.

Editing those files is simple, and I guess I could use “net usershare” too. I had to restart Samba too which probably wouldn’t be needed if I had use the “net” command.

Install Ubuntu on your Android Phone

With this app you can install Ubuntu on your Android phone. It has to be rooted obviously and it’s definitely not this.

It looks like this installs Ubuntu in the same way as in the video above. It’s an app that runs in the background and you use a VNC client to connect to it. You could of course use VNC on a local desktop machine to connect to it too making it more useful but I think this is more a curiosity for those who like to tinker with their phones …

Pity he couldn’t get WordPress running on that Ubuntu install. That would have been fun to see!

Howto: Install XFCE in Ubuntu 11.10

You realise how spoiled you are by the ease at which software can be installed in Linux only when you’ve done the same in Mac OS X or Windows. apt-get or aptitude will install a wide variety of software and in the case of aptitude will remove the software and all it’s dependencies afterwards.

Yeah, I’m saying goodbye to Unity and embracing XFCE (for the moment at least. Choice is good!)

# aptitude install xfce4 xfce4-goodies
The following NEW packages will be installed:
desktop-base{a} exo-utils{a} gtk2-engines-xfce{a} hddtemp{a} libexo-1-0{a} libexo-common{a} libexo-helpers{a} libgarcon-1-0{a} libgarcon-common{a} libkeybinder0{a} libtagc0{a} libthunar-vfs-1-2{a}
libthunar-vfs-1-common{a} libthunarx-2-0{a} libtumbler-1-0{a} libxfce4ui-1-0{a} libxfce4util-bin{a} libxfce4util-common{a} libxfce4util4{a} libxfcegui4-4{a} libxfconf-0-2{a} lm-sensors{a} mousepad{a}
orage{a} ristretto{a} squeeze{a} tango-icon-theme{a} thunar{a} thunar-archive-plugin{a} thunar-data{a} thunar-media-tags-plugin{a} thunar-volman{a} tumbler{a} tumbler-common{a} xfburn{a}
xfce-keyboard-shortcuts{a} xfce4 xfce4-appfinder{a} xfce4-artwork{a} xfce4-battery-plugin{a} xfce4-clipman{a} xfce4-clipman-plugin{a} xfce4-cpufreq-plugin{a} xfce4-cpugraph-plugin{a}
xfce4-datetime-plugin{a} xfce4-dict{a} xfce4-diskperf-plugin{a} xfce4-fsguard-plugin{a} xfce4-genmon-plugin{a} xfce4-goodies xfce4-mailwatch-plugin{a} xfce4-mixer{a} xfce4-mount-plugin{a}
xfce4-netload-plugin{a} xfce4-notes{a} xfce4-notes-plugin{a} xfce4-panel{a} xfce4-places-plugin{a} xfce4-power-manager{a} xfce4-power-manager-data{a} xfce4-quicklauncher-plugin{a} xfce4-screenshooter{a}
xfce4-sensors-plugin{a} xfce4-session{a} xfce4-settings{a} xfce4-smartbookmark-plugin{a} xfce4-systemload-plugin{a} xfce4-taskmanager{a} xfce4-terminal{a} xfce4-timer-plugin{a} xfce4-utils{a}
xfce4-verve-plugin{a} xfce4-volumed{a} xfce4-wavelan-plugin{a} xfce4-weather-plugin{a} xfce4-xkb-plugin{a} xfconf{a} xfdesktop4{a} xfdesktop4-data{a} xfwm4{a} xfwm4-themes{a} xscreensaver{a}
0 packages upgraded, 82 newly installed, 0 to remove and 0 not upgraded.
Need to get 40.9 MB of archives. After unpacking 144 MB will be used.
Do you want to continue? [Y/n/?] y

Once installed, logout and select XFCE from the login menu.

XFCE has it’s own quirks and gotchas but it feels lighter and more responsive than Unity. The most difficult part was making the top menu bar autohide. I had to remove the “running programmes” list to get at the panel preferences. Only later did I notice the “Panel” item when you right click some of the menu widgets. The full screen mode in Gnome Terminal gets me back the extra 2-3 lines of terminal I missed. So winning all around as a certain actor once said …

Installing Gnome 3.2 is just as easy and looks gorgeous!

aptitude install gnome-shell

Ubuntu: ALT TAB between browser windows?

I’m still using Ubuntu’s Unity desktop, which is saying a lot as I switched back to Gnome within a week or so of the previous release of Ubuntu.

One of the remaining bugbears I had with Unity was the window or task switcher. It was impossible to switch between Chrome browser windows. I had to click on the Chrome icon in the Unity sidebar and select the window I wanted. It felt like Ubuntu had tried to emulate what Windows 7 did with their taskbar, but Windows did it better because the window previews are close to the taskbar.

I’m not the only one to have this problem. You can either change window switcher in CCSM (oh oh, watch out when using CCSM!) or use ALT-`. That character is the tick character which normally sits above the TAB key on UK/English/US keyboards but may be elsewhere on other locales. I now need to get used to it like I did with Mac OS X.

Ubuntu 11.10: Be wary of Compiz Config Settings Manager (ccsm)

Have you recently installed Ubunty 11.10 and are you marvelling at the Unity Desktop? Not many are. Marvelling at the desktop that is, but it’s growing on me. I said that last time too so we’ll see how it goes.

Anyway, the point of this little rant is to tell you to avoid or be very careful with CCSM, or “Compiz Config Settings Manager” as it’s known to it’s enemies. This little app allows you to edit practically everything related to Compiz settings. Literally everything!

Unfortunately it can also lead to a world of pain. After fiddling around with it I went into the preferences and clicked on the “Plugins” link at which time my desktop froze and I couldn’t even CTRL-ALT to a different session. Forced reboot was the other of the day.

When I finally got back in my external monitor wasn’t detected and I was left with a 1024×768 display. I spent a few hours trying to figure out what the hell had gone wrong. I deleted .config/monitors.xml and tried editing it but nothing worked. Eventually I rebooted a few times and suddenly my monitor was recognised again!

Then it was on to the workspace switcher. It didn’t work the way it used to. I hesitantly fired up ccsm and dug into the settings in Viewport switcher, then in Rotate Cube, then Desktop Wall. It was then I discovered I couldn’t deselect “Desktop Cube”. ccsm would segfault every time. Switching workspaces using the cube was painful as my hardware just isn’t up to the task. Open windows would flicker slightly after I rotated the workspace. Eventually I discovered that I could take drastic action to restore normality. First I had to login as a different user and then go into my home directory and then move some configuration directories out of the way.

mkdir bak
mv .gconf .gconfd .gnome .gnome2 bak/

After logging in again I fired up ccsm and Desktop Cube was disabled! I usually switch between workspaces using CTRL 1-4 and I was able to configure Viewport Switcher to do just that with a minimal sliding animation.

After looking in the bak directory it appears that Compiz stores it’s configuration data in various compiz directories in .gconf/apps/. I suspect it’s enough to remove them rather than all the Gnome configuration files.

I like Ubuntu 11.10 so far, I’m getting used to Unity but the top menu bar feels to me like it’s crowding out the screen. The lack of Unity themes included is troubling too as there are only 4 (2 of which are for visually impaired users by the looks of things). I’ll have to go look for some more.

Hello Ubuntu 11.04

Today is the big day. A new release of Ubuntu Linux is out. Version 11.04 or “Natty Narwhal” is the first to ship with the Unity desktop and I’m very impressed! If you haven’t seen it yet, check out the Ubuntu website or this handy guide.

I like:

  • The auto hiding sidebar of icons. When a window is maximised it hides. Long click on an icon to move it around, and right click for a context dialog to remove it.
  • Control Center is 2 clicks away in the top right where there appears to be a light switch. That menu also has a lock screen item and various session controls.
  • Apps with multiple windows show a corresponding number of dots next to their icon on the sidebar. Click on the icon and you see all the windows of that application.
  • Application menus are in the top toolbar ala Mac OS. Some, like Chrome, aren’t however.
  • Long press Windows key and the sidebar icons are highlighted with numbers 0-9 to quick choose them.
  • Click the Ubuntu logo in the top left and you get a nice applications dispay.
  • Speedy alt-tab previews of each Window.
  • Left and right maximising of windows like in Windows 7. I think you need to drag it a bit further than in Windows 7 however, no bad thing. Full screen maximise on dragging a window to the top of the screen.
  • Painless upgrade from 10.10.

And what I didn’t like:

  • The window display for multi window apps requires you select a window. It’d be great if I could click the app icon again to return to the same window. ESC does the job though.
  • GIMP tear away menus are still broken, but this is likely an issue with GIMP. It was present in the last release of Ubuntu too and I just found a work around this evening.

    The menus you are looking for are no longer part of the drop-down menus, but rather part of a right-click menu visible when clicking on the canvas.

    I found using the space bar after clicking the menu option worked on torn off menus. This may be a bug.

  • The lack of formal application menus is off putting initially but it’s actually easy enough to find things with the new launcher.
  • I doubt I’ll ever like the thin scrollbar. There is a way to change that, must find out how.
  • Why does Ubuntu keep installing Evolution every time I upgrade? I’m fairly sure I uninstall that each and every time ..

In previous versions of Ubuntu I always felt the eye candy was there just to make things look pretty. With Unity they’re actually putting that graphical horsepower to good use. If you haven’t tried Ubuntu yet, give it a spin! You can even try it without installing anything simply by booting from the install disk (or usb drive) and opting for that. Check out the download page for further details.

I’m slowly making my way through all th…

I’m slowly making my way through all the video editing software in Linux. I’ve tried Cinnerella, Lives, Kdenlive, Openshot and a few others but for one reason or another they’re all lacking. Mainly bugs unfortunately.

Of the ones I tried I like Kdenlive and Openshot and was able to do some decent multi-track editing of a video. Kdenlive crashed quite a few times and I think I failed to create a video. Openshot did really well but then I triggered an odd bug where some clips in the video simply froze. The audio continued but the image displayed was the first frame. I went searching for it and found a discussion of the very problem. Seems to be slightly glitchy 1080×720 video will cause it.

Keep searching …

Admin 101: Postfix smtp limits

I’ve just moved all my sites on to a new install of Ubuntu on one of my VPses. This site and In Photos are now on the same server again and the VPS has finally calmed down.

Between configuring Apache (turn off keep alives, and reduce the number of child processes), installing xcache and the WordPress object cache and configuring it, and configuring MySQL I totally forgot about Postfix.

I did install Postgrey of course but when Blacknight switched the web and mail traffic to this server things started to go screwy.
Load average shot up, I thought it was Apache and spent quite some time playing with the number of processes, all to no avail. I didn’t immediately notice the large number of smtp processes when I did a “ps auxw”. I was looking at Apache.

What was happening was a rumplestiltskin attack on my server. Rogue bots all over the Internet try to send spam emails to mail servers using randomly generated addresses in the hope of guessing a correct one. It happens all the time, and I had configured Postfix correctly in the past, but I had forgot this time.

So, if your server is suffering under the strain of too many Postfix smtp processes open up /etc/postfix/ and look for the smtp line:

smtp inet n – – – – smtpd

Change the last dash to a number, try small first, depending on how much mail traffic your server gets. I changed mine to 3, restarted Postfix, and the server is humming along nicely now. Postfix was actually using up more resources than Apache during those attacks! It’s unfortunate that Ubuntu (and probably every other dist of Linux) allows unlimited number of smtp processes.

Oh, I’m hosted at Linode. Yes that’s an affiliate link, but I’ve been using them for years and been very happy with them.