Redmine 部署记录

本文是部署 Redmine 过程中问题的记录。

npm cache clean --force # 清空缓存

==========================================================

YARN

==========================================================

yarn config set registry https://registry.npmmirror.com # 注册模块镜像 yarn config set disturl https://npmmirror.com/mirrors/node # node-gyp 编译依赖的 node 源码镜像

以下选择添加

yarn config set sass_binary_site https://registry.npmmirror.com/mirrors/node-sass # node-sass 二进制包镜像 yarn config set electron_mirror https://registry.npmmirror.com/mirrors/electron/ # electron 二进制包镜像 yarn config set puppeteer_download_host https://registry.npmmirror.com/mirrors # puppeteer 二进制包镜像 yarn config set chromedriver_cdnurl https://registry.npmmirror.com/mirrors/chromedriver # chromedriver 二进制包镜像 yarn config set operadriver_cdnurl https://registry.npmmirror.com/mirrors/operadriver # operadriver 二进制包镜像 yarn config set phantomjs_cdnurl https://registry.npmmirror.com/mirrors/phantomjs # phantomjs 二进制包镜像 yarn config set selenium_cdnurl https://registry.npmmirror.com/mirrors/selenium # selenium 二进制包镜像 yarn config set node_inspector_cdnurl https://registry.npmmirror.com/mirrors/node-inspector # node-inspector 二进制包镜像 yarn config set sentrycli_cdnurl https://npmmirror.com/mirrors/sentry-cli/ # sentry-cli

yarn cache clean # 清空缓存



- `Generated checksum for "electron-vxx.y.zz-win32-x64.zip" did not match expected checksum.` 问题

在 WSL/Debian 中,修改 Windows 主目录下的 `.npmrc` 文件,加入以下内容。


```bash
➜  Hector PENG pwd
/mnt/c/Users/Hector PENG
➜  Hector PENG cat .npmrc
registry=https://registry.npmmirror.com
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/

参考

02. MAVEN 配置华为镜像

修改 ~/.mvn/settings.xml, 在<mirrors></mirrors>里加入以下内容:

<mirror>
    <id>huaweicloud</id>
    <mirrorOf>*</mirrorOf>
    <url>https://repo.huaweicloud.com/repository/maven/</url>
</mirror>

也可以直接下载 settings.xml 文件

Apache Maven 的安装:

$sudo tar xf apache-maven-3.x.x-bin.tar.gz -C /opt/ $sudo ln -s /opt/apache-maven-3.x.x /opt/mvn

建立 /etc/profile.d/mvn.sh,加入如下内容:

export JAVA_HOME=/opt/jdk
export M2_HOME=/opt/mvn
export MAVEN_HOME=/opt/mvn
export PATH=${M2_HOME}/bin:${PATH}
  • 注意 *:/opt/jdk 也是到 /opt/jdk-xx.x.x 目录的符号链接。

运行 $sudo chmod +x /etc/profile.d/mvn.sh

RubyGems

Ruby语言的开源依赖包镜像库。

使用说明 打开终端并执行如下命令:

gem sources --add https://repo.huaweicloud.com/repository/rubygems/ --remove https://rubygems.org/

如果你使用 Gemfile 和 Bundler,你可以用 Bundler 的 Gem 源代码镜像命令

bundle config mirror.https://rubygems.org https://repo.huaweicloud.com/repository/rubygems/

需要安装 build-essential

若没有安装 build-essential,会报出下面这样的错误:

"Gem::Ext::BuildError:  ERROR: Failed to build gem native extension."
"checking for unistd.h... *** extconf.rb failed *** "

"...lack of necessary libraries and/or headers."

需要安装 libpq-dev

若未安装 libpq-dev,则会报出:

Using config values from /usr/bin/pg_config                                                                                                         
checking for whether -Wl,-rpath,/usr/lib/x86_64-linux-gnu is accepted as LDFLAGS... yes                                                             
Using libpq from /usr/lib/x86_64-linux-gnu                                                                                                          
checking for libpq-fe.h... no                                                                                                                       
Can't find the 'libpq-fe.h header                                                                                                                   
*****************************************************************************                                                                                                                                                                                                                           
Unable to find PostgreSQL client library.                                                                                                                                                                                                                                                               
Please install libpq or postgresql client package like so:                                                                                            

sudo apt install libpq-dev                                                                                                                          
sudo yum install postgresql-devel                                                                                                                   
sudo zypper in postgresql-devel                                                                                                                     
sudo pacman -S postgresql-libs                                                                                                                                                                                                                                                                        
or try again with:                                                                                                                                    
gem install pg -- --with-pg-config=/path/to/pg_config                                                                                                                                                                                                                                                 
or set library paths manually with:                                                                                                                   
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/                                                                                                                                                                                                             
...

执行 RAILS_ENV=production bundle exec rake db:migrate 时的权限问题

参考:postgresql 15: additional steps required while initializing database

rake aborted!                                                                                                                                                                       
ActiveRecord::StatementInvalid: PG::InsufficientPrivilege: ERROR:  permission denied for schema public                                                                              
LINE 1: CREATE TABLE "schema_migrations" ("version" character varyin...                                                                                                                                     ^

需要执行:

sudo su - postgres
psql
postgres=# \c redmine postgres
postgres=# grant all on schema public to redmine;

注意:上面最后一行后面的 ; 必须输入。

rvm 与安装特定版本的 ruby 时遇到的问题

参考:Cannot install ruby version 2.6.6 on Ubuntu 22.04

rvm 是与 nvm 类似的 ruby 版本管理工具。在运行 rvm install ruby-x.y.z 安装特定版本会遇到失败的问题,检查日志文件:

/usr/local/rvm/log/1709778431_ruby-2.6.0/make.log

会发现:make: *** [uncommon.mk:286: build-ext] Error 2。此时需要先安装 openssl,然后再安装特定版本的 ruby:

rvm pkg install openssl
rvm install ruby-x.y.z --with-openssl-dir=/usr/local/rvm/usr
Last change: 2024-08-04, commit: df4e0d0