Tag Archives: sysAdmin

Focus Follow Mouse and other *nix wonders

Back in the days at the UCSD Center for fMRI, I had the opportunity to get my hands dirty with a few types of *nix systems that most people have never heard of, much less use. My boss was also pretty keen on very specific configurations that he insisted his employees put on their computers for those infrequent times he’d be on our workstations. For the record, they were:

  • Always use Emacs
  • Make sure that key to the left of the “A” key was your control key, map it to control if it wasn’t already
  • Make sure focus follows mouse set to enabled.
These are no big deal on various *nix systems, but to most Mac people, completely novel ideas

Caps Lock to Ctrl

Briefly, that control key thing. I hated it at first. Then I started using Emacs quite a bit and it made sense. It much better on your poor little pinky finger to press down without having to contort your hand. Old Solaris systems actually made that the hardware control key. Any other keyboard has to be remapped via software so “caps lock” wasn’t really caps lock. I highly recommend it, but people are soooo confused when they’re using my machine and the caps lock doesn’t work. Or control doesn’t work and makes all their text in capitals.

Focus Follows Mouse

I don’t know why I forget to do this one. The idea is that window focus (the act of becoming active) can be controlled by simply moving your mouse over the window rather than having to physically click on it and bring the window to the foreground. FFM is particularly handy because the window isn’t brought to the foreground, but is still takes input from the keyboard. I use this most often when working with the terminal – where often I only care most about the last several lines of output, and not all the clutter of text and OS UI above it. It leaves the main window that might be referencing right where it is.

On your Mac, open Terminal, and do this:

defaults write com.apple.terminal FocusFollowsMouse -string YES

Quit terminal. Re-open, and open a second terminal window (not tab). Hover your mouse over one of them and start typing. Now, hover your mouse over the other one and type. See what happens? If everything worked properly, the typing occurs in the window your mouse is hovered over. The only caveat is that it acts a little funny if the terminal is in the background to another app, but it still works. I found that sometimes you have to hover out & over another app then back to the other term window. Not a huge deal, I guess. Try it out. If you don’t like it, change the above command from … YES to … NO

It’s a time saver and convenience – especially useful on constrained displays. You might just fall in love. Now if only the whole OS would let me do that.

 

Tagged , , ,

Compiling PHP5.3.x on Snow Leopard

I like to wait quite a while before upgrading Mac OS X to the newest release because, for me, it often requires quite a bit of work. I had hopes that Snow Leopard would be different because Apple finally installed current versions of the whole LAMP stack, but I wanted to wait regardless… just in case.

Why the wait?

I do dev work that require custom libraries in my PHP installation – vanilla PHP from Apple doesn’t have what I need. To do that I’ve relied pretty heavily on the Fink package manager. Too many times I’ve upgraded to the new OS and some of the libraries haven’t yet been updated to work properly on the new system. Usually after a couple months either the libraries get fixed or Google will give me enough results and clues that I can fix the issue myself.

First things first

I went ahead and compiled  Apache from scratch. It’s easy enough and you’ll need the 64bit support for PHP. MySQL was much easier – download the intel x86_64 installer for Mac OS X 10.5 (yes, even for Snow Leopard). Side note – MySQL finally got around to recompiling the System Prefs Pane to 64bit.

Installing Fink

I’ll save you some time. First, compile fink from source. When you set up the app, do the 64bit-only packages (you’ll know – it’ll prompt you to pick 32bit or 64bit). I tried the 64bit and PHP wouldn’t install. You can always do a separate mixed architecture install later (see here for details on mixed fink arch installs).

Compiling PHP (with GD)

I need GD. This tutorial did the trick – once I had figured out the 64bit fink issue(s). Follow it and the companion standard PHP / Snow Leopard compile tutorial, linked in that article. Take a look at my compile flags, if you’re interested:
export MACOSX_DEPLOYMENT_TARGET=10.6 \
CFLAGS="-arch x86_64" \
CXXFLAGS="-arch x86_64"


