LoginSignup
4
6

More than 5 years have passed since last update.

GitBucketたててみた

Last updated at Posted at 2016-04-02

Gitコワイ クラウドコワイ って先輩言ってるけど
オンプレならええんやろってことで、、、

CentOS 7 の環境でつくってます

  • 去年僕が行ったインドネシア最大の島と同じ名前のプログラミング言語を扱えるようにします
    当時はversion "1.8.0_71" が最新でした
# yum search openjdk
# yum install java-1.8.0-openjdk-devel.x86_64
# java -version
openjdk version "1.8.0_71"
OpenJDK Runtime Environment (build 1.8.0_71-b15)
OpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)
# su kuchidake
$ export JAVA_HOME=/usr/bin/java
$ source .bashrc
$ echo $JAVA_HOME
/usr/bin/java
  • application server は何がいいですか? tomcatでいいですか?
  • ログインできないtomcatユーザをつくる
# yum install tomcat
# yum install httpd
# useradd -s /sbin/nologin tomcat
# chown -R tomcat:tomcat /usr/share/tomcat/

Apacheと連携させるため、httpのコネクタポートは無効にし、ajpで連携する。

# vi /usr/share/tomcat/conf/server.xml
<!--
  <connector port="8080" protocol="HTTP/1.1"
             connectionTimeout="20000"
             redirectPort="8443">
-->

<connector port="8009" protocol="AJP/1.3" redirectPort="8443">




# vi /etc/httpd/conf.d/vhosts.conf

<VirtualHost *:80>
DocumentRoot /usr/share/tomcat/webapps/gitbucket
ServerName gitbucket.com
ErrorLog logs/gitbucket_error_log
CustomLog logs/gitbucket_access_log common
<Proxy *>
  Order deny,allow
  Allow from all
</Proxy>
ProxyPass /assets !
ProxyPass /gitbucket ajp://localhost:8009/gitbucket
ProxyPassReverse /gitbucket ajp://localhost:8009/gitbucket
ProxyPreserveHost on
</VirtualHost>

# systemctl restart httpd


# cd /usr/share/tomcat/webapps
# wget https://github.com/gitbucket/gitbucket/releases/download/3.11/gitbucket.war
# systemctl start tomcat



# firewall-cmd --zone=public --add-port=8009/tcp --permanent
# firewall-cmd --reload



# systemctl enable httpd
# systemctl enable tomcat

* Nmapコマンドで、使用中のポートを確認する
# yum install -y nmap
# nmap localhost
  • そうかお前はjetty がいいのか。
# java -jar /usr/share/tomcat/webapps/gitbucket/gitbucket.war
2016-02-16 17:15:29.841:INFO::main: Logging initialized @171ms
2016-02-16 17:15:29.918:INFO:oejs.Server:main: jetty-9.3.z-SNAPSHOT
2016-02-16 17:15:30.940:INFO:oejw.StandardDescriptorProcessor:main: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/root/.gitbucket/tmp/webapp/WEB-INF/lib/logback-classic-1.1.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/.gitbucket/tmp/webapp/WEB-INF/lib/slf4j-jdk14-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
17:15:31.309 [MLog-Init-Reporter] INFO  com.mchange.v2.log.MLog - MLog clients using slf4j logging.
17:15:31.420 [main] INFO  com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
17:15:31.568 [main] INFO  c.m.v.c.i.AbstractPoolBackedDataSource - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> library, dataSourceName -> z8kflt9e1souujr1eg1d92|15c43bd9, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.h2.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> z8kflt9e1souujr1eg1d92|15c43bd9, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:h2:/root/.gitbucket/data;MVCC=true, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> true, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
17:15:32.998 [main] INFO  o.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
17:15:32.999 [main] INFO  org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.2.1 created.
17:15:33.002 [main] INFO  org.quartz.simpl.RAMJobStore - RAMJobStore initialized.
17:15:33.003 [main] INFO  org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.2.1) 'QuartzScheduler~job' with instanceId 'job'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 1 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

