Monday, February 23, 2009

Basic MySQL tips #1

History

MySQLAdmin maintains a history, accessible with the up and down arrows. And it works between sessions.

Which is nice.

Show all the (user) tables

> show tables;

Describe a specific table (e.g. users table):

> describe users;

Installing Web Frameworks, part 6: installing MySQL

  1. install mysql: sudo apt-get install mysql-server-5.0
  2. set the root password
  3. change root password (I didn't like the one I set it to): mysqladmin -u root -p password , where is the new password (and not the actual word 'password')

Thursday, February 12, 2009

apt-get without cdrom prompt

When running certain versions of Ubuntu (7.10 in this case), you might encounter a request to insert the cdrom when doing apt-get.

To stop this happening, edit the /etc/apt/sources.list file, and comment out (using leading #) the line containing 'deb cdrom...'

Installing Web Frameworks, part 5: Ruby On Rails

  1. Install Ruby: sudo apt-get install ruby-full build-essential
  2. Install SVN: sudo apt-get install subversion
  3. Install gems: download rubygems-1.2.0.tgz from rubyforge.org, then tar -zxvf rubygems-1.2.0.tgz, then sudo ruby setup.rb
  4. Install gems: download rubygems-1.3.1.tgz from rubyforge.org, then tar -zxvf rubygems-1.3.1.tgz, then sudo ruby setup.rb, then sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
  5. update gems: sudo gem update --system
  6. install Rails: sudo gem install rails -v 1.2.3 --include-dependencies


Wednesday, February 11, 2009

Installing Web Frameworks, part 4: renaming hosts

  1. edit the hostname file: sudo vi /etc/hostname
  2. change to required name
  3. reboot

Tuesday, February 10, 2009

Installing Web Frameworks, part 3: fixed IP address for SCC server

Next task was to ensure a fixed IP was assigned to the SCC (SVN) server. There's a known feature in Ubuntu 8.10 whereby any attempt to assign a fixed IP address using the Network Manager is overridden during reboot. There are many proposed solutions: here, here, here and here.

Having spent ~3 hours today fighting my own unique battle, I can relay the following measures that I had to do:
  1. I had to uninstall Network Manager: sudo apt-get purge network-manager
  2. edit /etc/networking/interfaces, as shown below
  3. edit /etc/resolv.conf, as shown below
  4. restart networking and/or reboot: sudo /etc/init.d/networking restart
# /etc/networking/interfaces
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
address 192.168.0.11
netmask 255.255.255.0
gateway 192.168.0.1

# /etc/resolv.conf
nameserver 192.168.0.2
nameserver 192.168.0.1

HTH

Installing Web Frameworks, part 2: SVN

  1. install apache2: sudo apt-get install apache2
  2. install svn: sudo apt-get install subversion
  3. add a svnusers group: sudo groupadd svnusers
  4. enabled visibility for all users: Alt-F2 to bring up run, and then type in gconf-editor. Within this, open apps/gnome-system-tools/users, and check showall.
  5. add me, root and www-data to svnusers group: I cheated and did it via the GUI!
  6. create root repositories directory: sudo mkdir /srv/repositories
  7. assign repositories to www-data & svnusers: sudo chown -R www-data:svnusers /srv/repositories
  8. change mod: sudo chmod -R g+rws /srv/repositories
  9. create rails repo, in /srv/repositores: svnadmin create rails
  10. repeat steps 7 & 8, to ensure that apache owns and controls all the files in the repo
  11. install libapache2-svn: sudo apt-get install libapache2-svn
  12. restart Apache2: sudo /etc/init.d/apache2 restart
  13. edit /etc/apache2/mods-available/dav_svn.conf. Add in the contents specified here. The list is below.
  14. create the password file /etc/subversion/passwd: sudo htpasswd -c /etc/subversion/passwd matthew. Don't forget this, or you'll end up with weird permissions errors in local and remote clients, including things along the lines of "Server sent unexpected return value (500 Internal Server Error) in response to MKACTIVITY request"

<Location /svn>
DAV svn
SVNParentPath /srv/repositories
SVNListParentPath On
AuthType Basic
AuthName "Synesis Web Subversion Repository"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
</LimitExcept>
</Location>

Minimal C++ program to verify GCC installation

#include <iomanip>
#include <iostream>
#include <stdlib.h>

int main(int argc, char** argv)
{
  std::cout << "__GNUC__: 0x" << std::hex << __GNUC__ << std::endl;

  return EXIT_SUCCESS;
}

Minimal C program to verify GCC installation

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
  printf("__GNUC__: 0x%08x\n", __GNUC__);

  return EXIT_SUCCESS;
}

Monday, February 9, 2009

Installing Web Frameworks, part 1: Ubuntu

  1. Download Ubuntu 8.10 in 32 and 64-bit guises
  2. Install two 32-bit systems: 1-processor and 2-processor
  3. Action all the latest updates
  4. Install/update the basic build tools, as described in the next few steps:
  5. gcc: sudo apt-get install build-essential
  6. verify gcc, by defining two programs, one C and a C++, and compiling them.