YouSource installation on Fedora Core ===================================== This document covers up installing YouSource to Fedora Core. It's based on "rough notes for installing gitorious on fedora 11" available at: http://groups.google.com/group/gitorious/browse_thread/thread/72cf30f5ea823113 It was posted by bryan@olenepal.org and it was contributed by Abhishek Singh. This installation manual is divided into sections: Cheatsheet Pitfalls Operating system Libraries & software Gems & Ruby environment Cheatsheet -------------- Skip this if you already know what pieces of software you are about to install. :-) Ruby: Thin Ruby web server that combines Mongrel parser, Event Machine and Rack Mongrel small library that provides HTTP 1.1 server Event Machine network I/O library Rack minimal interface between webservers and Ruby frameworks. Stomp messaging protocol Sphinx full text SQL search engine Ultrasphinx Ruby on Rails configurator and client to the Sphinx full text search engine. Gitorious spesific: poller task runner that polls messages from stomp broker and executes them Pitfalls ------------ Known uncompatibilites and things that can easily go wrong. As of 16th March 2010.. * Latest version of Rack crashes Thin server, use rack v1.0.1 Operating system -------------------- # disable selinux and set SELINUX to disabled emacs /etc/selinux/config SELINUX=disabled Libraries & software ------------------------ # install tons of rpms sudo yum install -y git git-svn emacs pcre pcre-devel pcre-static \ apg zlib zlib-devel zlib-static sendmail ; sudo yum -y groupinstall "Development Libraries" "Development Tools" ; sudo yum install -y libssh2 openssh openssh-askpass openssh-clients ; sudo yum install -y openssh-server libssh2-devel ruby ruby-RMagick \ ruby-RMagick-doc ruby-rdoc ruby-ri ruby-irb ruby-devel oniguruma memcached \ oniguruma-devel libyaml libyaml-devel GeoIP GeoIP-devel ImageMagick \ ImageMagick-devel mysql mysql-server mysql-libs mysql-devel http http- manual \ httpd-tools libuuid libuuid-devel uuid java-1.6.0-openjdk java-1.6.0- openjdk-devel \ java-1.6.0-openjdk-javadoc java-1.6.0-openjdk-plugin libsqlite3x-devel \ readline-devel mysql++-devel glibc-devel openssl-devel sudo ln -s /usr/bin/ruby1.8 /usr/bin/ruby Gems & Ruby environment --------------------------- # installing gems cd ~/ mkdir src cd src wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz tar xvzf rubygems-1.3.5.tgz cd rubygems-1.3.5 sudo ruby setup.rb sudo gem update --system #install tons of gems gem install --no-ri --no-rdoc rails mongrel mime-types \ textpow chronic ruby-hmac daemons mime-types oniguruma \ textpow chronic BlueCloth ruby-yadis ruby-openid geoip \ rspec rspec-rails RedCloth echoe hoe diff-lcs stompserver json mysql #!important latest version of rack crashes thin server, use v1.0.1 sudo gem install -b --no-ri --no-rdoc -v 1.0.1 rack sudo gem install -b --no-ri --no-rdoc -v 1.3.1.1 rdiscount sudo gem install -b --no-ri --no-rdoc -v 1.1 stomp #**Sphinx Stuff** cd ~/src wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz tar xvfz sphinx-0.9.8.tar.gz cd sphinx-0.9.8 ./configure make && sudo make install sudo gem install --no-ri --no-rdoc ultrasphinx # set up git user and dirs, the git user needs to have a home directory sudo adduser --create-home git sudo mkdir /var/git sudo mkdir /var/git/repositories sudo mkdir /var/git/tarballs sudo mkdir /var/git/tarball-work sudo mkdir -p /var/www/git.olenepal.org sudo chown -R git:git /var/git /var/www/git.olenepal.org #downloading stuff git clone git://gitorious.org/gitorious/mainline.git gitorious # create password for git user, I used "password" su passwd git # gitorious server stuff sudo groupadd gitorious sudo usermod -a -G gitorious git sudo chmod -R g+sw /var/www/git.olenepal.org cd /var/www/git.olenepal.org mkdir log mkdir conf git clone git://gitorious.org/gitorious/mainline.git gitorious sudo ln -s /var/www/git.olenepal.org/gitorious/script/gitorious /usr/ local/bin/gitorious cd gitorious/ rm public/.htaccess mkdir -p tmp/pids sudo chmod ug+x script/* sudo chmod -R g+w config/ log/ public/ tmp/ # set up keys for git user su git cd ~ mkdir /home/git/.ssh chmod 700 ~/.ssh touch ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys # !important make sure permissions on authorized_keys is 600 # and 700 for /home/git/.ssh # copy git-daemon, git-ultrasphinx, git-poller from this directory to # /etc/init.d/ and edit paths # GIT_DAEMON="/usr/bin/ruby \ /var/www/git.olenepal.org/gitorious/script/git-daemon -d" PID_FILE=/var/www/git.olenepal.org/gitorious/log/git-daemon.pid # change Ruby interpreter in git-daemon to /usr/bin/ruby #was #!/usr/bin/env ruby #now #!/usr/bin/ruby #!important don't use the centos init script from gitorious, use custom one # instead. I couldn't get the centos script working on fedora # configure gitorious and migrate database cd /var/www/git.olenepal.org/gitorious cp config/database.sample.yml config/database.yml cp config/gitorious.sample.yml config/gitorious.yml cp config/broker.yml.example config/broker.yml # Copy this, remove newlines and keep it in your kill ring apg -m 64 # edit /var/www/git.olenepal.org/gitorious/config/gitorious.yml # put secret key generated above by cookie_secret, but remove newlines repository_base_path: "/var/git/repositories" gitorious_client_host: git.olenepal.org gitorious_host: git.olenepal.org gitorious_client_port: 4000 archive_cache_dir: "/var/git/tarballs" archive_work_dir: "/var/git/tarballs-work" # set up database use user git for testing, but should use different user otherwise sudo /etc/init.d/mysqld start mysql -uroot -p create database gitorious_production; grant all privileges on gitorious_production.* to git@localhost \ identified by 'password'; sudo rake gems:install RAILS_ENV=production #!important: from here on I only use the production environment # edit config/database.yml w/ name of database user production: adapter: mysql database: gitorious_production username: git password: password host: localhost encoding: utf8 sudo rake db:migrate RAILS_ENV=production # create site administrator, user is admin, password: password cd /var/www/git.myserver.com/gitorious env RAILS_ENV=production ruby script/create_admin y...@foo.org, passwd: password, login: admin script/console production > user = User.first > user.login = "admin" # Change to your desired username > user.activate > user.accept_terms > user.save # modify file /var/www/git.olenepal.org/git.olenepal.org/gitorious/ vendor/plugins/ultrasphinx/tasks/ultrasphinx.rake # change indexer to /usr/local/bin/indexer # change searchd to /usr/local/bin/searchd cd /var/www/git.myserver.com/gitorious rake ultrasphinx:bootstrap RAILS_ENV=production sudo chown -R git:git /var/www/git.olenepal.org/ # generate a key for the user use to administer gitorious ssh-keygen # go to http://git.olenepal.org:3000/~hitman/keys/new # and add in your ssh key # set up to use thin instead of thin sudo gem install thin # create yml file for gitorious, gitorious-thin.yml cp gitorious-thin.yml /etc/thin/gitorious-thin.yml # configure services to start automatically sudo chkconfig --level 2345 mysqld on sudo chkconfig --level 2345 httpd on # copy files to /etc/init.d git-poller, git-daemon, git-ultrasphinx, # gitorious-thin, stomp, gitorious-thin.yml to /etc/thin/gitorious- thin.yml # set permissions sudo chmod 755 git-poller stomp gitorious-thin git-ultrasphinx git- daemon # schedule these scripts to run on various runlevels sudo chkconfig --add stomp ; sudo chkconfig --add git-poller ; sudo chkconfig --add git-ultrasphinx ; sudo chkconfig --add git- daemon ; sudo chkconfig --add gitorious-thin sudo chkconfig --add memcached # I added the following to git-poller, git-daemon, git-ultrasphinx, memcached # and it does lots of powerful magic # chkconfig: 2345 80 20 #configure apache cp mod_proxy.conf /etc/httpd/conf.d/mod_proxy.conf cp gitorious.conf /etc/httpd/conf.d/gitorious.conf # set up log rotation cp gitorious-logrotate /etc/logrotate.d/gitorious chmod +x /etc/logrotate.d/gitorious # start up your services! cd /etc/init.d sudo ./stomp start sudo ./git-daemon start sudo ./git-poller start sudo ./git-ultrasphinx start sudo ./gitorious-thin start service files /etc/httpd/conf.d/gitorious.conf ServerName git.foo.org DocumentRoot /var/www/git.foo.org/gitorious BalancerMember http://127.0.0.1:4000 BalancerMember http://127.0.0.1:4001 BalancerMember http://127.0.0.1:4002 ProxyPass / balancer://gitorious/ ProxyPassReverse / balancer://gitorious/ ErrorLog /var/log/httpd/error.log CustomLog /var/log/httpd/access.log vcombined CustomLog /var/log/httpd/gitorious-access.log combined /etc/httpd/conf.d/mod_proxy.conf #turning ProxyRequests on and allowing proxying from all may allow #spammers to use your proxy to send email. ProxyRequests Off AddDefaultCharset off Order deny,allow Allow from all # Enable/disable the handling of HTTP/1.1 "Via:" headers. # ("Full" adds the server version; "Block" removes all outgoing Via: headers) # Set to one of: Off | On | Full | Block ProxyVia On /etc/init.d/git-daemon #!/bin/bash # # Init file for Gitorious GIT-Daemon daemon # # chkconfig: 2345 80 20 # description: GIT-Daemon server daemon # # processname: git-daemon # pidfile: /var/www/gitorious/log/git-daemon.pid # source function library . /etc/init.d/functions PROG=$0 GIT_DAEMON="env RAILS_ENV=production /usr/bin/ruby /var/www/ git.tony.org/gitorious/script/git-daemon -d" PID='' RUNNING=0 get_pid(){ PID=`ps aux | grep git-daemon | grep -v grep | awk '{ print $2 }'` RUNNING=`ps aux | grep git-daemon | grep -v grep | awk '{ print $2}' | wc -l` } case "$1" in start) echo "Starting $PROG" daemon --user=git $GIT_DAEMON & ;; stop) echo "Stopping $PROG" get_pid kill -HUP $PID ;; restart) stop start ;; condrestart) if [ -f $LOCK_FILE ] ; then if [ "$RETVAL" = 0 ] ; then stop # avoid race sleep 5 start fi fi ;; *) echo $"Usage: $0 {start|stop|restart|condrestart}" RETVAL=1 esac exit $RETVAL /etc/init.d/git-ultrasphinx #!/bin/bash # # Init file for Gitorious Ultrasphinx daemon # # chkconfig: 2345 80 20 # description: Ultrasphinx server daemon # # processname: searchd # pidfile: /var/www/gitorious/db/sphinx/log/searchd.pid RETVAL=0 START_CMD="cd /var/www/git.tony.org/gitorious && rake ultrasphinx:daemon:start RAILS_ENV=production" STOP_CMD="cd /var/www/git.tony.org/gitorious && rake ultrasphinx:daemon:stop RAILS_ENV=production" RESTART_CMD="cd /var/www/git.tony.org/gitorious && rake ultrasphinx:daemon:restart RAILS_ENV=production" STATUS_CMD="cd /var/www/git.tony.org/gitorioius && rake ultrasphinx:daemon:status RAILS_ENV=production" LOCK_FILE=/var/lock/git-ultrasphinx PID_FILE=/var/www/git.tony.org/gitorious/db/sphinx/log/searchd.pid case "$1" in start) /bin/su - git -c "$START_CMD" ;; stop) /bin/su - git -c "$STOP_CMD" ;; status) /bin/su - git -c "$STATUS_CMD" ;; restart) /bin/su - git -c "$RESTART_CMD" ;; *) echo $"Usage: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL /etc/init.d/gitorious-thin #!/bin/sh ### BEGIN INIT INFO # chkconfig: 2345 80 20 # Provides: thin # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: S 0 1 6 # Short-Description: thin initscript # Description: thin ### END INIT INFO # Original author: Forrest Robertson # Do NOT "set -e" DAEMON=/usr/bin/thin SCRIPT_NAME=/etc/init.d/thin CONFIG_PATH=/etc/thin . /etc/init.d/functions # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 case "$1" in start) su git -c "$DAEMON start --config $CONFIG_PATH/gitorious-thin.yml" ;; stop) su git -c "$DAEMON stop --config $CONFIG_PATH/gitorious-thin.yml" ;; restart) su git -c "$DAEMON restart --all $CONFIG_PATH" ;; *) echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 exit 3 ;; esac /etc/thin/gitorious-thin.yml --- pid: tmp/pids/thin-gitorious.pid log: log/thin-gitorious.pid max_conns: 1024 timeout: 30 port: 4000 chdir: /var/www/git.tony.org/gitorious max_persistent_conns: 512 environment: production require: [] servers: 3 address: 127.0.0.1 daemonize: true /etc/init.d/git-poller #!/bin/sh # Start/stop the git poller # ### BEGIN INIT INFO # Provides: git-poller # Required-Start: stomp # Required-Stop: # chkconfig: 2345 80 20 # Default-Stop: 1 # Short-Description: Gitorious poller # Description: Gitorious poller ### END INIT INFO /bin/su -- git -c "cd /var/www/git.tony.org/gitorious ; RAILS_ENV=production script/poller $@" /var/www/git.tony.org/gitorious/config/gitorious.yml development: production: # The session secret key (`apg -m 64` is always useful for this kinda stuff) cookie_secret: sssht # The path where git repositories are stored. The actual (bare) repositories resides # in repository_base_path/#{project.slug}/#{repository.name}.git/: repository_base_path: "/var/git/repositories" # Stuff that's in the html . custom stats javascript code etc extra_html_head_data: # System message that will appear on all pages if present system_message: # Port the ./script/gitorious script should use: gitorious_client_port: 4000 # Host the ./script/gitorious script should use: gitorious_client_host: git.tony.org # Host which is serving the gitorious app, eg "gitorious.org" gitorious_host: git.tony.org # User which is running git daemon gitorious_user: git # Email spam on server errors to: exception_notification_emails: f...@foo.org # Mangle visible e-mail addresses (spam protection) mangle_email_addresses: true # Enable or Disable Public Mode (true) or Private Mode (false) public_mode: false # Define your locale locale: en # Where should we store generated tarballs? # (should be readable by webserver, since we tell it to send the file using X-Sendfile) archive_cache_dir: "/var/git/tarballs" # Which directory should we work in when we generate tarballs, before moving # them to the above dir? archive_work_dir: "/var/git/tarballs-work" # is it only site admins who can create new projects? only_site_admins_can_create_projects: false # Should we hide HTTP clone urls? hide_http_clone_urls: false # Is this gitorious.org? Read: should we have a very flashy homepage? is_gitorious_dot_org: false # Pick a default license #default_license: GNU Affero General Public License (AGPLv3) test: /etc/init.d/stomp #!/bin/bash # Start/stop the stompserver # ### BEGIN INIT INFO # Provides: stomp # Required-Start: $local_fs $remote_fs $network $syslog # chkconfig: 2345 55 45 # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: Stomp # Description: Stomp ### END INIT INFO test -f /usr/bin/stompserver || exit 0 . /etc/init.d/functions case "$1" in start) echo -n "starting stomp server" daemon --user=git /usr/bin/stompserver & ;; stop) echo -n "Stopping stomp server" killproc /usr/bin/stompserver ;; restart) echo "Stopping stomp server" killproc /usr/bin/stompserver echo -n "starting stomp server" daemon --user=git /usr/bin/stompserver & esac exit 0