创建生产环境数据库并执行迁移
$ RAILS_ENV=production rake db:create
$ RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake secret
将输出的一大串字码粘贴到rails工程中/config/secrets.yml去,替换掉该文件中的<%= ENV["SECRET_KEY_BASE"] %>,如下:
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
重新compile assets,这样所有的图片,CSS,scripts才会加载
$ RAILS_ENV=production rake assets:precompile
rake kindeditor:assets
关闭和重启nginx
sudo kill $(cat /opt/nginx/logs/nginx.pid)
sudo /opt/nginx/sbin/nginx
生产环境下启动sidekiq
RAILS_ENV=production bundle exec sidekiq
一定要先启动sidekiq再启动nginx,不然访问不到/sidekiq后台管理页面
关闭sidekiq
ps aux | grep sidekiq
sudo kill 对应的进程
mysql数据库用户名和密码配置文件
config/database.yml
操作mysql数据库
1、mysql -u root -p
输入系统密码
2、show databases;
3、show tables;
sudo docker run -d --restart=always -p 8888:80 -u 0 --name rails-tax
redis安装
https://www.cnblogs.com/zongfa/p/7808807.html
检查Redis服务器系统进程
~ ps -aux|grep redis redis 4162 0.1 0.0 10676 1420 ? Ss 23:24 0:00 /usr/bin/redis-server /etc/redis/redis.conf conan 4172 0.0 0.0 11064 924 pts/0 S+ 23:26 0:00 grep --color=auto redis
通过启动命令检查Redis服务器状态
~ netstat -nlt|grep 6379 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN