Advertisement
IchHabRecht

[BASH] Install CI-Server (CentOS 6.5)

Jan 9th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.85 KB | None | 0 0
  1. # Install Ruby
  2. yum install nano libyaml wget gcc libyaml-devel zlib-devel openssl openssl-devel libicu-devel patch gcc-c++ cmake readline-devel
  3. cd /root/
  4. mkdir downloads
  5. cd downloads/
  6. wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p598.tar.gz
  7. tar -xzvf ruby-2.0.0-p598.tar.gz
  8. cd ruby-2.0.0-p598
  9. ./configure
  10. make && make install
  11.  
  12. # Install MySQL
  13. yum install mysql-server mysql-devel
  14. service mysqld start
  15. chkconfig mysqld on
  16. /usr/bin/mysqladmin -u root password 'root'
  17.  
  18. # Install Apache HTTP Server
  19. yum install httpd
  20. service httpd start
  21. chkconfig httpd on
  22.  
  23. # Install Redmine
  24. mkdir /var/www/vhosts
  25. mkdir /var/www/vhosts/redmine
  26. cd /root/downloads/
  27. wget http://www.redmine.org/releases/redmine-2.3.3.tar.gz
  28. tar -xzvf redmine-2.3.3.tar.gz
  29. mysql -u root -p
  30. >>CREATE DATABASE redmine CHARACTER SET utf8;
  31. >>CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine';
  32. >>GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
  33. cp -a redmine-2.3.3/* /var/www/vhosts/redmine/
  34. chown -R root:apache /var/www/vhosts/redmine/
  35. cd /var/www/vhosts/redmine/
  36. cp config/database.yml.example config/database.yml
  37. nano config/database.yml
  38. >>production:
  39.   adapter: mysql2
  40.   database: redmine
  41.   host: localhost
  42.   username: redmine
  43.   password: redmine
  44. gem install bundler
  45. bundle install --without development test rmagick
  46. rake generate_secret_token
  47. RAILS_ENV=production rake db:migrate
  48. RAILS_ENV=production rake redmine:load_default_data
  49.  
  50. # Test Redmine
  51. ruby script/rails server webrick -e production
  52.  
  53. # Create Redmine service
  54. nano /etc/init.d/redmine
  55. >>[see http://pastebin.com/aDCnD57d]
  56. service redmine start
  57. chkconfig redmine on
  58.  
  59. # Link Apache and Redmine
  60. nano /etc/httpd/conf/httpd.conf
  61. >>#
  62.   # Use name-based virtual hosting.
  63.   #
  64.   NameVirtualHost *:80
  65.   Include /etc/httpd/sites-enabled/
  66. nano /etc/hosts
  67. >>127.0.0.1 redmine.vm
  68. cd /etc/httpd/
  69. mkdir sites-available && mkdir sites-enabled
  70. nano sites-available/redmine.vm
  71. >><VirtualHost *:80>
  72.         ServerName redmine.vm
  73.         DocumentRoot /var/www/vhosts/redmine
  74.  
  75.         ProxyRequests Off
  76.         ProxyPass / http://127.0.0.1:3000/ retry=0
  77.         ProxyPassReverse / http://127.0.0.1:3000/
  78.  
  79.         LogLevel warn
  80.         ErrorLog /var/log/httpd/redmine_error.log
  81.         CustomLog /var/log/httpd/redmine_access.log combined
  82.  
  83.         <Directory /var/www/vhosts/redmine>
  84.                 Options Indexes FollowSymLinks MultiViews
  85.                 AllowOverride None
  86.                 Order allow,deny
  87.                 allow from all
  88.         </Directory>
  89. </VirtualHost>
  90. ln -s /etc/httpd/sites-available/redmine.vm /etc/httpd/sites-enabled/redmine.vm
  91. /usr/sbin/setsebool -P httpd_can_network_connect true
  92. service httpd restart
  93. iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
  94. service iptables save
  95.  
  96. # Install Redis
  97. cd /root/downloads/
  98. wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  99. rpm -Uvh epel-release-6-8.noarch.rpm
  100. yum install redis
  101. nano /etc/redis.conf
  102. >>unixsocket /var/run/redis/redis.sock
  103.   unixsocketperm 0775
  104. service redis start
  105. chkconfig redis on
  106.  
  107. # Install GitLab
  108. yum install git
  109. adduser --shell /bin/bash --home-dir /home/git/ git
  110. usermod -aG redis git
  111. nano /etc/sudoers
  112. >>Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  113. mysql -u root -p
  114. >>CREATE USER 'git'@'localhost' IDENTIFIED BY 'git';
  115. >>CREATE DATABASE `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
  116. >>GRANT ALL ON `gitlabhq_production`.* TO 'git'@'localhost';
  117. cd /home/git/
  118. sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b v7.2.1 gitlab
  119. cd /home/git/gitlab
  120. sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
  121. sudo -u git -H nano config/gitlab.yml
  122. >>host: gitlab.vm
  123. >>email_from: admin@gitlab.vm
  124. chmod -R u+rwX log/
  125. chmod -R u+rwX tmp && chmod -R u+rwX public/uploads
  126. sudo -u git -H mkdir /home/git/gitlab-satellites && chmod 750 /home/git/gitlab-satellites
  127. sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
  128. sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
  129. sudo -u git -H cp config/resque.yml.example config/resque.yml
  130. sudo -u git -H cp config/database.yml.mysql config/database.yml
  131. sudo -u git -H nano config/database.yml
  132. >>production:
  133.     adapter: mysql2
  134.     encoding: utf8
  135.     reconnect: false
  136.     database: gitlabhq_production
  137.     pool: 10
  138.     username: git
  139.     password: "git"
  140. sudo -u git -H chmod o-rwx config/database.yml
  141. sudo -u git -H bundle install --deployment --without development test postgres aws
  142. sudo -u git -H bundle exec rake gitlab:shell:install[v2.1.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production
  143. restorecon -Rv /home/git/.ssh
  144. sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=5iveL\!fe
  145. cd ../gitlab-shell
  146. sudo -u git -H nano config.yml
  147. >>redis:
  148.   bin: /usr/bin/redis-cli
  149.   host: 127.0.0.1
  150.   port: 6379
  151.  
  152. # Create GitLab service
  153. wget -O /etc/init.d/gitlab https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn
  154. chmod +x /etc/init.d/gitlab
  155. chkconfig --add gitlab
  156. service gitlab start
  157. chkconfig gitlab on
  158.  
  159. # Link Apache and GitLab
  160. nano /etc/hosts
  161. >>127.0.0.1 gitlab.vm
  162. cd /etc/httpd/
  163. nano sites-available/gitlab.vm
  164. >><VirtualHost *:80>
  165.         ServerName gitlab.vm
  166.         DocumentRoot /home/git/gitlab/public
  167.  
  168.         ProxyRequests Off
  169.         ProxyPreserveHost On
  170.         ProxyPass / http://127.0.0.1:8080/ retry=0
  171.         ProxyPassReverse / http://127.0.0.1:8080/
  172.  
  173.         LogLevel warn
  174.         ErrorLog /var/log/httpd/gitlab_error.log
  175.         CustomLog /var/log/httpd/gitlab_access.log combined
  176. </VirtualHost>
  177. ln -s /etc/httpd/sites-available/gitlab.vm /etc/httpd/sites-enabled/gitlab.vm
  178. service httpd restart
  179.  
  180. # Update Apache
  181. service httpd stop
  182. yum erase httpd
  183. rm -f /etc/httpd/conf/httpd.conf.rpmsave
  184. yum install pcre-devel
  185. wget http://mirror.netcologne.de/apache.org//httpd/httpd-2.2.29.tar.gz
  186. tar -xzvf httpd-2.2.29.tar.gz
  187. cd httpd-2.2.29
  188. ./configure \
  189.         "--prefix=/etc/httpd" \
  190.         "--exec-prefix=/etc/httpd" \
  191.         "--bindir=/usr/bin" \
  192.         "--sbindir=/usr/sbin" \
  193.         "--sysconfdir=/etc/httpd/conf" \
  194.         "--enable-so" \
  195.         "--enable-dav" \
  196.         "--enable-dav-fs" \
  197.         "--enable-dav-lock" \
  198.         "--enable-suexec" \
  199.         "--enable-deflate" \
  200.         "--enable-unique-id" \
  201.         "--enable-mods-static=most" \
  202.         "--enable-reqtimeout" \
  203.         "--with-mpm=prefork" \
  204.         "--with-suexec-caller=apache" \
  205.         "--with-suexec-docroot=/" \
  206.         "--with-suexec-gidmin=100" \
  207.         "--with-suexec-logfile=/var/log/httpd/suexec_log" \
  208.         "--with-suexec-uidmin=100" \
  209.         "--with-suexec-userdir=public_html" \
  210.         "--with-suexec-bin=/usr/sbin/suexec" \
  211.         "--with-included-apr" \
  212.         "--with-pcre=/usr" \
  213.         "--includedir=/usr/include/apache" \
  214.         "--libexecdir=/usr/lib/apache" \
  215.         "--datadir=/var/www" \
  216.         "--localstatedir=/var" \
  217.         "--enable-logio" \
  218.         "--enable-ssl" \
  219.         "--enable-rewrite" \
  220.         "--enable-proxy" \
  221.         "--enable-expires" \
  222.         "--with-ssl=/usr" \
  223.         "--enable-headers"
  224. make && make install
  225. cd /etc/httpd/
  226. find . -type f -exec sed -i 's:/var/logs/:/var/log/httpd/:' {} +
  227. nano conf/httpd.conf
  228. >>PidFile /var/log/httpd/httpd.pid
  229. >>Include conf/extra/httpd-vhosts.conf
  230. nano conf/extra/httpd-vhosts.conf
  231. >><VirtualHost *:80>
  232.         ServerName localhost
  233.         DocumentRoot /var/www/htdocs
  234.  
  235.         LogLevel warn
  236.         ErrorLog /var/logs/httpd/localhost-error_log
  237.         CustomLog /var/logs/httpd/localhost-access_log common
  238. </VirtualHost>
  239. >>Include sites-enabled/*
  240. rm -Rf /var/logs
  241. apachectl start
  242.  
  243. # Install Java
  244. yum install java-1.6.0-openjdk
  245.  
  246. #Install Jenkins
  247. wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  248. rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
  249. yum install jenkins
  250. nano /etc/sysconfig/jenkins
  251. >>JENKINS_PORT="8081"
  252. service jenkins start
  253. chkconfig jenkins on
  254.  
  255. # Link Apache and Jenkins
  256. nano /etc/hosts
  257. >>127.0.0.1 jenkins.vm
  258. cd /etc/httpd/
  259. nano sites-available/jenkins.vm
  260. >><VirtualHost *:80>
  261.         ServerName jenkins.vm
  262.         DocumentRoot /var/www/htdocs
  263.  
  264.         ProxyRequests Off
  265.         ProxyPreserveHost On
  266.         ProxyPass / http://127.0.0.1:8081/ nocanon retry=0
  267.         ProxyPassReverse / http://127.0.0.1:8081/
  268.         AllowEncodedSlashes NoDecode
  269.  
  270.         <Proxy http://localhost:8081/*>
  271.                 Order deny,allow
  272.                 Allow from all
  273.         </Proxy>
  274.  
  275.         LogLevel warn
  276.         ErrorLog /var/log/httpd/jenkins_error.log
  277.         CustomLog /var/log/httpd/jenkins_access.log combined
  278. </VirtualHost>
  279. ln -s /etc/httpd/sites-available/jenkins.vm /etc/httpd/sites-enabled/jenkins.vm
  280. apachectl restart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement