Skip to content

Instantly share code, notes, and snippets.

@tkqubo
Created March 15, 2012 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkqubo/2047365 to your computer and use it in GitHub Desktop.
Save tkqubo/2047365 to your computer and use it in GitHub Desktop.
Rackspace - Ubuntu setup

Change password

passwd

Add an admin user

adduser qubo
usermod -a -G sudo qubo

edit sudoers file

visudo

add following line

%sudo ALL=(ALL) ALL

Updating apt

apt-get update
apt-get upgrade

Basic firewall

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport ssh -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -j DROP
iptables -I INPUT 1 -i lo -j ACCEPT

saving your rules

iptables-save > /etc/iptables.rules

set your rules to apply at boot

nano /etc/network/if-pre-up.d/iptaload

input these lines

#!/bin/sh
iptables-restore < /etc/if-post-up.d/iptasave

create a file to save rules

nano /etc/network/if-post-down.d/iptasave

input these lines

#!/bin/sh
iptables-save -c > /etc/iptables.save
if [ -f /etc/iptables.dowrules ]; then
	iptables-restore < /etc/iptables.downrules
fi
exit 0

make those files executable

chmod +x /etc/network/if-post-down.d/iptasave
chmod +x /etc/network/if-pre-up.d/iptaload

Installing MySQL Server on Ubuntu

Installing MySQL

sudo aptitude update
sudo aptitude install mysql-server

Iptables

iptables -I INPUT -p tcp --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT -p tcp --sport 3306 -m state --state ESTABLISHED -j ACCEPT

Launch MySQL

sudo service mysql start

Make Japanese available

Append these settings for each section

[client]
default-character-set = utf8
[mysqld]
default-character-set = utf8
skip-character-set-client-handshake
	character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8
[mysql]
default-character-set = utf8

Restart mysql

sudo /etc/init.d/mysql restart

Launching at boot

sudo /usr/sbin/update-rc.d mysql defaults

The MySQL shell

/usr/bin/mysql -u root -p

Setting the root password

UPDATE mysql.user SET Password = PASSWORD('password') WHERE User = 'root';

Misc.

add a user

INSERT INTO mysql.user (Host,User,Password) VALUES('localhost','demouser',PASSWORD('demopassword'));

change user's password

SET PASSWORD FOR 'username'@'localhost' = PASSWORD('password');

save the change

FLUSH PRIVILEGES;

grant user privileges

GRANT ALL PRIVILEGES ON databasename.* TO username@localhost;
FLUSH PRIVILEGES;

Install Java 7

Install add-apt-repository

sudo aptitude install python-software-properties

Install java7

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-jdk7-installer

Install Tomcat 7

Download Apache Tomcat 7.0.26

wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/tomcat/tomcat-7/v7.0.26/bin/apache-tomcat-7.0.26.tar.gz

Install

tar -xzf apache-tomcat-7.0.26.tar.gz

move extracted folder

sudo mv apache-tomcat-7.0.26 /opt/tomcat7

add tomcat user

sudo useradd -d /opt/tomcat7 -s /bin/false tomcat

change owner to tomcat user

chown -R tomcat. /opt/tomcat7

accept port 8080

iptables -I INPUT 6 -p tcp --dport 8080 -j ACCEPT

Check connection

start tomcat service

sudo /opt/tomcat7/bin/startup.sh

shutdown tomcat service

sudo /opt/tomcat7/bin/shutdown.sh

Others

Install zsh

sudo apt-get install zsh
chsh -s /usr/bin/zsh
vim .zshrc

append these lines

HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
bindkey -e
#
setopt auto_cd
setopt auto_pushd
setopt correct
setopt list_packed
setopt nolistbeep
#
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z} r:|[-_.]=**'
#
autoload -Uz compinit
compinit
#
#
export LANG=ja_JP.UTF-8
export JLESSCHARSET=japanese-UTF-8
export OUTPUT_CHARSET=UTF-8
#
# 31: red
# 32: green
# 33: yellow
# 34: blue
# 35: purple
# 36; azure
#
case ${UID} in
0)
	PROMPT=$'%{\e[31m%}%n%# %{\e[m%}'
	;;
*)
	PROMPT=$'%{\e[37m%}%n%# %{\e[m%}'
	;;
esac
#
PROMPT2=$'%{\e[33m%}%n%# > %{\e[m%}'
RPROMPT=$'%{\e[32m%}[%~]%{\e[m%}'
SPROMPT="correct: %R -> %r ? " 
#
alias la='ls -lA --color'
alias l='ls --color'
alias a='ls -lA --color'

Add Japanese fep

Add Japanese locale

sudo locale-gen ja_JP.UTF-8
sudo /usr/sbin/update-locale LANG=ja_JP.UTF-8

Install uim-fep and uim-anthy

sudo apt-get install uim-fep
sudo apt-get install uim-anthy

Set shortcut-key to enable uim-fep

vim ~/.uim

input these lines

(define default-im-name 'anthy)
(define-key generic-on-key? '("<Control> "))
(define-key generic-off-key? '("<Control> "))

Rune uim-fep

uim-fep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment