chatwoot安装

基础环境安装

首先确保咱们的yum源可用。

1.git安装.

yum -y install git

2.rvm安装

2.1、安装curl
yum -y install curl
2.2、安装rvm
https://www.icode9.com/content-3-1038798.html

没有报错,直接执行第四步;
如果出现以下报错请执行,请以此执行以下了,以下两条命令:

curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

2.3.再次执行安装命令
curl -L get.rvm.io | bash -s stable

2.4、执行命令,出现8条数据,说明安装成功
find / -name rvm -print

2.5、更新配置文件
source /etc/profile.d/rvm.sh
2.6、下载rvm的依赖
rvm requirements
2.7、查看rvm库中已知的ruby版本
rvm list known

2.8、安装需要ruby版本

我这边安装的是3.0.2

rvm install 3.0.2
2.9、使用指定版本的ruby
rvm use 3.0.2
2.10、设置默认版本
rvm use 3.0.2 --default
2.11、查看ruby版本
ruby -v

3.node、yarn安装

 sudo yum install -y nodejs

yarn安装执行:

 yum install -y yarn

如果提示不存在

1、添加yarn仓库

wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo

2、安装yarn

yum -y install yarn

4. redis安装

第一步:使用wget命令远程下载

wget -P /usr/local/src/ https://download.redis.io/releases/redis-6.0.9.tar.gz

第二步:进入到下载目录,解压tar.gz

tar zxvf redis-6.0.9.tar.gz

第三步:安装依赖GCC,确定机子上有GCC可跳过此步骤

yum -y install gcc-c++ autoconf automake  

第四步:进入到 redis-6.0.9.tar.gz解压目录,编译

make

我这里编译时报错,描述gcc版本过低问题部分代码:

server.c: 在函数‘allPersistenceDisabled’中:
server.c:1482:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
server.c: 在函数‘writeCommandsDeniedByDiskError’中:
server.c:3790:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}
^
server.c: 在函数‘iAmMaster’中:
server.c:4964:1: 警告:在有返回值的函数中,控制流程到达函数尾 [-Wreturn-type]
}

所以我这里对当前GCC进行升级


# 安装 centos-release-scl scl-utils-build
yum install -y centos-release-scl scl-utils-build
# 安装9版本的相关的 gcc工具
yum install -y devtoolset-9-toolchain
# 临时覆盖系统原有的gcc引用
scl enable devtoolset-9 bash
# 查看当前版本,显示gcc version 9...则表示成功
gcc -v

cd 到redis-6.0.9目录下,在进行make
第五步:后台启动
设置redis.conf下,daemonize的值改成yes即可

./redis-server ../redis.conf

5. postgress安装

5.1、安装存储库rpm包
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
5.2、安装客户端软件包
yum install postgresql12
5.3、安装服务端软件包(可选)
yum install postgresql12-server
5.4、初始化数据库并启用自动启动

初始化并启动服务 【这步先不要执行】

/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl enable postgresql-12
systemctl start postgresql-12

上面这步先不执行,默认postgreql 安装在/usr/pgsql-14,数据存储目录:/var/lib/pgsql/版本号/data,在实际生产中/var可能存在硬盘空间不足的问题,我们一般将数据存储目录放在挂载的硬盘如/data下

建立指定数据存储目录并赋予postgres用户权限:

sudo mkdir -p /data/postgresql_data 
sudo chown postgres:postgres /data/postgresql_data
sudo chmod 750 /data/postgresql_data

初始化数据库:

/usr/pgsql-12/bin/postgresql-12-setup initdb -D /data/postgresql_data
systemctl enable postgresql-12
systemctl start postgresql-12

或者我们进入:

/usr/lib/systemd/system/postgresql-12.service 

修改:修改Environment=PGDATA=/var/lib/pgsql/data这一行,如:

然后:

systemctl daemon-reload
5.5、操作

安装后的数据库data目录

/var/lib/pgsql/12/data

客户端程序目录

/usr/pgsql-12/bin

启动数据库

./pg_ctl -D /var/lib/pgsql/12/data start

客户端程序目录

/usr/pgsql-12/bin

启动数据库

./pg_ctl -D /data/postgresql_data start

服务安装

下载源代码进入根目录

1.安装依赖.

install ruby dependencies

bundle

Install JavaScript dependencies

yarn
2.设置环境变量
cp .env.example .env
3.编译前端
rake assets:precompile RAILS_ENV=production
4.数据库迁移
RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:reset
5.启动服务

修改:Procfile

#release: bundle exec rails db:chatwoot_prepare
web: bin/rails server -p 3000 -e production
worker: bundle exec sidekiq -C config/sidekiq.yml

执行指令:

foreman start -f Procfile

常见问题

Using devise-secure_password 2.0.1 from https://github.com/chatwoot/devise-secure_password (at master@de11e87)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-3.0.2/gems/pg-1.3.2/ext
/usr/local/rvm/rubies/ruby-3.0.2/bin/ruby -I /usr/local/rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20220417-21805-t8w5o5.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
Using libpq from /usr/lib64
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconninfo() in libpq-fe.h... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.3.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

查看版本:

[root@iZ0jl0r9llmeykqf9oqac8Z bin]# psql --version
psql (PostgreSQL) 9.2.24

解决方案:
https://stackoverflow.com/que...

查看版本:

 yum list installed postgres*


发现客户端跟服务端版本不一致

对/usr/bin/psql进行备份

mv /usr/bin/psql /usr/bin/psql.back

最后执行:

[root@iZ0jl0r9llmeykqf9oqac8Z bin]# ln -s /usr/pgsql-12/bin/psql /usr/bin/psql
[root@iZ0jl0r9llmeykqf9oqac8Z bin]# psql --version
psql (PostgreSQL) 12.10
[root@iZ0jl0r9llmeykqf9oqac8Z bin]# 

但是安装pg还是报错

[root@iZ0jl0r9llmeykqf9oqac8Z /]# gem install pg
Building native extensions. This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/rvm/gems/ruby-3.0.2/gems/pg-1.3.5/ext
/usr/local/rvm/rubies/ruby-3.0.2/bin/ruby -I /usr/local/rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0 -r ./siteconf20220417-26397-h22c2z.rb extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... yes
Using config values from /usr/bin/pg_config
Using libpq from /usr/lib64
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconninfo() in libpq-fe.h... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.3.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

安装完之后发现还是报第一次的错误mmp
解决方式:指定pg用的psql

find / -name psql
gem install pg -- --with-pg-config=/usr/pgsql-12/bin/pg_config
                                   /usr/pgsql-12/bin/pg_config

如果还是报错执行如下:

ln -s /usr/pgsql-12/bin/pg_config /usr/bin/pg_config

前端yarn时候deasync编译缓慢

我们只需要将其从依赖中去除即可:yarn.lock

deasync@^0.1.15:
  version "0.1.26"
  resolved "https://registry.yarnpkg.com/deasync/-/deasync-0.1.26.tgz#87f54440034b87afc1e6a46667930c4e06363256"
  integrity sha512-YKw0BmJSWxkjtQsbgn6Q9CHSWB7DKMen8vKrgyC006zy0UZ6nWyGidB0IzZgqkVRkOglAeUaFtiRTeLyel72bg==
  dependencies:
    bindings "^1.5.0"
    node-addon-api "^1.7.1"

deasync "^0.1.15"
数据库连接

[root@iZ0jl0r9llmeykqf9oqac8Z chatwoot]# psql -h 127.0.0.1 -d postgres -U postgres
psql: 错误: FATAL: Ident authentication failed for user "postgres"

[root@iZ0jl0r9llmeykqf9oqac8Z chatwoot]# find / -name pg_hba.conf
/data/chatwoot/postgresql_data/pg_hba.conf

修改local为trust
https://stackoverflow.com/que...

重启

systemctl restart postgresql-12.service 
UndefinedFile: ERROR: could not open extension control file "/usr/pgsql-

[root@iZ0jl0r9llmeykqf9oqac8Z chatwoot]# RAILS_ENV=production bundle exec rake db:reset
Dropped database 'chatwoot_production'
Created database 'chatwoot_production'
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedFile: ERROR: could not open extension control file "/usr/pgsql-12/share/extension/pg_stat_statements.control": No such file or directory

解决:/data/postgresql_data/postgres.conf

最后我安装了pg_stat_statements然后我就能启动postgresql了。 

添加到postgres.conf:

shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all
pg_stat_statements.max = 10000
track_activity_query_size = 2048
安装包postgresql-contrib-12.0:
 yum install -y postgresql12-contrib
重启postgresql服务:

然后进入:/usr/pgsql-12/share/contrib创建文件夹:pg_stat_statements


systemctl restart postgresql-12.service 
前端编译
[root@iZ0jl0r9llmeykqf9oqac8Z chatwoot]# yarn
yarn install v1.22.18
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://github.com/chatwoot/prosemirror-schema.git

编译报错时候:替换:package.json中的

 "@chatwoot/prosemirror-schema": "https://gitee.com/junweihuang_admin/prosemirror-schema.git#7e8acadd10d7b932c0dc0bd0a18f804434f83517",

为码云:

nginx安装

1.安装所需环境
//安装gcc
yum install gcc-c++
 
//安装PCRE pcre-devel
yum install -y pcre pcre-devel
 
//安装zlib
yum install -y zlib zlib-devel
 
//安装Open SSL
yum install -y openssl openssl-devel

2、创建nginx目录并下载安装包

//进入usr/local目录
cd /usr/local

//创建nginx目录
mkdir nginx

//进入nginx目录
cd nginx

//下载tar包
wget http://nginx.org/download/ngi...

//解压tar
tar -xvf nginx-1.13.7.tar.gz

参考:

https://www.cnblogs.com/lqqgi...

https://blog.csdn.net/Warm_da...

作者:startshineye 原文地址:https://segmentfault.com/a/1190000041715477

%s 个评论

要回复文章请先登录注册