markdown 如何部署Rails应用程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 如何部署Rails应用程序相关的知识,希望对你有一定的参考价值。
## Local config
```bash```
# Comment this gems in your Gemfile
#gem "unicorn"
#gem "thin"
#gem "puma"
# Add Passenger gem to Gemfile
gem "passenger"
# Run bundler
bundle install
```
## Server config
```bash```
# Create app folder
sudo mkdir /var/www
# Clone project
git clone <repo> /var/www/myprojectname
# copy master.key file to server project root path
# Set permissions for folders
chmod 700 config db
chmod 600 config/database.yml config/secrets.yml
# Create database
bundle exec rake db:create RAILS_ENV=production
# Run migrations and compile assets
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
```
## Config Passenger in server
Enter in project root path and create Passengerfile.json with this config:
```json```
{
"environment": "production",
"port": 80,
"daemonize": true,
"user": "root"
}
```
## Start/Stop server
```bash```
sudo bundle exec passenger start
sudo bundle exec passenger stop
```
## Config passenger to exec when system boot
```bash```
sudo chmod +x /etc/rc.local
sudo vi /etc/rc.local
```
```bash```
# THIS CODE ABOVE GOES ON rc.local FILE:
#
#
cd /var/www/myapp/code
bundle exec passenger start
```
# DEPLOY SUCCESS !!!
## To update project
```bash```
cd /var/www/production
git pull origin master
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
sudo bundle exec passenger stop
sudo bundle exec passenger start
```
以上是关于markdown 如何部署Rails应用程序的主要内容,如果未能解决你的问题,请参考以下文章
markdown 如何解决Rails(OSX)中的OpenSSL错误?
如何在 OpsWorks 部署到 Rails 堆栈期间始终运行迁移
如何将 Rails + Webpacker 应用程序部署到 Heroku?
如何使用 Redcarpet for Rails 在 Markdown 中嵌入 YouTube 视频?
部署了两个 Rails 应用程序 - 如何更改默认应用程序?
如何将 Rails 应用程序部署到 EC2(亚马逊)