Archive

Posts Tagged ‘Ubuntu’

Nginx and PHP on Ubuntu Lucid

To do some PHP development (read experimenting) on my laptop I wanted to get a web-server with PHP running on it. Since this is a laptop with limited resources, I decided to try Nginx instead of Apache. Nginx is known to use less memory as compared to Apache. I am hoping this will keep the laptop still usable while the web-server is still running in the background.

This is not an exhaustive how-to, but this is how I installed all that is needed to get my first PHP page up.

Let me begin by mentioning that this laptop currently runs the development build of Ubuntu Lucid (which will become Ubuntu 10.04 LTS sometime in April 2010).

To begin, I installed following packages from Ubuntu Lucid repositories:

  % sudo aptitude install nginx php5-cgi lighttpd

Although I am not using lighttpd, the package is required because it provides the spawn-fcgi script.

Nginx supports FastGI natively. PHP is served as a FastCGI process.

Modify /etc/php5/cgi/php.ini to include the following line:

cgi.fix_pathinfo=1

Setting this configuration makes sure that PHP sets path information of the executing script in a way that conforms with CGI specifications. The line may already exist in the file, but commented. Just un-comment it. This is an optional step (at least in Lucid version of PHP) since the default value of cgi.fix_pathinfo is 1.

To spawn FastCGI add the following line to /etc/rc.local every time the computer starts.

/usr/bin/spawn-fcgi \
    -a 127.0.0.1 -p 9000 -u www-data -g www-data \
    -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

This script (spawn-fcgi) was installed via the lighttpd package.

Finally, I configured a website in Nginx and enabled PHP via FastCGI. This configuration would typically reside in /etc/nginx/sites-available/<website_name>:

server {
  listen   80;
  server_name  localhost;

  access_log  /var/log/nginx/localhost.access.log;

  root   /var/www/blog;
  index  index.php;
  fastcgi_index  index.php;

  #
  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
  }
}

When all is set up properly, you can test it with the phpinfo() command. It should look something like the following:

phpinfo() screen - Click for full size

phpinfo() screen with Nginx+PHP setup

All this, mostly a note to self. But hope it helps someone out there.

Tags: , , ,

Koalas are in!

It’s been around a week since Ubuntu 9.10 – Karmic Koala was released. Both my Linux systems are now up-to-date.

Linux systems

One of the two machines is a Sony Vaio Laptop (VGN-T140P) and other is a desktop built on a Asus P5K-e Wifi/AP motherboard with an Nvidia 8400GS video card.

Install strategy

In both cases I chose to do a clean install. I always keep /home on a separate partition, so clean installs are not much of a hassle. I usually move all the dot-files (and directories) from /home/me out of the way before a clean install. After the install, I bring the ones I need manually. This, I believe, prevents any configuration issues arising from new versions of applications adding/removing/changing any configuration items. I do have to configure some applications – like compiz – all over again, but it is not a big deal most of the time.

I also make a copy of /etc directory before a clean install, just in case I need to refer to the hacks that worked around bugs in the previous release.

Trends

If I look at the way thinks are working on the two of my systems since Ubuntu 8.10 – Hardy Heron, I see pretty consistent trends. My laptop was at its best in Hardy, things are not quite that good now. The desktop, however, is at its best in Karmic! I wonder if it has to do with the video hardware (Intel in laptop, Nvidia in desktop) or wireless usage (I use it in laptop all the time, never on the desktop).

Suspend/resume has gotten worse on the laptop, but almost perfect on the desktop.

Laptop is plagued with wireless issues, but I know I am not alone there (Launchpad bug reports as of today).

Sound, at least on my systems, has greatly improved. It worked out of the box on both of them.

Laptop experience

The general feel of the OS has definitely improved. With the new boot experience, artwork, new themes, Karmic looks pretty neat. It is snappier than ever, even on the laptop with mediocre specifications. All that good stuff is marred by the issues that have come up in this release – from back in the alpha days.

There has always been a problem with the laptop hardware, that when it resumes from suspend (to RAM), the backlight is missing. In the past, I have been able to work around it by setting quirks in suspend/resume scripts. Those hacks don’t work anymore. I haven’t found any work-around for Karmic yet. Launchpad bug #417599.