17:15:33.003 [main] INFO  o.quartz.impl.DirectSchedulerFactory - Quartz scheduler 'QuartzScheduler~job
17:15:33.003 [main] INFO  o.quartz.impl.DirectSchedulerFactory - Quartz scheduler version: 2.2.1
17:15:33.004 [main] INFO  org.quartz.core.QuartzScheduler - Scheduler QuartzScheduler~job_$_job started.
[INFO] [02/16/2016 17:15:33.010] [main] [[QuartzScheduler~job]] Setting up scheduled job 'Daily', with 'com.typesafe.akka.extension.quartz.QuartzCronSchedule@2ceb80a1'
17:15:33.023 [main] INFO  o.scalatra.servlet.ScalatraListener - The cycle class name from the config: ScalatraBootstrap
17:15:33.025 [main] INFO  o.scalatra.servlet.ScalatraListener - Initializing life cycle class: ScalatraBootstrap
2016-02-16 17:15:33.575:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@62d0ac62{/,file:///root/.gitbucket/tmp/webapp/,AVAILABLE}{/gitbucket/gitbucket.war}
Exception in thread "main" java.net.BindException: Address already in use
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:326)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:384)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at JettyLauncher.main(JettyLauncher.java:64)
  • ということで tomcatを消します
    rm -r tomcat はログインしないユーザなんだから -r いらなかったです
# systemctl stop tomcat
# yum list installed | grep tomcat
tomcat.noarch                        7.0.54-2.el7_1                    @base
tomcat-el-2.2-api.noarch             7.0.54-2.el7_1                    @base
tomcat-jsp-2.2-api.noarch            7.0.54-2.el7_1                    @base
tomcat-lib.noarch                    7.0.54-2.el7_1                    @base
tomcat-servlet-3.0-api.noarch        7.0.54-2.el7_1                    @base
# yum remove -y tomcat.noarch tomcat-el-2.2-api.noarch tomcat-jsp-2.2-api.noarch tomcat-lib.noarch tomcat-servlet-3.0-api.noarch
# cd /usr/share/
# rm -r tomcat

気を取り直してJetty(初めて使う)でやってみます ←諦めが悪い

$ cd ~
$ wget http://download.eclipse.org/jetty/stable-9/dist/jetty-distribution-9.3.7.v20160115.tar.gz
$ tar zxvf jetty-distribution-9.3.7.v20160115.tar.gz
$ rm jetty-distribution-9.3.7.v20160115.tar.gz
$ sudo mv jetty-distribution-9.3.7.v20160115 /opt/gitbucket
$ sudo useradd -m jetty
$ sudo chown -R jetty:jetty /opt/gitbucket/
$ sudo ln -s /opt/gitbucket/bin/jetty.sh /etc/init.d/gitbucket
$ sudo chkconfig --add gitbucket
$ sudo chkconfig --level 345 gitbucket on
$ sudo chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

gitbucket       0:off   1:off   2:off   3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off

$ sudo vi /etc/default/gitbucket
JETTY_HOME=/opt/gitbucket
JETTY_USER=jetty
JETTY_PORT=8080
JETTY_HOST=[CentOSのIPアドレス]
JETTY_LOGS=/opt/gitbucket/logs/

$ sudo wget https://github.com/gitbucket/gitbucket/releases/download/3.11/gitbucket.war
$ sudo service gitbucket start
$ sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
$ sudo firewall-cmd --reload
success
  • ブラウザでhttp://[CentOSのIPアドレス]:8080/gitbucket/ につながったので勝ちです ポートの開放は最低限です
$ nmap localhost

Starting Nmap 6.40 ( http://nmap.org ) at 2016-02-17 14:29 JST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00096s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds
  • 移行するときは base_url を新しい IP アドレスに書き換えるだけ
# vi /home/jetty/.gitbucket/gitbucket.conf
4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6