First and Foremost, get Centos 7 Minimum installed, make sure it has access to the internet and that your account is a sudoer. Don't use root.... RVM doesn't like that.
Next install your core bits
sudo yum update sudo yum install vim curl zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel ftp wget ImageMagick-devel gcc-c++ patch readline readline-devel zlib libyaml-devel libffi-devel make bzip2 autoconf automake libtool bison subversion sqlite-devel sudo yum install epel-release sudo yum install nginx
At this point, I leave it up to you how you want to deal with selinux. You can search the internets to get a better idea, you can either disable temporarily or edit the config file and disable it.
sudo setenforce 0 sudo vim /etc/selinux/config
Next, take a moment to install MariaDB, and secore it, before we go on to configure it.
sudo yum install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
mysql_secure_installation
mysql -uroot -p
Now we setup the redmine database. Pay attention to where you need to supply the password.
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE redmine CHARACTER SET utf8;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine_passwd';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
Finally we get to install RVM and the magic begins.
\curl -sSL https://get.rvm.io | sudo bash -s stable
You might get told to download the gpg key, do so. At the end you will get a message that contains a few important things. PAY ATTENTION
* First you need to add all users that will be using rvm to 'rvm' group, and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh` in all your open shell windows, in rare cases you need to reopen all shell windows. * Please do NOT forget to add your users to the rvm group.
So take a moment to add yourself and nginx to the rvm group. After that, log out, reboot, get some coffee.
sudo usermod -a -G rvm USER
sudo usermod -a -G rvm nginx
Now, we are going to do 4 things.
1. Install Ruby 2.5.5
2. Create a gemset for our application
3. Use said gemset
4. Make any other user who is working on this with us lives easier by setting said gemset as the default.
rvm install ruby-2.5.5 rvm gemset create redmine rvm use 2.5.5@redmine rvm use --default 2.5.5@redmine
Onwards to Redmine
We are going to put it in /var/www because that is what normal people do (here is looking at you ubuntu)
Follow the next few steps and we will meet back at the database config
cd /var/www
sudo svn co http://svn.redmine.org/redmine/branches/4.0-stable redmine
sudo cp redmine/config/configuration.yml.example redmine/config/configuration.yml
sudo cp redmine/config/database.yml.example redmine/config/database.yml
sudo vim redmine/config/database.yml
Ok, We are using Maria DB, so we are going to configure mysql12 in the Production enviroment. It should look like this:
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: "redmine_passwd"
encoding: utf8
Now, a small aside, we want to add the Gem "puma" to our gemfile in Redmine under production, and remove it from test and development.
sudo vim /var/www/redmine/Gemfile
source 'https://rubygems.org'
gem "bundler", ">= 1.5.0"
gem "rails", "5.2.3"
gem "puma"
gem "rouge", "~> 3.3.0"
gem "request_store", "1.0.5"
gem "mini_mime", "~> 1.0.1"
gem "actionpack-xml_parser"
gem "roadie-rails", "~> 1.3.0"
gem "mimemagic"
gem "mail", "~> 2.7.1"
gem "csv", "~> 3.0.1" if RUBY_VERSION >= "2.3" && RUBY_VERSION < "2.6"
gem "nokogiri", (RUBY_VERSION >= "2.3" ? "~> 1.10.0" : "~> 1.9.1")
gem "i18n", "~> 0.7.0"
gem "xpath", "< 3.2.0" if RUBY_VERSION < "2.3"
Make sure it is up there at the top, and NO WHERE ELSE.
Now, from www change the owner of redmine to your user, install bundler and run the bundler.
sudo chown USER -R redmine
gem install bundler
bundle install --without development test
If that all goes well, get the database setup
rake generate_secret_token RAILS_ENV=production rake db:migrate RAILS_ENV=production REDMINE_LANG=en rake redmine:load_default_data
Now, from WWW, make a place for your puma socket to run (you may have to give it 777 or user nginx if you run into problems.
sudo mkdir share sudo mkdir share/sockets
Almost done, change the owner of redmine to nginx and load up you puma.service file
sudo chown nginx -R redmine sudo vim /etc/systemd/system/puma.service
The local ruby/puma wizard at work helped me whip up this next file. There are options in there to do things a few different ways, but if you leave it as is, you should be fine. You can see you can also test by putting it on a local port.
[Unit]
Description=Puma HTTP Server
After=network.target
[Service]
# Foreground process (do not use --daemon in ExecStart or config.rb)
Type=simple
# Preferably configure a non-privileged user
User=nginx
# The path to the puma application root
WorkingDirectory=/var/www/redmine
# The command to start Puma. The top one creates a scocke
# The bottom one creates a port
ExecStart=/usr/local/rvm/wrappers/ruby-2.5.5@redmine/bundle exec puma -e production -b unix:///var/www/share/sockets/puma.sock
#ExecStart=/usr/local/rvm/wrappers/ruby-2.5.5@redmine/bundle exec puma -e production -b "tcp://0.0.0.0:3000"
# Variant: Use config file with `bind` directives instead:
# ExecStart=<WD>/sbin/puma -C config.rb
# Variant: Use `bundle exec --keep-file-descriptors puma` instead of binstub
Restart=always
[Install]
WantedBy=multi-user.target
Now make a copy of your nginx configuration, and edit it to add : include sites-enabled
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bu sudo vim /etc/nginx/nginx.conf
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
You can remove the default server, but change it to port 81 if you do. It can be good for testing.
Right above server... add that line. Now, make some sites to include
sudo mkdir /etc/nginx/sites-enabled sudo vim /etc/nginx/sites-enabled/redmine.conf
There are, again, two options here. The port is for testing, the socket is for production
#server {
# listen 80;
# listen [::]:80;
#
# server_name yoursite.com;
#
# location / {
# proxy_pass http://localhost:3000/;
# }
#}
# http context
upstream backend_hosts {
# server localhost:3000;
server unix:///var/www/share/sockets/puma.sock;
}
server {
listen 80;
server_name yoursite.com;
location / {
proxy_pass http://backend_hosts;
}
}
Now, wrap everything up, enable the things, open the firewall, and do a good reboot at some point to make sure it ACTUALLY works.
sudo systemctl enable puma
sudo systemctl enable nginx
sudo systemctl start puma
sudo systemctl start nginx
sudo service nginx status
sudo service puma status
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload
No comments:
Post a Comment