An even worse issue that has come up is with the wireless networking. In my case, it just doesn’t connect. Even when it does, it doesn’t stay connected for long. It is extremely annoying. Launchpad but #429035. So its mostly wired network for now. I know, laptop wired to the router? That sucks :(
I hope not for very long though.

Desktop experience

On the desktop, Karmic is just sweet. Out of the box, everything just worked. Sound, video, suspend/resume, everything!

The only thing worth mentioning is that when I first rebooted the system after installing Karmic, Windows entry was missing from the Grub2 menu. All I did to fix this was:

  % sudo update-grub

I wonder why it missed the Windows entry during installation. I am sure it runs update-grub as an installation step, doesn’t it? In any case, if you see Windows entry missing from your Grub menu after installing Karmic on a dual-boot machine, just run the above command.

One more thing I haven’t checked is if wake-on-lan works. If it doesn’t I’ll need to do what I usually do after clean Ubuntu installs – Howto: Wake on LAN with ASUS P5WDG2 WS Pro in Debian/Ubuntu. Hope it works this time too!

Well, there. Now that the computer are all working, time to get some work done!

Incidentally, I set up a github account for all my little hobby projects. Check it out. All the projects are purely experimental and educational. Nothing is going to blow your mind.

Tags: , ,

Incorrect hue in video?

I was watching the Apple Get a Mac ads today and this is what I got:

Incorrect hue in GStreamer - Click for full size

Incorrect hue in videos can be corrected by fixing the hue setting in Movie Player

This is on Ubuntu 9.04 (Jaunty Jackalope), where Firefox uses GStreamer plug-in to display video. Movie Player (Applications -> Sound & Video -> Movie Player) also uses GStreamer as its back-end.

So to fix the hue issue, I opened Movie Player preferences (Edit -> Preferences). In the Display tab, under section Color Balance noticed the Hue. In my case it was set to the minimum value. I clicked on the Reset to Defaults button. It reset the Hue slider to a center position.

Closed Movie Player preferences and reloaded the movie. It looked so much better.

Now I wonder what changed the Hue setting in the first place…

Tags: , ,

Building Alpine on Hardy Heron

Lately, I have developed a liking for the Alpine Messaging System. It is a text based email client that runs on a variety of platforms. I use it with Gmail IMAP at home and MS Exchange at work. In both cases, it works beautifully.

Pre-compiled binaries for a good number of platforms are available on the apline website. But if you are not in a position to use the pre-compiled binaries – say because you do not have root privileges, or binary is not available for your platform, or may be you just
want to use the bleeding edge development code – you can build the alpine application from source. The following steps are specific to building the latest SVN snapshot on Ubuntu Hardy Heron. It may/may not work on other OSes.

Prepare your system

Get all the (known) prerequisites. From my experience, these are required:

  • libncurses5-dev to get rid of the following error:

configure: error: Terminfo/termcap not found

  • libpam0g-dev and libssl-dev to get rid of some SSL related errors.

To get the above use the following in terminal:

  % sudo apt-get install subversion libncurses5-dev \
                         libpam0g-dev libssl-dev

Get the source code

Get the latest source snapshot. Following few steps are one time. After the initial snapshot is acquired with svn checkout, svn update can be used to update the source snapshot:

  % mkdir ..../alpine
  % cd ..../alpine
  % svn checkout \

https://svn.cac.washington.edu/public/alpine/snapshots/

Accept the certificate (permanently) if required.

Configure, compile and install

Now use the familiar configure, make, make install routine to build and install Alpine.

  % cd .../alpine/snapshots
  % svn update
  % ./configure --prefix=/opt/apps/alpine
                --with-local-password-cache-method
  % make
  % sudo make install

I was overly optimistic in using --with-local-password-cache-method. I was hoping that Alpine would store my account passwords in Gnome Keyring! It did not work quite like that. I need to enter my email passwords every time I start Alpine.

Other way to automate password entry is to use the --with-passfile configure option. But it is known to be unsafe.

Happy messaging!

EDIT: Trying to recompile alpine on Intrepid, I discovered that libssl-dev is also required.

Firefox 3.0 on Linux and cairo version

