Late as a Cygwin user…

… but hey, better late than never!

So I was just complaining about how PuTTY doesn’t seem to handle SSH keys (e.g. AWS, Azure) very well, and then I came to (belated) realization that because rsync can be used in Windows via Cygwin, so can ssh.

Now I don’t waste time in a UI managing PuTTY profiles, generating PPKs, or fidding with regedit.exe to clean up cached host fingerprints.

Try Cygwin, today.

Advertisements

CentOS: httpd invalid command

Was configuring a CentOS 6 server recently, and I decided to comment out all httpd (i.e. Apache) LoadModule directives. Upon restart, there were several invalid commands, so I took the time to note ’em down as it wasn’t obvious (to me, at least) which commands were provided by which modules.

I liken this to a cheat sheet to http://httpd.apache.org/docs/2.2/ then:


Invalid command 'AddHandler': mod_mime
Invalid command 'Alias': mod_alias
Invalid command 'BrowserMatch': mod_setenvif
Invalid command 'DirectoryIndex': mod_dir
Invalid command 'IndexOptions': mod_autoindex
Invalid command 'LanguagePriority': mod_negotiation
Invalid command 'LogFormat': mod_log_config
Invalid command 'Order': mod_authz_host
Invalid command 'TransferLog': mod_log_config

CentOS: rpmbuild-ing Vim w/ Ruby support

Recently I switched from Ubuntu 11.04 to CentOS 5.7, only to find out that CentOS’s version of vim was build sans Ruby support:

$ vim --version | grep ruby
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent

“-ruby” means that Ruby support is not available. This was an unhappy moment, as I’d been a big fan of Command-T, an excellent plugin for Vim requiring Ruby support. There are a couple of blog posts about it, but required consolidation, so here is my (mostly) repost on the solution.

The posts recommend setting up an “rpmbuild” environment for building from source, which is basically user “rpmbuild”, plus a “~/.rpmmacros” definition, plus the source RPM.

1. If “rpmbuild” already exists, the following part is not required:

# useradd rpmbuild

2. Now switch to “rpmbuild”:

# su - rpmbuild
$ vim ~/.rpmmacros

3. “.rpmmacros” is a file with the following contents:

%_topdir /home/rpmbuild/rpm
%_tmppath /home/rpmbuild/rpm/tmp

4. My build is for x86_64, so replace “$ARCH” with “x86_64”:

$ mkdir -p rpm/{BUILD,RPMS/$ARCH,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}
$ mkdir -p rpm/{BUILD,RPMS/x86_64,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}

5. Next, get the source RPM, removing the “perl-devel” dependency from “vim.spec”:

$ cd rpm/SRPMS
$ wget http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/vim-7.2.411-1.6.el6.src.rpm
$ cd ~
$ rpm -Uvh --nomd5 ~/rpm/SRPMS/vim-7.2.411-1.6.el6.src.rpm
$ vim rpm/SPECS/vim.spec

BuildRequires: python-devel ncurses-devel gettext perl-devel
BuildRequires: python-devel ncurses-devel gettext

6. Now we are ready to start the build process:

$ rpmbuild -bb ~/rpm/SPEC/vim.spec

7. If “rpmbuild” is not installed — mine wasn’t — use “root” to install “rpm-build” first:

# yum install -y rpm-build

8. Assuming #6 completed successfully, we can use “root” to install the built RPMs:

rpm -Uvh ~/rpm/RPMS/x86_64/vim-{m,c,e}*

References

http://m.linuxweblog.com/vim-ruby-centos
http://wiki.centos.org/HowTos/SetupRpmBuildEnvironment
http://www.lamolabs.org/blog/2662/fixing-ruby-support-in-vim-on-fedora-10-11-and-centos-5-installing-the-vim-textile-plugin/

Failed dependencies when installing rpmforge

Got this error today whilst trying to install collectd, which is kindly provided by RPMForge:

$ sudo rpm -i rpmforge-release-0.5.2-2.el6.rf.i686.rpm
error: Failed dependencies:
rpmlib(FileDigests) <= 4.6.0-1 is needed by rpmforge-release-0.5.2-2.el6.rf.i686
rpmlib(PayloadIsXz) <= 5.2-1 is needed by rpmforge-release-0.5.2-2.el6.rf.i686

