-
Notifications
You must be signed in to change notification settings - Fork 36
Deploy TrustyCMS 3.5.0 to Digital Ocean droplet
Create a Digital Ocean Droplet from your username page.
Choose an image, click on One-click apps, select Ruby-onRails on Ubuntu 18.04, choose a size (1GB is fine), choose a datacenter region and click "Create".
You will recieve an email with the IP and other instructions.
Use the IP to login from Terminal using SSH:
Follow the instructions to set up your new root password.
apt-get update
apt-get install mysql-server
mysql_secure_installation
# asks you to enter mysql root password
apt-get install libmysqlclient-dev
sudo -i -u rails
# get to rails user
cd example
#"example" is the rails directory created by Digital Ocean. You can change the name.
vi Gemfile
#check that gem 'rails' is '5.2.1'. Use "i" key to edit, Press to exit editing mode, then type ':wq' to write the file and exit vim.
gem install bundler
bundle update
bundle install
rails app:update
# enter "Y" to everything
echo "gem 'trusty-cms', '3.5.0'" >> Gemfile
echo "gem 'rails-observers'" >> Gemfile
bundle update
bundle install
rails g trusty_cms rails_project
# Y to everything
su - root
#back to root user
sudo nano /etc/nginx/sites-available/rails
# Change proxy_pass http://localhost:3000
to proxy_pass http://0.0.0.0:3000
. To exit nano, type Control + X . If you ask nano to exit from a modified file, it will ask you if you want to save it. Just press Y [enter]
sudo mysql -u root -p
#if set, enter root password for mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new-password';
#replace 'new-password' with your password that goes in database.yml
mysql> exit
[enter] #exit mysql.
sudo service mysql stop
#Stop and start the mysql server.
sudo service mysql start
mysqld --verbose --help | grep ^socket
#This displays location of socket, which should be /var/run/mysqld/mysqld.sock
sudo -i -u rails
cd example
vi config/database.yml
# Make sure that under "production" your mysql username ("root") and password are added, and change socket to /var/run/mysqld/mysqld.sock
add new lines to three files:
vi config/environments/development.rb
# add config.eager_load = false
vi config/environments/test.rb
# add config.eager_load = false
vi config/environments/production.rb
# add config.eager_load = true
While in config/environments/production.rb comment out [i.e. put #
in front of]:
config.action_controller.consider_all_requests_local = false
and check that this is commented out:
`#config.logger = SyslogLogger.new'
vi config/application.rb
press 'i' to edit,
Go to line 57,
config.extensions = [ ]
add the extensions so it looks like
config.extensions = [ :snippets, :clipped, :layouts, :reorder, :multi_site, :rad_social]
Press [esc] to exit editing mode, then type ':wq' to write the file and exit vim.
vi package.json
#copy the dependencies from the Trusty package.json to the package.json in RAILS_ROOT
su - root
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
sudo service mysql restart
#not necessary if you already rebooted server.
bundle exec rake assets:precompile RAILS_ENV=production
bundle exec rake db:create RAILS_ENV=production
#should return "Created database 'rails_project_blank_live'"
bundle exec rails db:migrate RAILS_ENV=production
bundle exec rake trusty_cms_engine:install:migrations RAILS_ENV=production
bundle exec rake db:bootstrap RAILS_ENV=production
rails s -e production
# however puma exited, so:
lsof -wni tcp:3000
# get the PID number, below it is 1562
kill -9 1562
rails s -e production
# to stop puma just use control + C ...or alternatively:
rails server -d -e production
# start a daemonized server (run the server in the background) by adding -d to your command. To stop the server kill it using kill $(cat tmp/pids/server.pid)