Ubuntu

Ubuntu

Introduction

Linux is an alternative to operating systems like Windows and Mac OS. Linux is also free and comes in many distributions. For the purposes of this page, Ubuntu is the distribution of choice that also ranks high on DistroWatch.

Tips and Tricks

Getting Started

Server Install Steps

  1. Visit the Ubuntu web site and download the server ISO CD image.
  2. Once downloaded, burn the ISO file to CD, and reboot to start the installation process.
  3. Pick the server install from the main menu and follow the install screen prompts.
  4. When asked to detect keyboard, skip this and pick your country settings instead.
  5. When asked to to setup your hard disk pick “Guided - use entire disk”.
  6. When asked for automatic software updates, choose manual.
  7. When asked what software to install after the core has been installed choose: LAMP. It won’t work but pick it anyway.

Server Application Install Steps

With Ubuntu freshly installed, here are a few other apps worth installing to make Ubuntu more usable as a server and development platform (steps are provided afterwords on how to configure this software). Execute the following commands from the command line in order to install:

General:

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install curl
  4. sudo apt-get install openssh-client
  5. sudo apt-get install openssh-server
  6. sudo apt-get install vsftpd
  7. sudo apt-get install zip
  8. sudo apt-get install git-core
  9. sudo apt-get install build-essential
  10. sudo apt-get install bison
  11. sudo apt-get install libreadline6
  12. sudo apt-get install libreadline6-dev
  13. sudo apt-get install zlib1g
  14. sudo apt-get install zlib1g-dev
  15. sudo apt-get install libssl-dev
  16. sudo apt-get install libyaml-dev
  17. sudo apt-get install libapr1-dev
  18. sudo apt-get install libaprutil1-dev
  19. sudo apt-get install libxml2-dev
  20. sudo apt-get install libxslt-dev
  21. sudo apt-get install libsqlite3-0
  22. sudo apt-get install libsqlite3-dev
  23. sudo apt-get install sqlite3
  24. sudo apt-get install autoconf
  25. sudo apt-get install libc6-dev
  26. sudo apt-get install ncurses-dev
  27. sudo apt-get install imagemagick
  28. sudo apt-get install librmagick-ruby
  29. sudo apt-get install apache2
  30. sudo apt-get install apache2-prefork-dev
  31. sudo apt-get install libpq-dev
  32. sudo apt-get install postgresql
  33. sudo apt-get install mysql-server
  34. sudo apt-get install python-setuptools

Configure the Hostname

  1. Edit the /etc/hostname file with your name of choice.
  2. Run the following command to restart and apply your changes: sudo /etc/init.d/hostname.h start

Configure the Network

  1. Edit the /etc/network/interfaces file adding the ip, netmask, and gateway for your ethernet adapter.
  2. Edit the /etc/resolv.conf so that it includes the primary and secondary DNS servers.

Configure the OpenSSH Server

  1. Edit the /etc/ssh/sshd_config file so that the “Banner” line is uncommented to pick up the changes.
  2. Edit the /etc/issue.net file as you see fit (maybe enter the name of your server or something clever).
  3. Restart the server: sudo /etc/init.d/ssh restart.

Configure the FTP Server

  1. Edit the /etc/vsftpd.conf file.
  2. Set anonymous_enable=NO
  3. Set local_enable=YES
  4. Set write_enable=YES
  5. Restart the server: sudo /etc/init.d/vsftpd restart

Configure Git

Remote Setup:

  1. Switch to root user.
  2. cd ~/src
  3. git clone git://eagain.net/gitosis.git
  4. cd gitosis
  5. python setup.py install
  6. sudo adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/git git
  7. Create a public key (i.e. ssh-keygen -t rsa) on your local machine or use an existing public key in your ~/.ssh folder.
  8. Upload the id_rsa.pub key to the server in the /tmp folder for example.
  9. sudo -H -u git gitosis-init < /tmp/id_rsa.pub

Local Setup:

  • git clone ssh://git@<server host>/gitosis-admin.git

Full documentation can be found here.