Googled about it for awhile, nothing forthcoming. Now, if you ‘rpm -qa | grep rpmlib’ no results will return. The actual package name is ‘rpm-lib’.

So after awhile I noticed that the versions stated above were higher than the one I had installed, and I’d just done a ‘yum upgrade’. That was swiftly followed by the “el6” part, and that I had completely missed out the title “1. RPMforge for (upcoming) CentOS 6”. Well done.

So if you get the error in CentOS 5, it’s because you were trying to install an .rpm for CentOS 6. The correct URLs are:

i386: http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
x86-64: http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm

Skipping incompatible lclntsh

Received this error whilst make-ing oci8 for PHP. It was a fresh install of 64-bit CentOS 5.4 w/ Oracle XE 10g installed; e.g.

$ sudo make
.
.
.
/usr/bin/ld: skipping incompatible /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so when searching for -lclntsh
/usr/bin/ld: cannot find -lclntsh
$

So I checked for /usr/lib/oracle/10.2.0.4/client/lib/libclntsh.so — it was there, but for some reason it was “incompatible”. Google helped once again. The problem was that the 10g RPM was 32-bit, but I was compiling a 64-bit version of oci8. how vague is that?

To resolve the issue, I installed the 64-bit -basic, -devel versions of Oracle Instant Client. Obviously I was being a smart-ass, since I thought that the XE RPM would’ve been sufficient, not!

When running the configure script, prepend with the path to Oracle Instsnt Client:

$ phpize
$ ./configure -with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib
$ sudo make
$ sudo make install

Hopefully this helps the next one confounded by “skipping incompatible lcntsh”.

Using specific CentOS mirror

I wanted to have the server pull updates from a particular CentOS mirror.

Set enabled=0 for fastestmirror.conf:

$ cat /etc/yum/pluginconf.d/fastestmirror.conf
[main]
enabled=0
verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook

Set the mirrorlist, baseurl and failovermethod values for CentOS-Base.repo for base, updates, addons, extras, centosplus, contrib sections. Note that the baseurl is specific to each section, so copy carefully:

$ cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirror.nus.edu.sg/centos/$releasever/os/$basearch/
failovermethod=priority
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirror.nus.edu.sg/centos/$releasever/updates/$basearch/
failovermethod=priority
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
baseurl=http://mirror.nus.edu.sg/centos/$releasever/addons/$basearch/
failovermethod=priority
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirror.nus.edu.sg/centos/$releasever/extras/$basearch/
failovermethod=priority
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirror.nus.edu.sg/centos/$releasever/centosplus/$basearch/
failovermethod=priority
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirror.nus.edu.sg/centos/$releasever/contrib/$basearch/
failovermethod=priority
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

OCIEnvNlsCreate() failed again

So I’ve downloaded and installed Fedora 12 for the work laptop for awhile now. Previously it was Linux Mint 7/8, but I haven’t actually used the machine yet, as I encountered that darned OCIEnvNlsCreate() error message again. Same setup, just Oracle Express 10 on Linux, except the distro is Fedora this time.

So I was looking for a place to set environment variables — Apache’s SetEnv directive DOES NOT work — and there is no equivalent of Debian’s /etc/apache2/envvars in Fedora, at least I’m told. The weird thing is, plenty of people have encountered the problem before, but never found the solution — or didn’t bother to post the solution online.

I finally found the solution in an Oracle-hosted article about Oracle, PHP and Linux. It’s not really well-described, so I thought to post my solution here instead. Insert the call to oracle_env.sh somewhere in /etc/init.d/httpd. I put mine above the start() function definition:

. /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/bin/oracle_env.sh

oracle_env.sh file should contain something similar to the following:

ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_HOME
ORACLE_SID=XE
export ORACLE_SID
NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
export NLS_LANG
PATH=$ORACLE_HOME/bin:$PATH
export PATH
if [ $?LD_LIBRARY_PATH ]
then
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=$ORACLE_HOME/lib
fi
export LD_LIBRARY_PATH

Once you’re done, save the file (you need to be root) and then restart httpd:

sudo /etc/init.d/httpd restart