Go to your home directory and check out your source code.
cd ~
git clone /path/to/my_project.git
Go to your project directory.
cd my_project
Install the required gems.
bundle install
Update your production database credential in database.yml
production:
<<: *default
host: 127.0.0.1
port: 3306
database: database_name
username: database_user
password: password
Generate your production secret key base:
rake secret
Copy the generate key into secrets.yml
production:
secret_key_base: your_key_here
Update your production configuration in /config/environments/production.rb, such as SMTP info, and other credentials.
Update the timezone of the app in application.rb
config.time_zone = 'Kuala Lumpur'
Create database and generate schema
rake db:create db:migrate db:seed
Precompile assets and resources
rake assets:clean assets:precompile
Next, create a server block in your Nginx config to serve this app. For example:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name your_domain.com;
passenger_enabled on;
rails_env production;
root /home/username/my_project/public;
}
You will also need to adjust ulimit of your machine. The default value is usually not production ready. You can check the value by executing the command below.
ulimit -n
To set a custom value, create a file in limits.d:
sudo pico /etc/security/limits.d/mylimits.conf
Then and the following lines into the file and save it. Log-out and log-in your terminal and check the ulimit value again to make sure it takes effect. The value can be adjusted base on your need.
* soft nofile 10000
* hard nofile 10000
* soft nproc 10000
* hard nproc 10000
Next, in your nginx.conf, modify the events connection value.
worker_processes auto;
events {
worker_connections 10000;
}
Next, update the maximum client body size to a greater value if you intend to upload large file such as images.
http {
client_max_body_size 5m;
}
Finally, restart your Nginx server.