
今回設定する内容
- Server: serversman@vps
- OS: CentOS 6.4
- MySQL 5.6.14
- Ruby 1.9.3
- Redmine 2.4
- Gitlab 6.4
目次
- サーバー初期設定 a. SSL設定 b. ユーザー作成 c. 必要なソフトウェアインストール
- MySQL5.6.14インストール
- Ruby1.9.3インストール
- Redmine2.4インストール
- Gitlab6.4インストール
1.サーバー初期設定
a.SSL設定
Rootログインを不可にする。
1 2 |
$ echo "PermitRootLogin no" >> /etc/ssh/sshd_config $ /etc/init.d/sshd restart |
b.ユーザー作成
adminユーザーを作成してSudo権限を与える。
1 2 3 4 5 6 7 8 9 |
$ useradd -m admin $ passwd admin (任意のパスワード設定) // グループにapacheを追加 $ usermod -G apache admin // Sudo設定 $ sudo visudo admin ALL=(ALL) ALL $ chmod 775 /home/admin/ |
2.ライブラリインストール
最低限必要なライブラリを予めインストールしておく。
1 2 3 4 5 6 7 8 |
// epelパッケージをインストール $ mkdir ~/sources $ cd ~/sources $ wget http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm $ rpm -ivh epel-release-6-8.noarch.rpm // 必要なライブラリを一括インストール $ yum install -y --enablerepo=epel make gcc gcc-c++ curl curl-devel gcc gcc-c++ git openssl-devel httpd-devel readline-devel zlib-devel libffi-devel install libyaml-devel |
4.MySQL5.6.14インストール
MySQLはRPMパッケージから最新版をインスートルする。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$ yum -y localinstall http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-shared-compat-5.6.14-1.el6.x86_64.rpm $ yum -y localinstall http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-shared-5.6.14-1.el6.x86_64.rpm \ http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.14-1.el6.x86_64.rpm \ http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.14-1.el6.x86_64.rpm \ http://cdn.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.14-1.el6.x86_64.rpm $ chkconfig mysql on $ vim /etc/my.cnf (以下の内容を記述) [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql symbolic-links=0 character-set-server=utf8 innodb_file_per_table query-cache-size=16M [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [mysql] default-character-set=utf8 // MySQL起動。MySQLルートユーザーのパスワード設定 $ /etc/init.d/mysql start Starting MySQL... SUCCESS! // MySQLパスワード設定 (5.6からデフォルトでパスワードなしでログイン不可になった) $ cat /root/.mysql_secret The random password set for the root user at Fri Dec 27 07:08:23 2013 (local time): {初期パスワード} $ mysql -u root -p (パスワードを聞かれるので初期パスワードを入力) > SET PASSWORD FOR root@localhost=PASSWORD(''); // パスワードを空する場合 > exit |
Rubyインストール
RubyはRVMを用いてインストール。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// RVMをインストール $ curl -sSL https://get.rvm.io | bash -s stable $ echo "source /etc/profile.d/rvm.sh" >> ~/.bash_profile $ source ~/.bash_profile // ruby1.9.3をインストール $ rvm list known (インストール可能にRuby一覧を確認) $ rvm install 1.9.3 $ rvm gemset create rails3 $ rvm use --default 1.9.3@rails3 // 必要なGEMパッケージインストール $ gem install --no-rdoc --no-ri activesupport therubyracer |
Passengerのインストール設定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// Passengerのインストール $ gem install passenger --no-rdoc --no-ri $ passenger-install-apache2-module $ vim /etc/httpd/conf.d/passenger.conf (下記入力) LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p484@rails3/gems/passenger-4.0.29/buildout/apache2/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p484@rails3/gems/passenger-4.0.29 PassengerDefaultRuby /usr/local/rvm/wrappers/ruby-1.9.3-p484@rails3/ruby // サーバーネーム設定 $ echo "ServerName {あなたのドメイン名}" >> /etc/httpd/conf/httpd.conf // バーチャルホストを有効にする。 $ echo "NameVirtualHost *:80" >> /etc/httpd/conf/httpd.conf // Apacheサーバー再起動 $ /etc/init.d/httpd restart |
gitlab6.4インストール
gitlabのインストールを行います。gitlabのインストール&設定はgitlabユーザーで行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
// Redisインストール $ yum install -y --enablerepo=epel redis $ /etc/init.d/redis start $ chkconfig redis on $ yum install libxml2-devel libxslt-devel $ yum --enablerepo=epel -y install libicu-devel libxml2 libxml2-devel $ gem install charlock_holmes --version '0.6.9' --with-icu-dir/usr/share/icu/4.2.1/ --no-rdoc --no-ri $ gem install --no-ri --no-rdoc bundler // Gitユーザー作成 $ useradd -c 'gitlab' -s /bin/bash git $ chmod 755 /home/git $ su - git gitlab$ cd /home/git gitlab$ mkdir .ssh gitlab$ touch .ssh/authorized_keys gitlab$ chmod 600 .ssh/authorized_keys gitlab$ chmod 700 .ssh gitlab$ git config --global user.name "gitlab" gitlab$ git config --global user.email "gitlab@localhost" // Gitlab-shellをインストール gitlab$ git clone https://github.com/gitlabhq/gitlab-shell.git gitlab$ cd gitlab-shell/ gitlab$ git checkout v1.8.0 gitlab$ git checkout -b v1.8.0 gitlab$ cp config.yml.example config.yml gitlab$ vi config.yml (下記のgitlab_urlを自分のドメインに変更する) gitlab_url: "http://gitlab.hogehoge.com/" gitlab$ ./bin/install // gitlab用のMYSQLデータベース作成 gitlab$ sudo mysql -u root -p -e "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci" gitlab$ sudo mysql -u root -p -e 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON gitlabhq_production.* TO "gitlab"@"localhost" identified by "gitpass"' // Gitlabインストール gitlab$ cd /home/git/ gitlab$ git clone https://github.com/gitlabhq/gitlabhq.git gitlab gitlab$ cd gitlab gitlab$ git checkout 6-4-stable gitlab$ cp config/gitlab.yml.example config/gitlab.yml gitlab$ vim config/gitlab.yml host: gitlab.hogehoge.com bin_path: /usr/local/bin/git gitlab$ chown -R git log/ gitlab$ chown -R git tmp/ gitlab$ chmod -R u+rwX log/ gitlab$ chmod -R u+rwX tmp/ gitlab$ mkdir /home/git/gitlab-satellites gitlab$ mkdir tmp/pids/ gitlab$ chmod -R u+rwX tmp/pids/ gitlab$ cp config/database.yml.mysql config/database.yml gitlab$ vim config/database.yml username: gitlab password: "gitpass" gitlab$ bundle install --deployment --without development test postgres gitlab$ bundle exec rake gitlab:setup RAILS_ENV=production login.........admin@local.host password......5iveL!fe gitlab$ bundle exec rake gitlab:env:info RAILS_ENV=production gitlab$ bundle exec rake gitlab:check RAILS_ENV=production gitlab$ su - $ curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab-centos $ chmod +x /etc/init.d/gitlab $ vi /etc/init.d/gitlab (下記の部分を修正) - NAME=gitlab + NAME=gitlab $ chkconfig gitlab on $ /etc/init.d/gitlab start |
Redmine2.4.2インストール
gitlab同様、まずはredmineユーザーを作成してインストール作業を行います。redmineのほうがgitlabよりも早く簡単にインストールできると思います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
// 必要なソフトウェア(ImageMagickをインストール) $ yum install -y --enablerepo=epel ImageMagick-devel ImageMagick unzip // redmineユーザー作成 $ useradd -m redmine $ passwd redmine (任意のパスワード) $ chmod 755 /home/redmine $ sudo visudo redmine ALL=(ALL) ALL $ su - redmine // Redmineダウンロード redmine$ mkdir ~/www redmine$ cd ~/www redmine$ wget http://www.redmine.org/releases/redmine-2.4.2.zip redmine$ unzip redmine-2.4.2.zip redmine$ cd redmine-2.4.2 // Remine用のデータベース作成 redmine$ sudo mysql -u root -e "create database redmine character set utf8;" // Config設定 redmine$ vim config/database.yml (下記を入力) production: adapter: mysql2 database: redmine host: localhost username: root password: encoding: utf8 // メールの設定 (Gmailを利用する場合) redmine$ vim config/configuration.yml (下記を入力) production: email_delivery: delivery_method: :smtp smtp_settings: enable_starttls_auto: true address: "smtp.gmail.com" port: '587' domain: "smtp.gmail.com" authentication: :plain user_name: "yourusername@gmail.com" password: "yourpassword" // Redmineに必要なパッケージをインストール。 redmine$ rvmsudo bundle install --without development test postgresql sqlite redmine$ bundle exec rake generate_secret_token redmine$ RAILS_ENV=production bundle exec rake db:migrate // Apacheの設定 redmine$ sudo vim /etc/httpd/conf.d/redmine.conf (下記を入力) <VirtualHost *:80> ServerName {あなたのドメイン} DocumentRoot "/home/redmine/www/redmine-2.4.2/public" |~ ErrorLog "logs/redmine-error_log" |~ CustomLog "logs/redmine-access_log" combined </VirtualHost> // Apache再起動 redmine$ sudo /etc/init.d/httpd restart |
サイトにアクセスして下記のページが表示されれば完了。初期アカウントでログイン:admin、パスワード:adminでログインできる。
Unix Bench
ServersManのUnixBenchはネット上で色々公表されているが、 一応、入れて測定してみる。まぁやはり月額490相応の結果でした。。 (少しは改善されたかなと淡い期待をしていましたが・・)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// Perlのモジュールが無いと怒られるので、予めインストール。 $ yum -y install perl-devel perl-CPAN $ perl -MCPAN -e shell > install Time::HiRes > exit // UnixBenchのインストール。 $ cd ~/sources $ wget https://byte-unixbench.googlecode.com/files/UnixBench5.1.3.tgz $ tar xvf UnixBench5.1.3.tgz $ cd UnixBench $ make $ ./Run |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
------------------------------------------------------------------------ Benchmark Run: Mon Jan 06 2014 20:23:51 - 20:54:42 2 CPUs in system; running 1 parallel copy of tests Dhrystone 2 using register variables 5325204.6 lps (10.0 s, 7 samples) Double-Precision Whetstone 1826.7 MWIPS (10.0 s, 7 samples) Execl Throughput 953.7 lps (29.9 s, 2 samples) File Copy 1024 bufsize 2000 maxblocks 129328.7 KBps (30.0 s, 2 samples) File Copy 256 bufsize 500 maxblocks 39478.7 KBps (30.0 s, 2 samples) File Copy 4096 bufsize 8000 maxblocks 309127.0 KBps (30.0 s, 2 samples) Pipe Throughput 404757.2 lps (10.0 s, 7 samples) Pipe-based Context Switching 56490.2 lps (10.0 s, 7 samples) Process Creation 2350.7 lps (30.0 s, 2 samples) Shell Scripts (1 concurrent) 932.2 lpm (60.0 s, 2 samples) Shell Scripts (8 concurrent) 121.3 lpm (60.1 s, 2 samples) System Call Overhead 756429.7 lps (10.0 s, 7 samples) System Benchmarks Index Values BASELINE RESULT INDEX Dhrystone 2 using register variables 116700.0 5325204.6 456.3 Double-Precision Whetstone 55.0 1826.7 332.1 Execl Throughput 43.0 953.7 221.8 File Copy 1024 bufsize 2000 maxblocks 3960.0 129328.7 326.6 File Copy 256 bufsize 500 maxblocks 1655.0 39478.7 238.5 File Copy 4096 bufsize 8000 maxblocks 5800.0 309127.0 533.0 Pipe Throughput 12440.0 404757.2 325.4 Pipe-based Context Switching 4000.0 56490.2 141.2 Process Creation 126.0 2350.7 186.6 Shell Scripts (1 concurrent) 42.4 932.2 219.9 Shell Scripts (8 concurrent) 6.0 121.3 202.1 System Call Overhead 15000.0 756429.7 504.3 ======== System Benchmarks Index Score 283.4 ------------------------------------------------------------------------ Benchmark Run: Mon Jan 06 2014 20:54:42 - 21:31:22 2 CPUs in system; running 2 parallel copies of tests Dhrystone 2 using register variables 5082736.6 lps (10.0 s, 7 samples) Double-Precision Whetstone 3567.7 MWIPS (10.0 s, 7 samples) Execl Throughput 926.8 lps (29.8 s, 2 samples) File Copy 1024 bufsize 2000 maxblocks 120027.2 KBps (30.0 s, 2 samples) File Copy 256 bufsize 500 maxblocks 35244.9 KBps (30.0 s, 2 samples) File Copy 4096 bufsize 8000 maxblocks 162107.8 KBps (30.0 s, 2 samples) Pipe Throughput 304018.4 lps (10.0 s, 7 samples) Pipe-based Context Switching 34171.4 lps (10.1 s, 7 samples) Process Creation 1957.7 lps (30.0 s, 2 samples) Shell Scripts (1 concurrent) 976.2 lpm (60.1 s, 2 samples) Shell Scripts (8 concurrent) 127.9 lpm (60.0 s, 2 samples) System Call Overhead 735510.6 lps (10.0 s, 7 samples) System Benchmarks Index Values BASELINE RESULT INDEX Dhrystone 2 using register variables 116700.0 5082736.6 435.5 Double-Precision Whetstone 55.0 3567.7 648.7 Execl Throughput 43.0 926.8 215.5 File Copy 1024 bufsize 2000 maxblocks 3960.0 120027.2 303.1 File Copy 256 bufsize 500 maxblocks 1655.0 35244.9 213.0 File Copy 4096 bufsize 8000 maxblocks 5800.0 162107.8 279.5 Pipe Throughput 12440.0 304018.4 244.4 Pipe-based Context Switching 4000.0 34171.4 85.4 Process Creation 126.0 1957.7 155.4 Shell Scripts (1 concurrent) 42.4 976.2 230.2 Shell Scripts (8 concurrent) 6.0 127.9 213.2 System Call Overhead 15000.0 735510.6 490.3 ======== System Benchmarks Index Score 257.7 |
参考
以下、各公式サイト&参考にしたサイトです。