EC2ã«Redmineï¼Apache|Passenger|HTTPSï¼
人ã«é ¼ã¾ãã¦RedmineãAWSã®EC2ä¸ã«æ§ç¯ãããã¨ã«ãªã£ãããã®è¨äºã¯ãã®ä½æ¥è¨é²ã§ããã
è¦ä»¶
- ã©ã³ãã³ã°ã³ã¹ãã¯æä½éã«æãããï¼æ¥åæéä¸ãã使ããªãã
- ãªã¬ãªã¬è¨¼ææ¸ã§è¯ããããå¹³æã®HTTPã¯ä¸åç¦æ¢ãHTTPSã®ã¿ã§ã®éç¨ã«ããã
- OSã¯Amazon Linuxããã
- ãããã¯ã¼ã¯çã«ã¯ããããªå ´æããã¢ã¯ã»ã¹ãã
ãããã
å ±é ¬
èãå¿ã¯è¸ãã財å¸ã¯è¸ããªãã
ã¤ã³ãã©ã®ç¨æ
ãã¡ã¤ã³
æ¢ã«Route53ã§éç¨ãã¦ãããã¡ã¤ã³ãåå¨ãã¦ããã®ã§ãããã®ãµããã¡ã¤ã³ã使ã£ãã
Aã¬ã³ã¼ãããå¾è¿°ã®ElasticIPã®ãã®ã«è¨å®ããã
EC2ä»®æ³ãã·ã³
éç¨ã¯t2.microã使ãã®ã ããã¡ã¢ãªã1GBãããªãã¨ãã¯å¾è¿°ã®Passengerã®ãã«ãæã«ãã¡ã¢ãªè¶³ããããコï¾ï¾ï½§ãswapã®è¨å®ãããããã¨æããã¦ããããé¢åèãã£ãè¨æ¶ããã£ãã®ã§ããããªã®ã¯éã§è§£æ±ºãããæ§ç¯ä¸ã¯t2.smallã¤ã³ã¹ã¿ã³ã¹ã使ããæ§ç¯ãçµãã£ããt2.microã«åãæ¿ããã
ãæ¥åæéä¸ãã使ããªããã¨ãããã¨ã§ãã£ãããäºç®ã®é½åã§ELB使ããªããè¤éãªãã¨ã¯ããããªãï¼å ±é
¬ãå°ãªãï¼ï¼ã®ã§ãEC2ã¤ã³ã¹ã¿ã³ã¹èµ·åãã度ã«PublicIPã¢ãã¬ã¹ãRoute53ã«ç»é²ãããããªæ§æã¯åãããElasticIPã使ãã
ãã£ããã¨
- ElasticIP 1ååå¾
- t2.small ã¤ã³ã¹ã¿ã³ã¹
- Amazon Linux
- Security Groupã¯ãsshãå¶éä»ãã§è¨±å¯ãHTTPSãã©ãããã§ã許å¯ãã¨ããæãã®ãç¨æã
- IAM Role ã¯ãä¾ãã°ããã¯ã¢ãããS3ã«ç½®ãããã£ã¦ãã¨ãèãããããã©ä»ã¯ããã¾ã§è¨è¨ããã®é¢åãããã®ã§ãä¸å¿ç©ºã£ã½ã®ãã®ãä»ãã¨ããèµ·åããå¾ã«Roleè¨å®ãããã¨ã¯é常ã«é¢åèããã©ãæ¢åã®Roleã«æ¨©é追å ããã®ã¯ç°¡åãªã®ã§ã
- ã¹ãã¬ã¼ã¸ã¯ããã©ã«ãã®8GBã§æ§ç¯ãããããå°ãã容éã ã¨GP-SSDããã¯Magneticã®æ¹ãè¯ãæ°ããã¦ãã®ã§Magneticã§æ§ç¯ãï¼å®¹éå°ãªãã¨ãã®GP-SSDã®ãã³ãã誰ãåã£ã¦ãªãããªã¼ï¼ï¼
- root ã¦ã¼ã¶ã«ãªãï¼
$ sudo su -
# yum update
/etc/sysconfig/network
ãããã£ã¦ãã¹ãåãè¨å®- æ°ã«ãªããªãOSåèµ·å
MySQLã®ç¨æ
MySQL 5.6 ã¯ãAmazon Linuxãããã©ã«ãã§æä¾ãã¦ãããªãã¸ããªã®ä¸ã§ã¯ææ°çãä¸ã®ä¸ã¯5.7ã®è©±é¡ã§æã¡ããã ãã©ãããã¯5.6ã使ããï¼5.7ã¯è½ã¨ãç©´ãä¸æ¯ãããâ¦ï¼
# yum install mysql56-server
ããã¦èµ·åã
# service mysqld start
ååèµ·åæã¯ããããè¨å®ãããããããã°ãããããã§ãããã®ä¸ã«ãç¹æ¨©ã¦ã¼ã¶ã®ãã¹ã¯ã¼ããè¨å®ãããï¼ãã¨ããã¡ãã»ã¼ã¸ãå± ãã®ã§è¦éããã«è¨å®ããã
# /usr/libexec/mysql56/mysqladmin -u root password 'new-password'
Apacheã®ç¨æ
# yum install httpd24 mod24_ssl
ãªã¬ãªã¬è¨¼ææ¸
- 100年使ããï¼ç¬ï¼è¨¼ææ¸
- ç§å¯éµã¯æå·åããªãï¼ãã¹ãã¬ã¼ãºè¨å®ããªãï¼
ã¨ããæ¦ç¥ãåããå®å ¨ã«äºç®ã®é½åã§ããã
# cd /etc/httpd # mkdir ssl # cd ssl # openssl genrsa 2048 > server.key # openssl req -new -key server.key > server.csr â»ããã§ãç½²åè¦æ±ã«è¨è¼ããäºé ã®å ¥åã対話åã§æ±ãããããCNï¼Common Nameï¼ã¯ãäºåã«ç¨æãã¦ããããã¡ã¤ã³ãæãããã«ããã # openssl x509 -days 36500 -req -signkey server.key < server.csr > server.crt # chmod 400 server.key
æå¾ã®ç§å¯éµã®æ¨©éè¨å®ã¯ãæ°è»½ãªé¯ã ã£ãããããªãã¦ãè¯ããã¨ããæ°ãããããæãåæã«æã¡è¾¼ãã
証ææ¸ã®ç¨æãã§ããããApacheã«ãããé£ãããã
ç§å¯éµã®çµ¶å¯¾ãã¹ã¯ /etc/httpd/ssl/server.key
ã«ãªã£ã¦ãã¦ã証ææ¸ã®çµ¶å¯¾ãã¹ã¯ /etc/httpd/ssl/server.crt
ã«ãªã£ã¦ããã¯ããªã®ã§ããããã®æ
å ±ã /etc/httpd/conf.d/ssl.conf
ã«æ¸ãè¾¼ãããã®ãã¡ã¤ã«å
ã®ã©ãã«æ¸ãããè¯ãã®ãã£ã¦ã®ã¯ãã®ãã¡ã¤ã«ã®ä¸èº«ãè¦ãã°ãããã¯ãã ã
ããã¾ã§ã§ããã°ã # service httpd start
ã§Apacheãèµ·åãã¦HTTPSã®åä½ç¢ºèªãã§ããã¯ãã ã
OSèµ·åè¨å®
OSãèµ·åããã¨ãã«ãMySQLã¨Apacheãèµ·åããããã«ãã¦ããã
# chkconfig --level 345 mysqld on # chkconfig --level 345 httpd on
Redmineã®ç¨æ
ãã¦ããããããæ¬çªã§ãããåºæ¬çã«ã¯å
¬å¼ã®ããã¥ã¢ã« http://www.redmine.org/projects/redmine/wiki/RedmineInstall ã«æ²¿ããã¨ã«ãªãã
å人çã«rubyãåãæ±ãã¨ãã«ãã¤ãæ©ãã®ããgemãã©ã®ã¦ã¼ã¶ã®ã¨ããã«ã¤ã³ã¹ãã¼ã«ãããã®ãã¨ããã¨ãããä»åã¯Redmineã®å°ç¨é¯ã«ãªãã®ã§rootã¦ã¼ã¶ã«ä»è¾¼ãããã¨ãèããããããµã«ãªã大éã«é£ãã§ããå¯è½æ§ããã訳ã§ããã¯ã redmine
ã¨ããåã®å°ç¨ã®ã¦ã¼ã¶ãç¨æããã
以ä¸ã#
ã¯root権éã$
ã¯redmine権éã§ã®ã³ãã³ãå®è¡ã§ããã
ã¦ã¼ã¶ã®ç¨æ
# useradd redmine
以å¾ã®æä½ã¯åºæ¬çã« redmine ã¦ã¼ã¶ã§å®æ½ããã # su - redmine
ã§æããããã
ãã¼ã¸ã§ã³ã®é¸å®ã¨å ¥æï¼å ¬å¼ããã¥ã¢ã«ã®Step1ã«ç¸å½
å人çãªããªã·ã¼ã¨ãã¦ãæ§ç¯æã®ææ°ã® stable ãªãªã¼ã¹ã®ãã®ã使ãããã¨ã«ãã¦ããããã®è¨äºã®å·çæç¹ã§ã¯ Redmine 3.1.1 ãããã«è©²å½ããããã®è¨äºã®å·çæç¹ã§ã®AmazonLinuxããã©ã«ãã®Rubyã®ãã¼ã¸ã§ã³ã¯åä½ã§ãã Ruby ã®ãã¼ã¸ã§ã³ã¯2.0.0ã§ãããããã㯠Redmine 3.1.1ãåä½å¯è½ãªãã¼ã¸ã§ã³ã§ããããã ããã®ã¾ã¾3.1.1使ãããã¦ã³ãã¼ããã¼ã¸ http://www.redmine.org/projects/redmine/wiki/Download ããå¿ è¦ãªã¢ã¼ã«ã¤ãã®ãªã³ã¯ãã³ãã£ã¦ãwgetã¨ãã§ãã¦ã³ãã¼ãï¼
$ cd ~ $ wget http://www.redmine.org/releases/redmine-3.1.1.tar.gz $ md5sum redmine-3.1.1.tar.gz ï¼ä¸å¿ç¢ºèªãã¨ãï¼ $ tar -zxf redmine-3.1.1.tar.gz
ãã®çµæãredmineã¦ã¼ã¶ã® ~/redmine-3.1.1
ã«ãã£ã¬ã¯ããªãã§ãã¦ãã®ã§ãããã«å
¥ã£ã¦ããã
DBã®ç¨æï¼å ¬å¼ããã¥ã¢ã«ã®Step2ã«ç¸å½
é¢åèããããMySQLã®rootã¦ã¼ã¶ã§æ¥ç¶ããããã ããã¦ã¼ã¶ã¯ä½ããªãã
$ mysql -h localhost -u root -p
ã§æ¥ç¶ãã¦ã
CREATE DATABASE redmine CHARACTER SET utf8;
ã§DBä½æãçµãã£ãã quit
DBæ¥ç¶è¨å®ï¼å ¬å¼ããã¥ã¢ã«ã®Step3ã«ç¸å½
config/database.yml.example
ã config/database.yml
ã«ã³ãã£ã¦ä½¿ãã¨å
¬å¼ããã¥ã¢ã«ãè¨ã£ã¦ããããã®ã§ãç´ ç´ã«ããã«å¾ããè¨å®å
容ãããã¥ã¢ã«ã«å¾ããããã¾ã§ä½ã£ã¦ããDBã®ç°å¢ã®ãã¨ãæãåºããªããã
å¿ è¦ãªgemã®ã¤ã³ã¹ãã¼ã«ï¼å ¬å¼ããã¥ã¢ã«ã®Step4ã«ç¸å½
ã©ãããããããã®ã³ãã³ããå®è¡ããã¨ãã®ä½æ¥ãã£ã¬ã¯ããªã¯å¤§äºã§ããããã ãGemfileãè¦ãã¦ããå ´æã§ã£ã¦ã®ã大äºãªãã ããããã£ã¨ã
$ gem install bundler $ bundle install --without development test
ãã®ï¼åç®ã® bundle ã³ãã³ããåããã¨ãâ¯â¯ãããã¾ãããã¿ãããªã¨ã©ã¼ãåºã¦æ¢ã¾ããRedmineã¤ã³ã¹ãã¼ã«ã®é£é¢ãã®ï¼ã§ããã
ã¨ã©ã¼ã¡ãã»ã¼ã¸ã«å¾ã£ã¦å¿
è¦ãªãã®ãã¤ã³ã¹ãã¼ã«ãããããã§ä½ãå¿
è¦ãªã®ãï¼ã調ã¹ãã®ããRedmineï¼ã¨ãããrubyï¼ã®ãã©ãã¨ããã ã¨æã£ã¦ããã¾ãrubyåå¿è
ã®æ¯è¨ã§ã¯ãããã
# yum install ruby-devel rubygem20-io-console gcc zlib zlib-devel patch mysql56-devel ImageMagick ImageMagick-devel
ãã®yumã®ãã¨ãã¾ã redmine ã¦ã¼ã¶ã«æ»ã£ã¦ããã£ã¬ã¯ããªãééããã« bundle install
ããã°è¯ãã
ãã¹ã¯ã¼ãçæï¼å ¬å¼ããã¥ã¢ã«ã®Step5ã«ç¸å½
Redmineã®ãã¼ã¸ã§ã³ã«ãã£ã¦æµãã¹ãã³ãã³ããç°ãªãã1.4.x 㨠2.x ã«ã¯æ¡å ããããã3.x ã®æ¡å ã¯ç¡ããããã§ã¯ 2.x ã®ã¬ã¤ãã«å¾ãã
$ bundle exec rake generate_secret_token
ãã¼ãã«æ§ç¯ï¼å ¬å¼ããã¥ã¢ã«ã®Step6ã«ç¸å½
ããã§ä¸çºãåè¿°ã®DBæ¥ç¶è¨å®ããã¹ã£ã¦ãã¨æ»ã¬ã
$ RAILS_ENV=production bundle exec rake db:migrate
åæå¤æå ¥ï¼å ¬å¼ããã¥ã¢ã«ã®Step7ã«ç¸å½
ãã¼ãã«æ§ç¯ãæåãã¦ãããã¾ãè¡ãã
$ RAILS_ENV=production bundle exec rake redmine:load_default_data
ã©ã®è¨èªï¼ã£ã¦èãããã®ã§ãè±èªããããã°ãã®ã¾ã¾return, æ¥æ¬èªãè¯ããã° ja æå®ã ã
ãã¡ã¤ã«æ¨©éè¨å®ï¼å ¬å¼ããã¥ã¢ã«ã®Step8ã«ç¸å½
ããã§èªããã¨ã¯ä½ããªããå ¬å¼ããã¥ã¢ã«éãã
chmod 777 files chmod 777 log chmod 777 tmp chmod 777 tmp/pdf chmod 777 public/plugin_assets
ã§çµããã¨è¡ãããã¨ããã§ããããããã¾ã§ã®æé ã«æ²¿ã㨠redmine ã¦ã¼ã¶ã®ãã¼ã ãã£ã¬ã¯ããªå
ã«ç½®ãã¦ããredmineã®ãã¡ã¤ã«ç¾¤ã«Apacheã®ããã»ã¹ã辿ãçããªãããããã£ã¡ã chmod 755 ~
ãæµãå¿
è¦ãæãã
â»æ¬å½ãªã /var/
ã®ä¸ã ã£ãã /usr/local/
ã®ä¸ã ã£ããã«ç½®ãã®ãçæ³çãªãã ãããã§ãå°ç¨é¯ãªã®ã§å¤§ç®ã«è¦ãã
Webrickã§ã®åä½ç¢ºèªï¼å ¬å¼ããã¥ã¢ã«ã®Step9ã«ç¸å½
SecurityGroupã§HTTPã®ãã¼ãéããã®é¢åèããããã¹ãåæãã¹ã¯ã¼ããã¤ã³ã¿ã¼ãããä¸ã«å¹³æã§æµãã®ãå«ã ãã
Passengerã®ç¨æ
ã¾ãã¯gemã®ã¤ã³ã¹ãã¼ã«ã
$ gem install passenger
ããã¯ãããªãè¡ãã
次ã«ãApacheã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã
$ passenger-install-apache2-module
ã§ãã¾ã足ããªããã®ãã¤ã³ã¹ãã¼ã«ããå¿ è¦ã«è¿«ãããã
# yum install gcc-c++ libcurl-devel httpd24-devel apr-devel apr-util-devel
å度ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã«ã試ã¿ãã¨ããã«ããå§ã¾ããã¡ã¢ãªè¶³ããªããã·ã³ä½¿ã£ã¦ãã¨ããã§æãããã
æ°åå¾
ã¤ã¨ãApacheã®è¨å®ãã¡ã¤ã«æ¸ãæãããã£ã¦ããã¡ãã»ã¼ã¸ãåºã¦ããã®ã§ãããã«å¾ãããããã¡ãã£ã¨é¢åã§ãããä¸ã¤ã®ã»ãã·ã§ã³ã§sshã¤ãªãå¿
è¦ããããæ¥ç¶ã§ãããroot権é㧠/etc/httpd/conf.d/
ã« redmine.conf
ã¨ãè¨ã£ã¦æ¸ãè¾¼ããå¥ã»ãã·ã§ã³ã®æ¹ã¯ããã§ä»»åå®äºã§ããããæ¥ç¶ãæ®ãã¦ããã®ãè¯ãã
DocumentRoot ã®è¨å®
ãããRedmineã®ã¤ã³ã¹ãã¼ã«ãã£ã¬ã¯ããªã /home/redmine/redmine-3.1.1/
ã§ãããªãã°ãè¨å®ãã¹ãDocumentRoot㯠/home/redmine/redmine-3.1.1/public
ã«ãªãã
ããã¯Apacheã®è¨å®ãã¡ã¤ã« /etc/httpd/conf/httpd.conf
ã«ç´æ¥æ¸ãè¾¼ããä¸ç·ã«ãã£ã¬ã¯ããªã®è¨å®ããã¦ãã¾ãã
DocumentRoot "/home/redmine/redmine-3.1.1/public" <Directory "/home/redmine/redmine-3.1.1/public"> AllowOverride None Require all granted </Directory>
ããã¾ã§ã§ãããã # service httpd restart
ããã°Redmineã使ããããã«ãªã£ã¦ããã¯ãã ãåæãã¹ã¯ã¼ããªã©ã¯å
¬å¼ã®ããã¥ã¢ã«ã«æ¸ãã¦ããã®ã§ããã¨ã¯å¥½ãã«ãããè¯ãã ããã
å®æçããã¯ã¢ããã¯ãã¾ãæãªã¨ãã«ããï¼ãã¶ãè¨äºã«ã¯ããªãï¼ãè¨å®ããIAM Roleããã£ã¨å½¹ã«ç«ã¤ã¯ãã ã
ã¤ã³ã¹ã¿ã³ã¹ã¿ã¤ã
ãã¨ãã¨t2.smallã使ã£ã¦ãçç±ã¯Passengerã®Apacheã¢ã¸ã¥ã¼ã«ã®ãã«ãã«ã¡ã¢ãªãå¿ è¦ã ã£ããããã§ããã稼å確èªã§ãããããt2.smallã§ããå¿ è¦ã¯ãªãã¦ãt2.microã«åãæ¿ãã¦è¯ãã