Important update to earlier post on MySQL Installation

I have updated an earlier post on how to install MySQL 5.5 on Ubuntu 10.04 LTS.

Importantly, the new instructions include how to add the MySQL 5.5 libs to the loader path. This is very important as it’s highly likely that you’ll build software that depends on these MySQL libraries.

The updated instructions can be viewed at: MySQL 5.5 on Ubuntu 10.04 LTS.

Advertisements

Change the default ssh port on Ubuntu

Changing the default port of ssh is not a huge improvement in security, but I’ve found it to be a useful tool in keeping log files free from failed login attempts with username root on port 22 (and I hope you do spend the time to review your log files!). A large number of scripts run scans on the default ssh port of 22 looking for known vulnerabilities. Of course, you should keep ssh fully patched, however rapidly growing log files is a problem all its own.

One of the easiest ways to keep your log files from filling up with failed login attempts is to change the ssh port.

vi /etc/ssh/sshd_config

Update the port to a new value, such as:

Port 876

Once you’ve updated sshd, you may also which to update ssh for convenience:

vi /etc/ssh/ssh_config

Uncomment the line with Port, and set it to the same value that you set in the sshd_config file:

Port 876

Lastly, reload the sshd daemon:

/etc/init.d/ssh reload

Open a 2nd ssh session to the server to ensure everything is working.

Note:
I recommend you keep the original session open in case you get something wrong in your configuration.

Install Python 2.7.2 from source on Ubuntu 10.04 LTS

The first thing I did was to create a wwwuser that I plan to run pyramid under. As a result, I am intentionally installing Python 2.7.2 under only 1 user account, and am leaving the system wide python installation unchanged.

useradd wwwuser
passwd wwwuser
cd /home
mkdir wwwuser
chown wwwuser:wwwuser wwwuser

Copy all of the hidden files into the /home/wwwuser folder. I did this from my desktop files.

vi /etc/passwd
Update the shell to be:
/bin/bash

su - wwwuser
ln -s .profile .bash_profile
mkdir bin
mv Python-2.7.2.tgz bin
cd bin
tar -xzf Python-2.7.2.tgz
cd Python-2.7.2
./configure --prefix /home/wwwuser/bin/Python-2.7.2
make
make install

vi ~/.profile
Update path to:
PATH="$HOME/bin:/home/wwwuser/bin/Python-2.7.2/bin:$PATH"

source ~/.profile

which python
/home/wwwuser/bin/Python-2.7.2/bin/python

python --version

The output of the python --versioncommand should now be Python 2.7.2.

Install MySQL 5.5 on Ubuntu 10.04 LTS running in the Rackspace Cloud

Update April 23, 2012
I added new instructions for adding the MySQL libs to the loader path. Failure to add the libs to the loader path will cause errors when you try to run/build programs that depend on MySQL, such as installing the MySQL driver for Pyramid (Python).

Update April 18, 2012
Thanks to Lampros for pointing out that WordPress was converting double dashes into single dashes “-“. I have updated the post so that double dashes are displayed correctly.

The following are installation notes for MySQL 5.5 on Ubuntu 10.04 LTS running on the Rackspace cloud.

Download MySQL

Download the MySQL package from http://www.mysql.com in the ~/Downloads directory.

Download the following package from http://www.mysql.com/downloads/mysql/#downloads by selecting Debian Linux from the Select Platform drop-down list:

mysql-5.5.22-debian6.0-x86_64.deb

Installation Prerequisities

After the download is complete, open a terminal and execute the following commands:

Note:
libpthread-stubs0 libpthread-stubs0-dev coreutils are really not required, but I installed them as I was working through another issue.

apt-get install build-essential cmake libncurses5-dev libaio-dev bison libpthread-stubs0 libpthread-stubs0-dev coreutils

Setup the MySQL User and Group

groupadd mysql

useradd -r -g mysql mysql

Install MySQL

cd ~/Downloads

dpkg -i mysql-5.5.22-debian6.0-x86_64.deb

Note:

MySQL is now installed into the following directory:

/opt/mysql/server-5.5

cd /opt
chown root:root mysql
cd mysql
chown root:root server-5.5
cd server-5.5
chown -R mysql:mysql ./*
./scripts/mysql_install_db --user=mysql
chown mysql:mysql ./*
cd lib
chown -h mysql libmysqlclient.so libmysqlclient.so.18 libmysqlclient_r.a libmysqlclient_r.so libmysqlclient_r.so.18 libmysqlclient_r.so.18.0.0
cd ../support-files/

Note:
Decide which of the configuration files meets your needs, then copy it to /etc.

cp my-medium.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysql

Add MySQL to PATH

vi /etc/environment

Add the following to the end of the path:

/opt/mysql/server-5.5/bin

Example:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/mysql/server-5.5/bin"

source /etc/environment

Start the MySQL Server

/etc/init.d/mysql start

Set the MySQL Server to Start on Boot

update-rc.d mysql defaults

Create a root Password and Secure the Server

The following is the most basic and minimal security, but the steps below are required for a production server.

/opt/mysql/server-5.5/bin/mysql_secure_installation

Check the security settings:

mysql -u root -p
mysql> use mysql;
mysql> SELECT User, Host, Password FROM mysql.user;

Note:
None of the password fields should be blank.

Add the MySQL Libs to the Loader Path

We now need to update our loader path to include the MySQL libs. This is important for any future work we do that depends on the MySQL libraries, such as installing a MySQL driver for Pyramid.

cd /etc/ld.so.conf.d
vi mysql.conf

Paste in the following:

# MySQL 5.5 Libraries
/opt/mysql/server-5.5/lib

ldconfig

Post installation checks

mysqladmin version -u root -p
mysqladmin variables -u root -p

Create an Ubuntu 10.04 LTS in the Rackspace Cloud

The following are instructions for creating an Ubuntu 10.04 (LTS) server instance in the Rackspace cloud.

  1. Login to your CloudControl Panel account.
  2. In the left pane, click Hosting, then click Cloud Servers.
  3. Click Add Server.
  4. Click Select next to Ubuntu 10.04 LTS (Lucid).
  5. Enter a Server Name.
  6. Select a Server Size.
  7. Click Create Server.