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.

#microsoft, #red-hat

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

#apache, #linux, #red-hat

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/

#red-hat, #ruby, #vi

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

#red-hat

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”.

#oracle, #red-hat

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

  1. CentOS-Base.repo

#

  1. The mirror system uses the connecting IP address of the client and the
  2. update status of each mirror to pick mirrors that are updated to and
  3. geographically close to the client. You should use this for CentOS updates
  4. unless you are manually picking other mirrors.

#

  1. If the mirrorlist= does not work for you, as a fall back you can try the
  2. 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

#red-hat

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

#oracle, #red-hat

RHEL 5 to CentOS 5

I used VirtualBox to install RHEL v5.4 today, as we’re going to use it to host our web application.

The install completed successfully, and then I realized that some kind of subscription plan is required to issue ‘yum’ commands.

So there I was, stuck with an outdated RHEL5 system (circa September 2009, the box tells me), and no RHN login in sight. Great.

Some Google-ing uncovered this article, which pretty much works, except I had to make a few edits here and there.

I thought to repost here instead, in case I ever have to convert RHEL to CentOS again.

It’s an excerpt of root’s commands:

# remove cached packages
yum clean all

# create /root/centos/
mkdir ~/centos
cd ~/centos

# import CentOS's GPG key
wget http://mirror.centos.org/centos/5.4/os/i386/RPM-GPG-KEY-CentOS-5
rpm --import RPM-GPG-KEY-CentOS-5

# web get base packages
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-5-4.el5.centos.1.i386.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/centos-release-notes-5.4-4.i386.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-3.2.22-20.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-fastestmirror-1.1.16-13.el5.centos.noarch.rpm
wget http://mirror.centos.org/centos/5.4/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm

# install using 'rpm'
rpm -Uvh centos*.rpm
rpm -Uvh yum*.rpm

# clear RHN stuff
rpm -e --nodeps redhat-release
rpm -e --nodeps yum-rhn-plugin

# upgrade to heart's content
yum upgrade

At this moment, the update is buzzing along quite well, thanks to NUS’s mirror.

#red-hat

Ruby/Rubygems on Fedora Core 6 (64-bit)

# gunzip -dc ruby-1.8.5-p12.tar.gz | tar -xof -
# cd ruby-1.8.5-p12
# ./configure
# make
# make test
# sudo make install
# gunzip -dc rubygems-0.9.2.tgz | tar -xof -
# cd rubygems-0.9.2
# ruby setup.rb
# sudo gem install rails --include-dependencies

OMG… it took like 5 minutes. Nice. How about that, PHP!

#red-hat, #ruby

PHP5 on Fedora Core 6 (64-bit)

# gunzip -dc php-5.2.1.tar.gz | tar -xof -
# cd php-5.2.1
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-libdir=lib64
.
.
.
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... no
checking for MySQL UNIX socket location... no
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!
localhost# mysql -v
zsh: command not found: mysql

Great! MySQL is not installed! Gotta head over to the MySQL website for more progress. Look for Linux (non RPM downloads), for platform Linux (AMD64 / Intel EM64T).

Now… Linux is really powerful, way more than Windows ever could be IMO but to even have a decent LAMP — that’s Linux, Apache, MySQL and Perl/PHP — for development purposes only going, the learning curve is so steep.

In contrast, I could just get XAMPP and have a development server on Windows running really quickly.

* update *

Yessss… the install for the AMD64 binary went through like a dream! I didn’t even know it was a binary at first:

# gunzip -dc mysql-standard-5.0.27-linux-x86_64-glibc23.tar.gz | tar -xof -
# ./configure
NOTE: This is a MySQL binary distribution. It's ready to run, you don't need to configure it!
.
.
.
Starting the mysqld server.  You can test that it is up and running
with the command:
./bin/mysqladmin version
localhost# Starting mysqld daemon with databases from /root/mysql-standard-5.0.27-linux-x86_64-glibc23/data
STOPPING server from pid file /root/mysql-standard-5.0.27-linux-x86_64-glibc23/data/wayne.sg.pid
070217 16:19:26  mysqld ended

OK, some problems, it started, then stopped on its own. Fine. I looked for INSTALL-BINARY, and lo and behold:

# groupadd mysql
# useradd -g mysql mysql
# cd /usr/local
# mv /root/mysql-standard-5.0.27-linux-x86_64-glibc23/ /usr/local/
# cd /usr/local/
# ln -s mysql-standard-5.0.27-linux-x86_64-glibc23 mysql
# cd mysql
# scripts/mysql_install_db --user=mysql
# chown -R root  .
# chown -R mysql data
# chgrp -R mysql .
# bin/mysqld_safe --user=mysql &
# ps -aef | grep mysql
root     18474  7962  0 16:14 pts/1    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql    18492 18474  0 16:14 pts/1    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid-file=/usr/local/mysql/data/wayne.sg.pid --skip-external-locking
root     19031  7962  0 16:23 pts/1    00:00:00 grep mysql

Yes… it worked!

Now back to PHP:

# cd /root/php-5.2.1/
# ../configure --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql \
--with-libdir=lib64 \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/usr/local/mysql/data/wayne-devel.pid
.
.
.
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... /usr/local/mysql/data/wayne.sg.pid
checking for MySQL UNIX socket location... /usr/local/mysql/data/wayne.sg.pid
configure: error: Cannot find libmysqlclient under /usr/local/mysql.
Note that the MySQL client library is not bundled anymore!

Hmmm. I installed MySQL server, now I need the client.

# rpm -ivh MySQL-client-standard-5.0.27-0.rhel4.x86_64.rpm
error: Failed dependencies:
perl(DBI) is needed by MySQL-client-standard-5.0.27-0.rhel4.x86_64

Noooooooooooooooooooooooooooooooooooo. Luckily I am familiar with installing CPAN modules. But I wonder why Perl DBI is required?!? Nevermind. Will figure that out again. I guess.

# gunzip -dc DBI-1.53.tar.gz | tar -xof -
# cd DBI-1.53
# perl Makefile.PL
# make
# make test
# make install

Same goes for DBD-mysql, since I am be doing Perl development in future.

# gunzip -dc DBD-mysql-4.001.tar.gz | tar -xof -
# cd DBD-mysql-4.001
# perl Makefile.PL
# make
# make test
# make install
# rpm -ivh MySQL-client-standard-5.0.27-0.rhel4.x86_64.rpm
error: Failed dependencies:
perl(DBI) is needed by MySQL-client-standard-5.0.27-0.rhel4.x86_64

Argh. What’s wrong? Here’s what’s wrong. This is the 3rd time I have encountered issues with 64-bit. So much for bleeding edge. The advice was to skip the dependency checking:

# rpm -ivh --nodeps MySQL-client-standard-5.0.27-0.rhel4.x86_64.rpm

*update2 *

I STILL can’t get php to compile with MySQL support, the error is something like “can’t find libmysqlclient”. Shall skip the –with-mysql options until I can figure out what’s wrong. Google-ing resulted in alot of links but no help so far.

#apache, #mysql, #php, #red-hat