Since its Alphas, I’ve been comparing font rendering in official Firefox 3.0 Linux builds and the ones I used to compile myself. Fonts in the official builds were, and still are, very crudely rendered. Upon reading a little, I learned that this difference is due to the use of different version of Cairo, a graphics library that Firefox uses under the hood.

Using --enable-system-cairo option when building Firefox greatly improves the look of fonts. I used to compile my own nightly builds using this option, hoping that the official builds will move to using that option too, before the final 3.0 release.

I just tried the final release and found that it still does not use --enable-system-cairo option, and the fonts are still not neat.

Thankfully, I also noticed that Ubuntu’s Firefox 3.0 – that got updated today as well, does use --enable-system-cairo option. Now I don’t have to compile my own builds. I wish I had noticed this the first time I installed Hardy – the Firefox 3.0 beta that came with it probably used system Cairo too. But I am glad I noticed this, better late than never.

Here are a couple of screenshots that illustrate the difference:

Firefox fonts with and without system cairo - Click for full size

Click on the image to view full size – The one on top is the Ubuntu build, using --enable-system-cairo option. The one a the bottom is the official Firefox build, not using that option. Notice how the fonts in the Ubuntu build are so much better than the fonts in the official Firefox build

Now, go download Firefox 3.0 while it’s hot. You don’t get to set a world record everyday!

Glowy Window Shadows with Compiz

I was running Ubuntu Linux 7.10 (Gutsy Gibbon) on my desktop which had an ATI graphics card. There were a lot of driver related issues (fglrx driver). I tried different versions of the driver, even upgraded to the alpha version of Hardy Heron, to gain access to the new kernel. The issues persisted. Succumbing to the driver blues, I replaced the ATI card with an Nvidia card. I am so much happier now.

However, I have this:

Glowy shadows

Notice the glow instead of shadow

What should be window shadows are somehow a glowy halo!

It is good to know I am not the only one. There’s a bug on CompizFusion (OpenCompositing) website that tracks this issue.

There seems to be a general consensus that this is indeed related to the Nvidia Linux drivers.

Here’s what is known so far. Folks dealing with glowy shadows have following in common:

  • Some flavor of Linux (Ubuntu, ArchLinux, …)
  • Nvidia graphics card (Mostly the 8-series)
  • Latest Nvidia driver (nvidia-glx-new version 169.09 in my case)
  • CompizFusion with Window Decoration plugin
  • Either Emerald or Gnome window decorator

If you are dealing with similar issue, and think can add useful bit of information to the discussion, drop a comment. Better yet, update the bug on CompizFusion (OpenCompositing).

While we are at it, is there a way of tracking bugs submitted to Nvidia (via nvidia-bug-report.sh)?

But oh, the wasted hours…

Few months back when I installed Edgy on my Sony laptop, audio wasn’t working right out of the box. I had to spend a few days googling and ubuntu-forumming to find the fix for that. Eventually it worked fine after un-muting some channels in the Volume Control.

Last weekend I upgraded to Feisty. Again the same thing – audio is gone. Once again I found myself googling and ubuntu-forumming to see if people were having the same problem – and they were. So I was convinced that there was something wrong with audio in Feisty.

Until last night, when I accidentally hit the ‘Mute’ button on the laptop! I don’t remember that button working in Edgy! So I guess its a good thing after all :)

But oh, the wasted hours :(

Tags: , , , ,

Ubuntu 7.04… or not?!

Over the weekend, I upgraded the Edgy to Feisty on my laptop. The upgrade went just fine, mostly.

The sound is gone. Just like it was after a clean install of 6.10 a few months back. I’ll need to read up a bit and get the audio working.

There was a broken emacs21 module – battery had died when I installed it and I did not clean it up. The upgrade process quit once due to dependency issues with this module. I removed the module and started the upgrade again. It went through. It used all the same downloaded files from the failed attempt.

During the upgrade process, I was constantly worried if I was really upgrading to 7.04 (see the snapshot below). The Upgrade Manager window said Upgrading Ubuntu to version 6.10!. But About Ubuntu was already updated to read 7.04!

Ubuntu 7.04 or not!

Back to work…

Tags: , ,