Linux
server
Ubuntu
SSH
vps

ubuntu server構築時にやった作業

More than 5 years have passed since last update.

Cloud Core VPSに作業用環境構築した時のメモ

zsh

sudo aptitude install zsh
chsh
 Changing the login shell for koshikawa
 Enter the new value, or press ENTER for the default
        Login Shell [/bin/bash]: /usr/bin/zsh

vim

sudo aptitude install vim-nox

sshd

sudo vim /etc/ssh/sshd_config
Port 2222
PermitRootLogin no
PasswordAuthentication no
sudo /etc/init.d/ssh restart

update

sudo aptitude update && sudo aptitude safe-upgrade
sudo aptitude install git-core
sudo aptitude install zsh

rvm

sudo aptitude install curl
sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
sudo aptitude install gcc
sudo aptitude install automake
sudo aptitude install zlib1g-dev
rvmsudo rvm install 1.9.3-p125
rvm install ruby1.9.3-p125
rvmsudo rvm use ruby-1.9.3-p125
rvmsudo rvm gemset create work
rvmsudo rvm use ruby-1.9.3-p125@work
rvmsudo rvm alias create default ruby-1.9.3-p125@work
rvm --default use ruby-1.9.3-p125@work
sudo aptitude install build-essential bison openssl libreadline5 libreadline5-dev curl zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev

defaultの作業用ruby gemset にheroku入れておく

gem install heroku --no-ri --no-rdoc

perlbrew

curl -kL http://install.perlbrew.pl | bash
source ~/perl5/perlbrew/etc/bashrc
perlbrew install perl-5.14.2
perlbrew switch perl-5.14.2

言語設定

sudo aptitude install locale
sudo aptitude install language-pack-ja-base

nginx

sudo aptitude install python-software-properties pkg-config
sudo add-apt-repository "deb http://ppa.launchpad.net/nginx/stable/ubuntu lucid main"
sudo aptitude update
sudo aptitude install nginx
sudo cp /etc/nginx/nginx.conf .
sudo mkdir /tmp/nginx
sudo chown www-data /tmp/nginx

sysv-rc-conf

再起動時にもサービス起動させる設定

sudo aptitude install sysv-rc-conf
sudo sysv-rc-conf nginx on

usage

sysv-rc-conf --list
sysv-rc-conf [サービス名] on
sysv-rc-conf [サービス名] off

mysql

sudo aptitude install mysql-server-5.1
sudo sysv-rc-conf mysql on

my.cnf

sudo vim /etc/mysql/my.cnf
[client]
default-character-set   = utf8

[mysqld]
skip-name-resolve
default-character-set   = utf8
log-bin=/var/log/mysql/mysql-slow.log
log-bin-index=bin.index
log_slow_queries        = /var/log/mysql/mysql-slow.log
long-query-time=1
log-queries-not-using-indexes
log-slow-admin-statements

[mysqldump]
default-character-set   = utf8

[mysql]
default-character-set   = utf8

daemontools

sudo aptitude install svtools daemontools-run 
sudo reboot

java

sudo aptitude install python-software-properties
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo aptitude update
sudo aptitude install sun-java6-jdk=6.21dlj-0ubuntu1~lucid1~ppa1

union platform server

cd /usr/local/src
sudo mkdir union
cd union
sudo wget http://unionplatform.com/releases/union/union_1.1.0.tar.gz
sudo tar zxvf union_1.1.0.tar.gz
sudo mv union /usr/local/union1.1.0
cd /usr/local
sudo ln -s union1.1.0 union
cd union
sudo chmod 755 *.sh
sudo mkdir /etc/service/union
sudo vim /etc/service/union/run
#!/bin/sh
exec 2>&1
cd /usr/local/union || exit 1
exec \
java -cp lib/union.jar:lib/stax-api-1.0.1.jar:lib/wstx-asl-3.2.6.jar net.user1.union.core.UnionMain start
sudo chmod +x /etc/service/union/run

union serverの起動・再起動

sudo svc -u /etc/service/union/run
sudo svc -d /etc/service/union/run

iptables

sudo ufw status
sudo ufw enable

sudo ufw default deny incoming
sudo ufw default allow outgoing

sudo ufw reload
sudo ufw status verbose
sudo ufw status numbered

sudo ufw limit in 2222/tcp
sudo ufw allow in http/tcp
sudo ufw allow in 9110/tcp
sudo ufw allow in 9100/tcp