apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server php5-mcrypt -y apt-get install git-core git-doc gitolite -y #安装最新版的gitolite #http://www.bigfastblog.com/gitolite-installation-step-by-step adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/gitolite git #以gitolite身份登陆,并安装初始化gitolite, su - git cd ~ ssh-keygen -t rsa gl-setup /home/gitolite/.ssh/id_rsa.pub 修改/home/gitolite/.gitolite.rc,将其中的 $REPO_UMASK = 0077; 修改为 $REPO_UMASK = 0027; #退出到root身份 exit #安装redmine所依赖的环境 apt-get install ruby rubygems libruby libapache2-mod-passenger ruby-dev -y apt-get install libmysqlclient-dev libmagickcore-dev libmagickwand-dev -y gem install bundler #安装最新版(或指定版本)的redmine adduser --system --shell /bin/bash --gecos 'redmine user' --group --disabled-password --home /home/redmine redmine cd /home/redmine git clone git://github.com/redmine/redmine.git cd redmine bundle install --without development test postgresql sqlite #在mysql数据库中建立一个redmine的用户以及redmine数据库,redmine对这个数据库拥有所有权限(一定要是utf-8编码格式的) Copy config/database.yml.example to config/database.yml and edit this file in order to configure your database settings for "production" environment. Example for a MySQL database using ruby1.8 or jruby: production: adapter: mysql2 (note: For Rails < 3.1 use mysql instead of mysql2) database: redmine host: localhost username: redmine password: my_password #修改好后运行 rake generate_secret_token #如果有sql错误,再运行一下bundle install 好像就可以解决 #再依次运行,在问用什么语言时,我选的en RAILS_ENV=production rake db:migrate RAILS_ENV=production rake redmine:load_default_data #修改 config/configuration.yml 中的 database_cipher_key: 值为 *(我没有修改也可以) 再次运行 rake db:encrypt RAILS_ENV=production #然后添加apache的虚拟机: <VirtualHost *:80> ServerName do1.justchen.com DocumentRoot /usr/local/share/redmine/public <Directory /usr/local/share/redmine/public> AllowOverride all Options -MultiViews </Directory> </VirtualHost> 这样,redmine就算安装成功!并且是最新版的 如果有500错误chmod 777 -R /usr/local/share/redmine/tmp 2013-05-18 增加在利用nginx反代Unicorn,以redmine身份运行redmine 参照https://github.com/jbox-web/redmine_git_hosting/issues/9 1:停止apache2 并将端口号修改到8080 apt-get install nginx -y gem install unicorn 修改 nginx配置: upstream unicorn_redmine { server unix:/home/redmine/redmine/tmp/sockets/unicorn.sock fail_timeout=0; #server 127.0.0.1:3000; #dev mode } server { server_name redmine.example.com listen 0.0.0.0:80; root /home/redmine/redmine; access_log /var/log/nginx/redmine.log; error_log /var/log/nginx/redmine.log; location / { try_files $uri @ruby; } location @ruby { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_set_header X-Forwarded-Proto https; # uquote if you are in HTTPs proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 300; proxy_pass http://unicorn_redmine; } } 增加文件REDMINE_ROOT/config/unicorn.rb # configuration file for Unicorn (not Rack) # # See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete # documentation. # Use at least one worker per core if you're on a dedicated server, # more will usually help for _short_ waits on databases/caches. worker_processes 2 # Help ensure your application will always spawn in the symlinked # "current" directory that Capistrano sets up. working_directory "/home/redmine/redmine" # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy listen "/home/redmine/redmine/tmp/sockets/unicorn.sock", :backlog => 64, :tcp_nopush => false #listen 3000, :tcp_nopush => false # nuke workers after 30 seconds instead of 60 seconds (the default) timeout 30 # feel free to point this anywhere accessible on the filesystem pid "/home/redmine/redmine/tmp/pids/unicorn.pid" # some applications/frameworks log to stderr or stdout, so prevent # them from going to /dev/null when daemonized here: stderr_path "/home/redmine/redmine/log/unicorn.stderr.log" stdout_path "/home/redmine/redmine/log/unicorn.stdout.log" # combine REE with "preload_app true" for memory savings # http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = true before_fork do |server, worker| # the following is highly recomended for Rails + "preload_app true" # as there's no need for the master process to hold a connection defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! # The following is only recommended for memory/DB-constrained # installations. It is not needed if your system can house # twice as many worker_processes as you have configured. # # # This allows a new master process to incrementally # # phase out the old master process with SIGTTOU to avoid a # # thundering herd (especially in the "preload_app false" case) # # when doing a transparent upgrade. The last worker spawned # # will then kill off the old master process with a SIGQUIT. # old_pid = "#{server.config[:pid]}.oldbin" # if old_pid != server.pid # begin # sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU # Process.kill(sig, File.read(old_pid).to_i) # rescue Errno::ENOENT, Errno::ESRCH # end # end # # # *optionally* throttle the master from forking too quickly by sleeping # sleep 1 end after_fork do |server, worker| # per-process listener ports for debugging/admin/migrations # addr = "127.0.0.1:#{9293 + worker.nr}" # server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true) # the following is *required* for Rails + "preload_app true", defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection # if preload_app is true, then you may also want to check and # restart any other shared sockets/descriptors such as Memcached, # and Redis. TokyoCabinet file handles are safe to reuse # between any number of forked children (assuming your kernel # correctly implements pread()/pwrite() system calls) end 增加文件/etc/init.d/redmine #!/bin/sh ### BEGIN INIT INFO # Provides: redmine # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: projects manager # Description: This file should be used to start and stop redmine. ### END INIT INFO [ -f /etc/default/rcS ] && . /etc/default/rcS . /lib/lsb/init-functions case "$1" in start) su - redmine -c 'service_unicorn.sh start' ;; stop) su - redmine -c 'service_unicorn.sh stop' ;; restart) su - redmine -c 'service_unicorn.sh restart' ;; *) echo "Usage : service_unicorn.sh {start|stop|restart}" ;; esac 再增加文件/<redmine user home>/bin/service_unicorn.sh #!/bin/bash function start () { echo "Start Unicorn Server..." unicorn_rails -c "$HOME/redmine/config/unicorn.rb" -E production -D echo "Done" } function stop () { echo "Stop Unicorn Server..." kill $(cat $HOME/redmine/tmp/pids/unicorn.pid) echo "Done" } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage : service_unicorn.sh {start|stop|restart}" ;; esac 继续增加文件/<redmine user home>/.profile # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi 然后就可以,应该是要将 /etc/init.d/redmine start 拿到开机自运行的 /etc/init.d/redmine start /etc/init.d/redmine stop 安装 redmine git hosting https://github.com/jbox-web/redmine_git_hosting#readme gem install lockfile inifile net-ssh 没安装成功啊... |