📜 ⬆️ ⬇️

Setting up your own GIT / SVN / Mercurial server based on SCM Manager for Tomcat under Debian

The other day, the team was faced with the fact that Bitbucket became small for us, and focusing on the similarity of corporate security, in any case, sooner or later will require moving from private repositories outside the company to their own infrastructure. After surfing the Internet, it was decided to stop at the ready solution SCM - manager for a number of reasons



Installation OS: Debian7
It is worth noting that no one has come across this before and the article is the result of several hours of throwing through the Internet and manuals.
SCM was put on Tomcat, because Redmine is spinning on it
The installation and configuration under the cut:
')

Setup service software


  1. We put JRE (necessary for Apache Tomcat)
    su apt-get install openjdk-6-jre 
  2. Downloading the latest version of Apache Tomcat from here (Required for the SCM-manager services)
     cd /tmp wget file http://www.sai.msu.su/apache/tomcat/tomcat-7/v7.0.41/bin/apache-tomcat-7.0.41.tar.gz 
  3. Unpack it, remove the garbage and drop the folder with Tomkat in / etc
     tar xzf apache-tomcat-7.0.41.tar.gz mv apache-tomcat-7.0.41 tomcat7 rm apache-tomcat-7.0.41.tar.gz mv /tmp/tomcat7/ /etc 
  4. Create a group, user for Tomkat and assign permissions to the directory
     groupadd tomcat7 useradd -g tomcat7 -d /etc/tomcat7 tomcat7 usermod -G www-data tomcat7 chown -R tomcat7:tomcat7 /etc/tomcat7 
  5. Let's add Tomkat to autoload (Note the JAVA_HOME variable in the script - you may not have amd64, - it depends on the server architecture)
     nano /etc/init.d/tomcat 

     #!/bin/bash CATALINA_HOME=/etc/tomcat7; export CATALINA_HOME JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64; export JAVA_HOME TOMCAT_OWNER=tomcat7; export TOMCAT_OWNER JAVA_OPTS="-Xms128M -Xmx128M"; export JAVA_OPTS start() { echo -n "Starting Tomcat: " su $TOMCAT_OWNER -c $CATALINA_HOME/bin/startup.sh } stop() { echo -n "Stopping Tomcat: " su $TOMCAT_OWNER -c $CATALINA_HOME/bin/shutdown.sh } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo $"Usage: tomcat {start|stop|restart}" exit esac 

     chmod +x /etc/tomcat7/bin/*.sh chmod +x /etc/init.d/tomcat 
  6. We start and check the server
     /etc/init.d/tomcat start 

    http: //***.***.***.178: 8080
  7. To access Tomkat's interface to a file
     nano /etc/tomcat7/conf/tomcat-users.xml 

    add a line inside the <tomcat-users> tag
     <user name="admin" password="password" roles="manager-gui,manager-status,manager-script,manager-jmx" /> 
  8. We throw Tomkata service on port 80
    Right but difficult
     nano /etc/tomcat7/conf/server.xml 

    Change the lines
     <Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 

    We put authbind in order to transfer it to ports below 1024
      apt-get install authbind 

     touch /etc/authbind/byport/80 chmod 500 /etc/authbind/byport/80 chown tomcat7 /etc/authbind/byport/80 

    To file
     nano /etc/tomcat7/bin/setenv.sh 

    write down
     CATALINA_OPTS="-Djava.net.preferIPv4Stack=true" 

    and change the last line in the file
     nano /etc/tomcat7/bin/startup.sh 

     exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@" 

  9. Not quite right
     /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080 /sbin/service iptables save 

  10. Restart Tomkat
     /etc/init.d/tomcat restart 


SCM installation



Login Details: scmadmin / scmadmin

In the section Users add your own

Create your own repository

Further it is available by reference.
http: //***.***.***.178/scm/git/tglync, to which we clone further.

Repositories can be easily imported, and there are also many ready-made plugins, using which you can customize SCM for yourself, for example, add notifications. Plugins are also connected via a web interface.
If desired, the SCM web client can also be customized externally.

Thank you all, I hope it was not useless.

Source: https://habr.com/ru/post/184964/


All Articles