Centos7-Redmine-Nginx-Passenger安装

混江龙づ霸主 提交于 2020-02-29 10:51:45

Step 1 - Redmine application

wget http://www.redmine.org/releases/redmine-3.4.3.tar.gz
cp redmine-3.4.3.tar.gz /var/www
cd /var/www
tar -zxf redmine-3.4.3.tar.gz 
mv redmine-3.4.3 redmine
cd redmine/

Step 2 - Create an empty database and accompanying user

yum -y install mariadb-server mariadb
systemctl enable mariadb.service
mysql_secure_installation
mysql -u root -p
CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';

Step 3 - Database connection configuration

cp config/database.yml.example config/database.yml
vim config/database.yml

production: adapter: mysql2 database: redmine host: localhost username: redmine password: my_password encoding: utf8

Step 4 - Dependencies installation

yum install gem rubygems
yum install libxml2-devel zlib-devel ruby-devel mariadb-devel ImageMagick-devel libcurl-devel
gem sources --remove https://rubygems.org/
gem sources -a https://ruby.taobao.org/
gem install bundler
bundle install --without development test

Step 5 - Session store secret generation

bundle exec rake generate_secret_token

Step 6 - Database schema objects creation

RAILS_ENV=production bundle exec rake db:migrate

Step 7 - Database default data set

RAILS_ENV=production bundle exec rake redmine:load_default_data
zh

Step 8 - File system permissions

E.g., assuming you run the application with a redmine user account:

mkdir -p tmp tmp/pdf public/plugin_assets
sudo chown -R redmine:redmine files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets

Step 9 - Test the installation

bundle exec rails server webrick -e production http://localhost:3000/

Step 10 - Logging into the application¶

login: admin password: admin

Step 11 - Web Server

gem install passenger
passenger-install-nginx-module

Nginx with Passenger support was successfully installed. The Nginx configuration file (/opt/nginx/conf/nginx.conf) must contain the correct configuration options in order for Phusion Passenger to function correctly.

This installer has already modified the configuration file for you! The following configuration snippet was inserted:

http {
...
passenger_root /usr/local/share/gems/gems/passenger-5.0.21;
passenger_ruby /usr/bin/ruby;
...
}

After you start Nginx, you are ready to deploy any number of Ruby on Rails applications on Nginx.

Step 12 - 在centos7版本下增加nginx service

vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecStop=/opt/nginx/sbin/nginx -s stop
ExecReload=/opt/nginx/sbin/nginx -s reload
KillMode=process
KillSignal=SIGQUIT
TimeoutStopSec=5
PrivateTmp=true

[Install]
WantedBy=multi-user.target
#systemctl enable nginx.service

Step 13 - Configure nginx run redmine

vim /opt/nginx/conf/nginx.conf

增加一行在后面,如: passenger_root /usr/local/share/gems/gems/passenger-5.0.21; passenger_ruby /usr/bin/ruby; passenger_app_env production; 注释并修改如下:

# location / {
# root html;
# index index.html index.htm;
# }
root /var/www/redmine/public;
passenger_enabled on;

重启服务:

systemctl restart nginx.service

Step 14 - Configure redmine mail发送通知

cd /var/www/redmine/config
cp configuration.yml.example configuration.yml 
vim configuration.yml

修改如下:

default:
# Outgoing emails configuration
# See the examples below and the Rails guide for more configuration options:
# http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
email_delivery:
delivery_method: :smtp
smtp_settings:
address: MY_SMTP_DOMAIN
port: 25
domain: MY_DOMAIN
authentication: :login
user_name:MY_MAIL_USER
password: MY_MAIL_PASS

重启服务:

systemctl restart nginx.service
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!