./configure --prefix=/Library/PHP5 \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/etc \
--with-config-file-path=/etc/php.ini \
--with-zlib \
--with-zlib-dir=/usr \
--with-openssl \
--enable-zip \
--enable-exif \
--enable-ftp \
--enable-mbstring \
--enable-mbregex \
--enable-soap \
--enable-sockets \
--with-curl \
--with-curlwrappers \
--disable-cgi \
--with-iconv=/sw \
--with-gd \
--with-jpeg-dir=/usr/local/lib \
--with-png-dir=/usr/X11R6 \
--with-freetype-dir=/usr/X11R6 \
--with-xpm-dir=/usr/X11R6 \
--with-apxs2=/Library/Apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql

Two things: First, my PHP is installed into /Library/PHP5/. Second, my Apache is located at /Library/Apache2/. Nothin to it. Too bad it took me all day to figure this out. At least now I can move on with my life!

Tagged , , , , , ,

Backups to Amazon S3 the Easy Way

I was looking for a simple solution to backup my newly constructed server to an off-site location in case something were to happen. I don’t mean I lost a file… more like catastrophic hardware failure, fire, water damage, physical damage, and even theft!. Local backups really are best, and I don’t plan on abandoning them any time soon, but in the case of the one in a million chance where something like this occurs, there’s a high likelihood that everything might be lost.

Enter Cenolan.com: How to: Incremental Daily Backups Using Aamazon S3 Duplicity. It really is pretty easy. Just one thing: besides installing Duplicity (also required a few other dependencies), I had to install Python-boto: yum install python-boto

You may also be interested in doing regular backups of your MySQL database (from HowToForge.com)

Tagged , ,

Adding the Fedora Install DVD to Your Yum Repo List

I recently performed a major upgrade on my file server this week. It was a lot harder than it should have been, but that’s only because my Linux Foo can only go this far. Two to three re-installs later on the new hardware it was getting old, so I told the Fedora installer to just do the base package and I would worry about the rest later.

Worry is not my middle name, but frustration might be. For reasons unknown to me I thought I could just do an “upgrade” from the installer. Wrong. Then I thought maybe I could boot normally, insert the DVD, and I could then select it as a package source. Wrong. Download all those packages I missed the first time around isn’t an option on slower-than-molasses connection I have at home. So I did what any other self-respecting nerd would do – turn to Google.

The trick lies in the Yum Repos list, located in /etc/yum.repos.d/fedora.repo

Check it out. Normally you have three entries: Fedora, a Debug branch, and a Sources branch. The primary Fedora branch configs look something like this (I’m using Fedora 10 in my example) :


[fedora]
name=Fedora $releasever - $basearch
failovermethod=priority
baseurl=http://download.fedoraproject.org/pub/fedora/linux/releases/$releasever\
/Everything/$basearch/os/
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&\
arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$basearch

Our job is to copy and modify it so Yum and the GUI app manager can use the DVD. First you need to copy the block of code pertaining to [fedora] and paste the copy into your file – after [fedora] is fine.

  1. Change the line [fedora] to [fedora-dvd]
  2. change the name line to name=Fedora 10 x86_64 - DVD
  3. change the baseurl line to baseurl=file:///media/Fedora%2010%20x86_64%20DVD (the path to your DVD might be different – check it first)
  4. delete the mirrorlist line
  5. make sure the enabled line is enabled=1 (you can turn it off later through the “Software Sources” app)
  6. Save and exit

Use Yum or the Application manager to install. Rather than taxking your network and your patience you’ll see the DVD activity light busily blinking as you begin installing packages. One tip you might need to keep in mind is that refresh packages button on the package manager. There were a few packages I tried installing that were no longer available when I turned-off the net-based repo source. This is equivalent to yum clean [option]

Happy installing!

Tagged , , , ,

Nasty WordPress Worms

I just ran across a nasty worm in one of my WordPress blogs (not the most current install). Not only did it overwrite a ton of files, inserting spam links and malware into the pages, but it was sneaky enough to go into my wp-admin/.svn/prop-base/ directory and re-write those files as well. It’s fairly ingenious from the hacker standpoint. Most people like me will rely on the svn revert file.php to send the file back to its original version. That won’t work if the .svn/prop-base files are altered because svn will see that they are the same – it doesn’t bother actually checking the repo, so you’re stuck with infected files.

