1. Installing Yum on CentOS 4

    I’m officially on mediatemple now and after getting my VPS or (dv) cleansed of plesk I noticed Yum was not installed. I’m planning on doing a full writeup after a few days but for now I’ll get this tutorial on how to install Yum on CentOS 4 out of the way.
    First off you’ll need to install a key from the centos mirrors,

    # rpm –import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4

    Next let’s start installing yum,

    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/yum-2.4.3-3.el4.centos.noarch.rpm
    Retrieving http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/yum-2.4.3-3.el4.centos.noarch.rpm
    error: Failed dependencies:
    libxml2-python is needed by yum-2.4.3-3.el4.centos.noarch
    python-elementtree is needed by yum-2.4.3-3.el4.centos.noarch
    python-sqlite is needed by yum-2.4.3-3.el4.centos.noarch
    rpm-python is needed by yum-2.4.3-3.el4.centos.noarch
    urlgrabber is needed by yum-2.4.3-3.el4.centos.noarch

    As you can tell there are a few dependencies that need to be installed first. If you’re going to copy and paste these commands be careful,

    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/libxml2-2.6.16-10.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/libxml2-python-2.6.16-10.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/python-elementtree-1.2.6-5.el4.centos.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/python-sqlite-1.1.7-1.2.1.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/rpm-python-4.3.3-22_nonptl.i386.rpm
    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/python-urlgrabber-2.9.8-2.noarch.rpm

    Wow that was a lot, now finally yum,

    # rpm -Uvh http://mirror.centos.org/centos/4/os/i386/CentOS/RPMS/yum-2.4.3-3.el4.centos.noarch.rpm

    And you should now have yum installed and ready to run. I won’t tell you how to use yum but the first thing I did was run,

    # yum update

  2. Installing SVN and Trac on Fedora Core 6 for Apache

    For some reason or another I could not find good documentation on installing Subversion and Trac on fc6 while also using Apache so I’ve simply just documented what I’ve learned and just implemented on my own system.

    This tutorial is about the installation of a development enviroment on FC6 it’s not a how-to for using it. If you need to know more I recommend reading Version Control with Subversion (I just ordered it).

    Requirements

    You need to install these packages before we start (use yum install package-name).

    • Trac – documentation wiki and bug-tracking software.
    • Subversion – source code control system.
    • Apache – duh.

    (more…)

  3. Tape Drive Setup under Linux

    Sequential-Access drives are different than Direct-Access drives and need to be treated as such. For a while now I had always thought differently because my experience with tape was only on OS X Server. And those machines had programs that managed the tape drives for ease of use.

    With a little knowledge under my belt I know differently and now I’m passing it on:

    The 2.4 kernel has built-in SCSI support so you may want to upgrade. I’m using SLES 9 and 10 so I was okay.

    Test to see if you’ve got it hooked up correctly and if Linux notices it:

    cat /proc/scsi/scsi

    Look for a non-”Direct Access” device (“Direct Access” devices are hard disks), Tape drives are primarily “Sequential-Access” devices. If it’s not there (for example, because the drive was connected, but powered on after boot) recycle the system or find a rescan-scsi-bus script to run.

    cat /proc/scsi/scsi brought up this for me:

    Host: scsi1 Channel: 00 Id: 05 Lun: 00
    Vendor: IBM Model: ULT3580-TD2 Rev: 53Y2
    Type: Sequential-Access ANSI SCSI revision: 03

    To check drive status:

    mt -f /dev/st1 status

    although yours might be:

    mt -f /dev/st0 status
    Now to use the tape drive you’ll need to use programs/commands that support non-direct-access drives. The easiest which I consider ideal is one-time tar backups: The first three steps may be unnecessary, depending on drive model. Mine seems to automatically rewind and you can just let tar overwrite any existing data, rather than wait for the erase step to finish — it takes a long time to erase a 200 GB tape, trust me.

    mt -f /dev/st1 rewind
    mt -f /dev/st1 erase
    mt -f /dev/st1 rewind
    mt -f /dev/st1 lock #to prevent someone hitting eject before it's finished
    tar -cvzf /dev/st1 /path/to/stuff/to/back/up/
    mt -f /dev/st1 unlock
    mt -f /dev/st1 eject

  4. Changing SVN Repositories

    I already posted about using the technique of updating wordpress through SVN but it just dawned on me that the instructions I (and many others) used committed us to the 2.1 trunk. And since 2.2 is a few weeks away I’m thinking of how to transition.

    If your running a few sites, the easy way would be to just run these commands:

    svn switch --relocate http://svn.automattic.com/wordpress/branches/2.1/ \http://svn.automattic.com/wordpress/branches/2.2/

    Not that big transition since I can control who gets the updates and who doesn’t just in case 2.2 doesn’t play well. If I don’t use the above steps I’ll just copy my nightly script and simply modify it with the above command to run a single update for everyone in a few seconds.

    The other option would be to use the wp trunk rather than the stable release repositories.

    http://svn.automattic.com/wordpress/trunk/

    I’m not to keen with the latter but it is an option.

  5. fedora over ubuntu

    One of my tasks this week was to setup a web server for some sites currently hosted on the tragedy of the grid. I don’t want to talk about the (mt) grid since I’ve said so much about it before but to answer “why?” I’m still on the grid for production sites is, I’ve been too busy to migrate them and at one point I was going to put them on a spry VPS but my DB was too large for their contrants, very weird indeed and I could made it work but I pushed it aside.

    This week I couldn’t wait any longer I was getting so many CS calls about it “being down” or “Sooo Slow” that it became a big priority. I was planning to install Ubuntu server and setup the system in a few hours but I had so many issues with Ubuntu Server. I rather not go into details because I can’t remember them all but one major problem was webmin and gnome. I hate to rely on a UI to manage a server but it makes my tasks so much easier. Gnome installed fine after an apt-get command but there are so many dependencies that it took hours for it to download and install. At that point I was already frustrated with the install that the problems with webmin, configuration and installing some other server packages I had givin up and started the fedora core 6 downloads.

    Today I had the time to finish the system but the installation was as easy as Ubuntu except for the 5 CDs it took to install everything. That was the only downside for fedora over Ubuntu. But at least it’s a complete web server after install. Without phpMyadmin and webmin installed I was able to serve up whatever I needed with just a few service starts. The management tool provided as well are perfectly suited and easy to use. I can’t remember the particulars but it seemed Ubuntu wanted me to configure way to much after install without any management tools, fedora can serve a test page from apache after install and if not the tools provided make it a few clicks away.

    After a few yum installs and eventually remembering to edit my host file in order to get webmin to show (from the host machine) I had a production server ready.

    fedora has some great advatages over Ubuntu IMO: First SELinux (security) and server management tools. Another feature over Ubuntu right now would be the Xen support and management tools built into core 6. The Xen management will definitely help me get a couple webservers (maybe one for myself) installed with the little time I already have instead of wasting time figuring out how to install and configure it for Ubuntu.

    This post is not saying fedora is a better web server then Ubuntu but for ease of use it’s clearly better out of the box.

  6. Flushing DNS

    It’s bad to remember how to flush DNS in windows and not know what to do in OS X, when it’s your main system.

    Windows:
    C:>ipconfig /flushdns
    OS X command
    bash$ lookupd -flushcache
    Linux:
    $/etc/rc.d/init.d/nscd restart … Read More »

  7. Restore your MySQL database from the command line

    I always forget these simple commands and since I just had to do a restore because of a 2.1 upgrade sna-foo.

    Restoring via the command line

    Restoring from FILENAME.mysql is a three step process:

    1.Drop the database

    mysqladmin -u USERNAME -p drop DATABASE

    2. Recreate the database

    mysqladmin -u USERNAME -p create DATABASE

    3. Import the backup data

    mysql -u USERNAME -p DATABASE < FILENAME.mysql

  8. How to manually hardlink

    How to manually hardlink multiple files to point to one single file. This will drastically help you if you have multiple files that are all the same because instead of editing all of the files you just need to edit one.

    This is the command that I ran
    #find . -name ‘FiletoFind.txt’ -exec ln -f newfile_hardlink.txt {} \;

    FiletoFind.txt is the file name that you want to search for. newFile_hardlink.txt is the file you want all the files to look at after they are found.

    I then executed,
    #ls -alh newFile_hardlink.txt

    This will show you how many files you hardlinked to that one file.

    After doing this for a work project I got, -rw-r–r– 4031 dcameron apache 1.3K Dec 15 18:45 newFile_hardlink.txt

    Wow, four thousand files that I just saved myself from editing.

  9. Server to Server Transfers/Migrations

    I’m getting my new server setup and I need to migrate all of my files over from my current one. Instead of using a rsync, which I’d recommend if in the process of migrating the old server’s files they get changed, I decided to just use tar and the scp command.

    For my tar I used,

    tar czvf backup.tar.gz /home/html

    For the transfer you can either go from original host to new host or vice versa.

    scp localfile myname@[newhost]:/[path to owned directory]

    or

    go to the new host and do it the other way (which I decided to do).

    scp username@[oldhost]:[path to file] ./ [/path]

    You could also combine the two with a |. I didn’t because I had to figure out the scp commands.

    FYI: I tried to do a simple wget on the tar’d file but for some reason it gave me a 403.

  10. Server Permissions

    Permissions on webservers are a hassle if not setup correctly. It’s one thing to setup everyone with their own group if they aren’t going to be editing each others files but in an environment with multiple editors it’s not a good idea, IMO.

    The best way I’ve found so far to clean up my permissions, with the help of Qunu.com, was the find command.

    # find /path/to/dir -user [username] -group [groupname] -exec chown newown.newgroup {} \;

    and then I need to make sure the files are group writable

    # chmod g+w /path/to/dir

    If you want to do Recursive changes put the -R option after the command of ‘find’ or ‘chmod’.

    Since I already cd into the directory and I only need to edit the groups I used these:
    # find . -group [group] -exec chown :[newgroup] {} \;

    # chmod g+w *

    I’m still hesitant with this solution, probably because this is the only option I know right now.

    More importantly, what’s the best practice for webservers with multiple editors and developers? Dav and Samba? I wonder how Subversion handles permissions since that’s what we are going to deploy in our next system.