To install and set up a redmine content management system: ---------------------------------------------------------- Author: A. Palladino Date: 08 Feb 2011 Step 1: How to enable EPEL?: rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm =========check that epel is enabled======== [ap4ax@anton ap4ax]# yum repolist =========Install stuff======== [ap4ax@anton ap4ax]# yum install ruby ruby-devel ruby-libs ruby-irb ruby-rdoc ruby-postgres rubygems [ap4ax@anton ap4ax]# gem install rails [ap4ax@anton ap4ax]# service mysqld start =========Set it up: (choose mostly defaults... just press for root password)========== [ap4ax@anton ap4ax]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] n ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] ... Success! Cleaning up... All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! =============Now make mysqld start at boot time=============== [root@anton log]# chkconfig --list | grep mysqld mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@anton log]# chkconfig --levels 345 mysqld on [root@anton log]# chkconfig --list | grep mysqld mysqld 0:off 1:off 2:off 3:on 4:on 5:on 6:off [ap4ax@anton redmine-0.8.7]# useradd redmine [ap4ax@anton redmine-0.8.7]# passwd redmine give it the password: redmine [ap4ax@anton redmine-0.8.7]# mysql --user="root" --password="" Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 17 Server version: 5.0.77 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> mysql> CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'redmine'; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON *.* TO 'redmine'@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> quit [ap4ax@anton redmine-0.8.7]# mysql --user="redmine" --password="redmine" [ap4ax@anton ap4ax]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.0.77 Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> create database redmine character set utf8; Query OK, 1 row affected (0.00 sec) mysql> mysql> quit Bye [ap4ax@anton ap4ax]# [ap4ax@anton ap4ax]# cd /opt [ap4ax@anton /opt]# [ap4ax@anton /opt]# wget http://rubyforge.org/frs/download.php/67144/redmine-0.8.7.tar.gz [ap4ax@anton /opt]# tar -xvzf redmine-0.8.7.tar.gz [ap4ax@anton /opt]# cd redmine-0.8.7 [ap4ax@anton redmine-0.8.7]# cp config/database.yml.example config/database.yml [ap4ax@anton redmine-0.8.7]# kwrite config/database.yml & Enter the appropriate settings for the [production] section ensuring that host is set to 127.0.0.1 For example: ------------ production: adapter: mysql database: redmine host: 127.0.0.1 username: redmine password: redmine encoding: utf8 [ap4ax@anton redmine-0.8.7]# rake config/initializers/session_store.rb (in /opt/redmine-0.8.7) [ap4ax@anton redmine-0.8.7]# [ap4ax@anton redmine-0.8.7]# rake db:migrate RAILS_ENV="production" [ap4ax@anton redmine-0.8.7]# rake redmine:load_default_data RAILS_ENV="production" edit config/environments/production.rb to have this line at the bottom: Redmine::Utils::relative_url_root = "/pen_cms" ActionController::AbstractRequest.relative_url_root = "/pen_cms" ##the following line is NOT needed ##config.action_controller.relative_url_root = '/pen_cms' [ap4ax@anton redmine-0.8.7]# sudo chown -R redmine:redmine files log tmp public/plugin_assets [ap4ax@anton redmine-0.8.7]# sudo chmod -R 755 files log tmp public/plugin_assets [ap4ax@anton redmine-0.8.7]# cp config/email.yml.example config/email.yml [ap4ax@anton redmine-0.8.7]# kwrite config/email.yml & Then edit it so: production: delivery_method: :sendmail try it on the localhost: [ap4ax@anton redmine-0.8.7]# ruby script/server -e production point to http://localhost:3000/ in a browser opened on anton.phys.virginia.edu you should see redmine. [ap4ax@anton redmine-0.8.7]# yum install ImageMagick [ap4ax@anton redmine-0.8.7]# yum install ImageMagick-devel [ap4ax@anton redmine-0.8.7]# gem install rmagick -v 1.15.13 --no-rdoc --no-ri [ap4ax@anton redmine-0.8.7]# gem install mongrel mongrel_cluster daemons [ap4ax@anton redmine-0.8.7]# mongrel_rails cluster::configure -e production -p 8000 -N 4 -c /opt/redmine-0.8.7 --prefix /pen_cms ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix Writing configuration file to config/mongrel_cluster.yml. [ap4ax@anton redmine-0.8.7]# kwrite config/environment.rb & Add these lines to the bottom of the file: Redmine::Utils::relative_url_root = "/pen_cms" ActionController::AbstractRequest.relative_url_root = "/pen_cms" Make it so our mongrel cluster starts at boot time: [root@anton redmine-0.8.7]# mkdir /etc/mongrel_cluster [root@anton redmine-0.8.7]# ln -s /opt/redmine-0.8.7/config/mongrel_cluster.yml /etc/mongrel_cluster/pen_redmine.yml [root@anton redmine-0.8.7]# cp /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/resources/mongrel_cluster /etc/init.d/ [root@anton redmine-0.8.7]# chmod +x /etc/init.d/mongrel_cluster [root@anton redmine-0.8.7]# /sbin/chkconfig --level 345 mongrel_cluster on [ap4ax@anton redmine-0.8.7]# mongrel_rails cluster::start ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix starting port 8000 ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix starting port 8001 ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix starting port 8002 ** Ruby version is not up-to-date; loading cgi_multipart_eof_fix =========Ignore those warnings============= Now we have to get mod_fcgi or mod_fastcgi to work: In your redmine/public/ directory, copy dispatch.fcgi.example to dispatch.fcgi [root@anton conf.d]# cp public/dispatch.cgi.example public/dispatch.cgi [root@anton conf.d]# kwrite ./public/.htaccess & edit it as follows: # # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] # # # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] # # # RewriteRule ^(.*)$ dispatch.cgi [QSA,L] # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] then [root@anton conf.d]# service httpd configtest [root@anton conf.d]# service httpd restart ============ Get the redirects working for apache: make a new file called: /etc/httpd/conf.d/redmine.conf and put this in it: #----Below is the virtual host for redmine AND ap4ax's homepage----- #NameVirtualHost anton.phys.virginia.edu:80 ServerName anton.phys.virginia.edu:80 LogLevel warn ProxyRequests Off ProxyPreserveHost On RewriteEngine On ProxyReceiveBufferSize 2048 ProxyIOBufferSize 131072 SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 SetEnv proxy-initial-not-pooled 1 #---------------------- ErrorLog logs/rails_errors_log CustomLog logs/rails_log combined DocumentRoot /opt/redmine-0.8.7 Options FollowSymLinks AllowOverride None Order allow,deny Allow from all #Redirect permanent /redmine https://anton.phys.virginia.edu/redmine/ #ProxyPass /redmine balancer://redmine_cluster #ProxyPassReverse /redmine balancer://redmine_cluster Order allow,deny Allow from all #BalancerMember http://127.0.0.1:8000 BalancerMember http://127.0.0.1:8001 BalancerMember http://127.0.0.1:8002 BalancerMember http://127.0.0.1:8003 #ProxySet lbmethod=byrequests maxattempts=3 timeout=10 #Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all RewriteEngine On RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule ^/pen_cms(.*)$ balancer://redmine_cluster%{REQUEST_URI} [P,QSA,L] RewriteRule ^/palladino(.*) /home/httpd/html$1 [L] #----end of file /etc/httpd/conf.d/redmine.conf ------------------------------------ ============ mod_fcgid seems newer and preferable to mod_fastcgi. install this one too: [root@anton conf.d]# cd /usr/local/src/ [root@anton conf.d]# wget http://downloads.sourceforge.net/project/mod-fcgid/mod-fcgid/mod_fcgid.2.2.tar.gz/mod_fcgid.2.2.tgz [root@anton conf.d]# tar xvf mod_fcgid.2.2.tgz [root@anton conf.d]# cd mod_fcgid.2.2 [root@anton conf.d]# kwrite Makefile & edit as follows: #top_dir = /usr/local/apache2 top_dir = /usr/lib/httpd [root@anton conf.d]# cd /etc/httpd/conf.d/ [root@anton conf.d]# kwrite mod_fcgid.conf & add this: LoadModule fcgid_module /usr/lib/httpd/modules/mod_fcgid.so SocketPath /tmp/fcgid_sock/ AddHandler fcgid-script .fcgi [root@anton conf.d]# service httpd restart ======================= Redmine sometimes crashes after long periods of inactivity, or heavy loading by lots of users connecting simultaneously. To remedy this I tried to install a monitor: monit yum install monit The configuration file is: /etc/monit.conf but I didn't have to edit it. I added a file called "redmine" in the directory: /etc/monit.d/redmine Edit this file so it contains: #============================================================================================ # receive all alerts set alert ap4ax@virginia.edu # watch redmine check process pen_redmine_mongrel_8001 with pidfile /opt/redmine-0.8.7/tmp/pids/mongrel.8001.pid start program = "/usr/bin/mongrel_rails cluster::start -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --clean --only 8001" stop program = "/usr/bin/mongrel_rails cluster::stop -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --only 8001" if totalmem is greater than 90.0 MB for 4 cycles then restart if cpu is greater than 80% for 4 cycles then restart if 20 restarts within 20 cycles then timeout group redmine check process pen_redmine_mongrel_8002 with pidfile /opt/redmine-0.8.7/tmp/pids/mongrel.8002.pid start program = "/usr/bin/mongrel_rails cluster::start -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --clean --only 8002" stop program = "/usr/bin/mongrel_rails cluster::stop -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --only 8002" if totalmem is greater than 90.0 MB for 4 cycles then restart if cpu is greater than 80% for 4 cycles then restart if 20 restarts within 20 cycles then timeout group redmine check process pen_redmine_mongrel_8003 with pidfile /opt/redmine-0.8.7/tmp/pids/mongrel.8003.pid start program = "/usr/bin/mongrel_rails cluster::start -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --clean --only 8003" stop program = "/usr/bin/mongrel_rails cluster::stop -C /opt/redmine-0.8.7/config/mongrel_cluster.yml --only 8003" if totalmem is greater than 90.0 MB for 4 cycles then restart if cpu is greater than 80% for 4 cycles then restart if 20 restarts within 20 cycles then timeout group redmine #============================================================================================ Then we can start the monit sevice: service monit restart You should get an email saying that it started. Now make it start at boot time: [root@anton log]# chkconfig --list | grep monit lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off monit 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root@anton log]# chkconfig --levels 345 monit on [root@anton log]# chkconfig --list | grep monit lvm2-monitor 0:off 1:on 2:on 3:on 4:on 5:on 6:off mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off monit 0:off 1:off 2:off 3:on 4:on 5:on 6:off =================================== Now there is a script to restart redmine every night at midnight. This alleviates many problems with the system hanging up. The script is in the ROOT users crontab. [root@anton config]# crontab -l * * * * * killall -HUP elogd >> /dev/null 2>&1 0 0 * * * /home/ap4ax/scripts/restart_redmine.sh >> /dev/null 2>&1 Where the restart_redmine.sh script is as follows: #!/bin/bash # Here is the cron job to execute once every day at midnight: # 0 0 * * * /home/ap4ax/scripts/restart_redmine.sh >> /dev/null 2>&1 #Restart PEN content management system cd /opt/redmine-0.8.7/ mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 10s mongrel_rails cluster::start #Restart NAB content management system cd /opt/redmine-0.8.7_nab/ mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 10s mongrel_rails cluster::start #Restart NPDg content management system cd /opt/redmine-0.8.7_npdg/ mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 2s mongrel_rails cluster::stop sleep 10s mongrel_rails cluster::start exit 0