I solved my problem by deleting the wp-admin directory and doing an svn-up on its parent. That forces SVN to say “hey – that directory is missing. I should pull it down from the repository.” Problem solved (for now).

And I am now running the most current version of WordPress, so hopefully I’m free of risk and infection from here on out.

Tagged , , ,

Fixing a Broken TimeMachine Backup

I had the unfortunate event of having to send my MacBook Pro into Apple for some repairs. The machine came back working fine, however there was something odd going on with TimeMachine – it wanted to do a full backup of my disk. Odd, considering I keep it plugged-in all the time when I’m at my office desk. I tried re-selecting the disk, but that didn’t work. Clearly this would require some detective sleuthing on my part.

There are a couple points you need to know.

* First of all, check the Apple Support forums. They have some good information on there, but most of it is pretty basic. Start there then move on if you haven’t quickly solved your problem.

* Time Machine disks know your computer by the MAC address. This was the root of my problem – it seems my mac address had changed (new logic board?).

* I eventually found my solution at MacOSXHints.com, however I had to do a little more work to actually get everything working. See below.

What made this a step more difficult was that the MacOSXHints solution didn’t quite work, however one reader commented on a unique situation that resembled mine. in the /Volumes/TimeMachine/Backups.backupdb directory there were MyComputerName and “MyComputerName 2″ directories. The former had all my backups in there, the latter didn’t have any completed backups and showed a file creation time of today, not the last time I ran a backup. So with the ACL turned off (see the directions) I removed the “MyMachineName 2″ directory (mind you – I had already completed all the steps on MacOSXHints.com before trying this. It might be important). It worked.

YMMV but hopefully this will work for you.

Tagged , , , , ,

What’s your Fortune?

Here’s a fun little thing you can do for your next site goodie: display your users’ “fortunes” from the command-line interface, CLI, application Fortune.

On Fedora, install:
% sudo yum install fortune-mod

from PHP (fortune.php)
<pre>
<? passthru('fortune'); ?>
</pre>

I pre-formatted the text because it comes out looking as it does in the CLI. In its simplest form you can simply include this into a nice little div tag somewhere on your site (little side box above/below the nav?). If you don’t have privileges to install apps on your machine, this probably won’t work for you.

While you’re at it, take a look at simply parsing RSS feeds for your site. I found a good source over at BrainyQuote.com. Give it a shot!

Tagged , , ,

Install PHP mb_string in Fedora

Q: How do you install the mb_string PHP extension in Fedora?

A: % sudo yum install php-mbstring

It’s really painless. Answer a few y/n questions (probably want to answer “yes” to all of them), restart apache, and you’re done! Also see my recent post on adding gd support to PHP in Fedora.

Tagged ,

SEO your URL

If you’re looking for some help on learning mod_rewrite, this post isn’t for you. sorry. Instead, I’m going to show you a neat little trick that will make sure you always have one the www in front of your domain name. Why is it important? Potentially for your stats package, definitely for search engine ranking (no duplicated content), and even for uniformity across brand(?). Though it’s not necessarily part of your “brand” it is important to be consistent with the URLs you send people or have others link to.

For the purposes of this example, we want our URLs to always have the www in front: http://www.digitalfishlibrary.org

Step 1:
Open (or create) your .htaccess file and add RewriteEngine On if it isn’t already in there.

Step 2:
Below the RewriteEngine On line, add the following Rewrite condition/rule pair:
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]

We use the http 301 response code to tell browsers and search engines that this is a permanent redirect, thus updating their records. Little-known fact: web browsers are supposed to automatically update bookmarks to the new URL from a 301 code. Search engines probably do the same with their indices.

Tagged , , ,

Adding GD PHP support to Fedora Core 5 (FC5)

For some reason I thought GD was installed by default onto the DFL production servers… and that PHP was configured accordingly. I was wrong. But lo and behold I found a very simple upgrade path.

% yum install gd-devel
% yum install php-gd

restart apache:
% /sbin/service httpd restart

You’re golden.

Tagged
Follow

Get every new post delivered to your Inbox.

Join 393 other followers