用centos 搞了3-4天仪表盘仍然有各种报错,索性祭出终极大法,换Ubuntu
ubuntu默认没开ssh,无法远程,先开sshd
sudo apt-get install openssh-server
sudo /etc/init.d/ssh start
先下载一些库
apt-get install git libmysqlclient-dev libpq-dev libsqlite3-dev ruby-dev libxml2-dev libxslt-dev nodejs
git也要安装下
sudo apt-get update
sudo apt-get install git
下载仪表盘程序
cd /usr/share
sudo mkdir -pv puppet-dashboar
cd puppet-dashboard
sudo git clone https://github.com/sodabrew/puppet-dashboard.git
安装mariadb
sudo apt install mariadb-server
启动下
/etc/init.d/mysql start
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &
mysql -u root
select Host,User,plugin from mysql.user where User='root';
update mysql.user set plugin='mysql_native_password';
update mysql.user set password=PASSWORD("12345.coM") where User='root';
flush privileges;
systemctl stop mysql
mysql就不贴图了
配置下mysql缓存
vim /etc/mysql/my.cnf
加一行
max_allowed_packet = 32M
systemctl start mysql
创建表和用户
CREATE DATABASE dashboard_production CHARACTER SET utf8;
CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON dashboard_production.* TO 'dashboard'@'localhost';
把样本复制出来,填入数据库连接信息
sudo cp config/settings.yml.example config/settings.yml
sudo cp config/database.yml.example config/database.yml
sudo vim config/database.yml
安装gem,并且用gem 部署bundle
sudo gem install bundler
sudo bundle install --deployment
一路顺畅
设置数据库和编译
sudo RAILS_ENV=production bundle exec rake db:setup
生产环境缺少密码
cd config
vim secrets.yml
里面开发和测试环境都是hard code写的安全码
生产环境不建议存明文密码
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.
建议通过
export SECRET_KEY_BASE=$(bundle exec rails secret)
我先创建测试环境
sudo RAILS_ENV=test bundle exec rake db:setup
创建test表和用户
CREATE DATABASE dashboard_test CHARACTER SET utf8;
CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON dashboard_test.* TO 'dashboard'@'localhost';
仍然有外键冲突
不管了,先让我试试看预编译
sudo RAILS_ENV=test bundle exec rake assets:precompile
无报错
sudo RAILS_ENV=test bundle exec rails server
终于看到了久违的webui