Configure the Apache HTTP Server

  1. Create your own Apache web directory (instead of using the defaults). Example: /var/www/example.
  2. Create a new user group that will be associated with the newly created /var/www/example directory: sudo adduser dev
  3. Create and add team members to the new “web” user group.
  4. Set group permissions on the “/var/www/example” directory so the new group can access the directory.
  5. Copy the /etc/apache2/sites-available/default file to a /etc/apache2/sites-available/(your site name) file.
  6. Edit the /etc/apache2/sites-available/(your site name) file.
  7. Set the ServerName to your private or public web address. Example: ..com.
  8. Set the ServerAdmin to your personal e-mail address.
  9. Set the DocumentRoot to whatever your newly created “web” directory path name is.
  10. Rename the /var/www directory to whatever your newly created “web” directory path is.
  11. Disable the default site: sudo a2dissite.
  12. Enable your new site: sudo a2ensite.
  13. Enable any additional modules by issuing the sudo a2enmod command and picking which module(s) you want to enable. Example: rewrite.
  14. Restart the server: service apache2 restart.

Configure PostgreSQL

Admin Setup:

  1. sudo -u postgres psql template1
  2. \password postgres
  3. \q
  4. vi /etc/postgresql/9.1/main/pg_hba.conf and add ensure the following is added to the bottom of the file:
    local all all trust and host all 127.0.0.1/32 trust Details here.
  5. To restart, type: service postgresql restart or /etc/init.d/postgresql restart

User Setup

  1. sudo -u postgres createuser --superuser <user> -P

Database Setup:

  1. sudo -u postgres createdb -O <user> <database>
  2. sudo -u postgres psql template1
  3. GRANT ALL PRIVILEGES ON DATABASE <database> to <user>;
  4. \q

Type service postgresql restart to restart PostgreSQL.

Configure MySQL

  1. Set the root password: sudo mysqladmin -u root password (your new password). You might also want to log into MySQL using the following command: mysql -u root -p. It is worthwhile to double check the root password is set.
  2. Edit the /etc/mysql/my.cnf file.
  3. Comment out the “bind-address=127.0.0.1″ line so connections can be accepted from other machines.
  4. Restart the server: sudo /etc/init.d/mysql restart
  5. Login to MySQL and create a default database: CREATE DATABASE (new database name here).
  6. Grant access to the new database for the main user or set of users who might need to access the database via MySQL Administrator or other GUI tools: GRANT ALL PRIVILEGES ON <database>.* TO "<username>"@"<host>" IDENTIFIED BY "<password>"; NOTE: <database>, <username>, <host>, and <password> should be replaced accordingly.

Configure Ruby and Ruby on Rails

To configure Ruby and Ruby on Rails, execute the following commands from the command line:

rbenv:

  1. cd ~
  2. git clone git://github.com/sstephenson/rbenv.git .rbenv
  3. echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
  4. echo 'eval "$(rbenv init -)"' >> ~/.bashrc
  5. source .bashrc
  6. mkdir ruby_source
  7. cd ruby_source
  8. curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz
  9. tar -xvzf ruby-1.9.2-p290.tar.gz
  10. cd ruby-1.9.2-p290
  11. ./configure --prefix=$HOME/.rbenv/versions/1.9.2-p290
  12. make
  13. make install
  14. rbenv rehash
  15. rbenv global 1.9.2-p290

dotfiles:

  1. cd ~
  2. rm -f .bash_profile
  3. rm -f .bashrc
  4. git clone https://github.com/bkuhlmann/dotfiles
  5. cd dotfiles
  6. ruby install.rb

gems:

  1. cd ~
  2. git clone https://github.com/bkuhlmann/ruby_gem_setup
  3. cd ruby_gem_setup
  4. ruby setup.rb

node.js:

This is necessary for Rails (especially the execjs gem).

  1. sudo apt-get install python-software-properties
  2. sudo add-apt-repository ppa:chris-lea/node.js
  3. sudo apt-get update
  4. sudo apt-get install nodejs

Phusion Passenger:

Read my Phusion Passenger post.

Services

Applications

  1. Top 10 Ubuntu Downloads
  2. lsof - A handy debugging tool for listing files and processes currently open or in use by the operating system.
  3. Top 10 Apps
  4. ManDVD - Use it to create customized DVD menus.
  5. K3b - CD/DVD authoring software. Go here to learn more.
  6. Redcar - “An open-source programmers’ text editor for Gnome (Linux). It is designed to be compatible with Textmate bundles (a work in progress) and is written almost entirely in Ruby - with some Vala thrown in for speed.”