IK.AM

@making's tech note


お名前.com VPSセットアップメモ

🗃 {Dev/VPS/Onamae}
🗓 Updated at 2013-03-18T14:42:00Z  🗓 Created at 2013-03-18T14:42:00Z   🌎 English Page

OSでデフォルトのCentOS6.2。ユーザーはmakiを想定

ユーザー追加&SSH設定

# useradd maki
# passwd maki
# visudo

maki ALL=(ALL) ALLを追加する

# su - maki
$ mkdir .ssh
$ chmod 700 .ssh

いったんログアウト。クライアント(自分の場合はmacbook)から

$ cat .ssh/id_rsa.pub | ssh -i .ssh/vpsXXXXXXXX-001.key root@xxx.xxx.xxx.xxx 'cat - >> ~maki/.ssh/authorized_keys && chown -R maki ~maki/.ssh && chmod 600 ~maki/.ssh/authorized_keys'

vpsXXXXXXXX-001.keyは管理コンソールからダウンロードする。これでmacbookからは ssh xxx.xxx.xxx.xxxでアクセスできる。以降これでログイン

$ sudo yum install emacs
$ sudo emacs -nw /etc/ssh/sshd_config 

PasswordAuthentication noに変更。

yum設定

$ sudo yum -y install yum-priorities 
$ sudo emacs -nw /etc/yum.repos.d/CentOS-Base.repo 

baseをpriority=1に、それ以外をpriority=2に設定する。

[base]
…
priority=1

[updates]
…
priority=2

[extra]
…
priority=2

[centosplus]
…
priority=2

[contrib]
…
priotiry=2

Epel追加

$ sudo yum install wget
$ wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
$ sudo rpm -ivh epel-release-6-8.noarch.rpm
$ sudo emacs -nw /etc/yum.repos.d/epel.repo 

priorityを1にする。保守的な人はpriority=2にしましょう。

[epel]
...
priority=1

Firewall設定

80番と8080番を開けておく

$ sudo emacs -nw /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

$ sudo /etc/init.d/iptables restart

Httpdインストール

$ sudo yum install 
$ sudo chkconfig httpd on

Javaインストール

$ sudo yum install java-1.7.0-openjdk-devel

GlassFishインストール

 $ sudo yum install unzip 
 $ wget http://download.java.net/glassfish/3.1.2/release/glassfish-3.1.2.zip
 $ sudo unzip glassfish-3.1.2.zip -d /opt/
 $ sudo useradd glassfish -d /opt/glassfish3
 $ sudo chown -R glassfish /opt/glassfish3
 $ sudo su - glassfish
 $ cd glassfish/bin
 $ ./asadmin
Use "exit" to exit and "help" for online help.
asadmin> start-domain
Waiting for domain1 to start ........
Successfully started the domain : domain1
domain  Location: /opt/glassfish3/glassfish/domains/domain1
Log File: /opt/glassfish3/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
asadmin> change-admin-password
Enter admin user name [default: admin]> 
Enter admin password> 
Enter new admin password> 
Enter new admin password again> 
Command change-admin-password executed successfully.
asadmin> exit
Command multimode executed successfully.

管理画面にアクセスする際はクライアントPCから以下のようにSSHトンネリングを張って http://localhost:4848 にアクセス。

$ ssh -L 4848:localhost:4848 xxx.xxx.xxx

MongoDBインストール

$ sudo emacs -nw /etc/yum.repos.d/10gen.repo

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1
priority=1

$ sudo yum install mongo-10gen mongo-10gen-server
$ sudo chkconfig mongod on
$ sudo /etc/init.d/mongod start

Misc

$ sudo yum install lsof
$ sudo yum install git

✒️️ Edit  ⏰ History  🗑 Delete