Skip to content
This repository has been archived by the owner on Apr 30, 2018. It is now read-only.

Commit

Permalink
Update server creation docs
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbarclay committed Apr 10, 2017
1 parent acaa1bc commit ee6bd6f
Show file tree
Hide file tree
Showing 4 changed files with 567 additions and 5 deletions.
36 changes: 36 additions & 0 deletions docs/postgres.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
* Installation

To install the server locally use the command line and type:

sudo apt-get install postgresql postgresql-contrib

This will install the latest version available in your Ubuntu release and the commonly used add-ons for it.

See "External Links" below for options for getting newer releases.

* Server Setup

If you don't intend to connect to the database from other machines, this alternative setup may be simpler.

By default in Ubuntu, Postgresql is configured to use 'ident sameuser' authentication for any connections from the same machine. Check out the excellent Postgresql documentation for more information, but essentially this means that if your Ubuntu username is 'foo' and you add 'foo' as a Postgresql user then you can connect to the database without requiring a password.

Since the only user who can connect to a fresh install is the postgres user, here is how to create yourself a database account (which is in this case also a database superuser) with the same name as your login name and then create a password for the user:

sudo -u postgres createuser --superuser $USER
sudo -u postgres psql

postgres=# \password $USER

Client programs, by default, connect to the local host using your Ubuntu login name and expect to find a database with that name too. So to make things REALLY easy, use your new superuser privileges granted above to create a database with the same name as your login name:

sudo -u postgres createdb $USER

Connecting to your own database to try out some SQL should now be as easy as:

psql

Creating additional database is just as easy, so for example, after running this:

create database amarokdb;

You can go right ahead and tell Amarok to use postgresql to store its music catalog. The database name would be amarokdb, the username would be your own login name, and you don't even need a password thanks to 'ident sameuser' so you can leave that blank.
58 changes: 53 additions & 5 deletions docs/serverSetup.org
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

* Installing Ruby with RVM
Before you can deploy your app on the production server, you need to install Ruby. In this tutorial we recommend that you use Ruby Version Manager (RVM) for this purpose. RVM is a tool for installing and managing multiple Ruby versions.

Expand Down Expand Up @@ -248,10 +249,7 @@ $ nano config/database.yml
Ensure that the production section looks like this:
#+E

#+B text
production:
adapter: sqlite3
database: db/production.sqlite3

#+E
Rails also needs a unique secret key with which to encrypt its sessions. Starting from Rails 4, this secret key is stored in config/secrets.yml. But first, we need to generate a secret key. Run:

Expand All @@ -274,13 +272,58 @@ production:
#+E
Then replace it with the following. If the file didn't already exist, simply insert the following.


production:
secret_key_base: the value that you copied from 'rake secret'
To prevent other users on the system from reading sensitive information belonging to your app, let's tighten the security on the configuration directory and the database directory:
#+B bash
$ chmod 700 config db
$ chmod 600 config/database.yml config/secrets.yml
#+END_SRC

**** Email

The application uses the postmark service, http://www.postmarkapp.com. You will need to create an account on Postmark, go to an account page and copy the "Account Api Token" that they provide you.
Next, go to config/secrets.yml:

#+B bash
$ nano config/secrets.yml
#+E

Look for this in the file.
e#+B
production:
postmark_api_key: <%= ENV["POSTMARK_API_KEY"] %>
#+E

Then replace it with the following.

#+B
production:
postmark_api_key: the value that you copied from 'http://www.postmarkapp.com'
#+E


**** Setting Domain

We need to set the domain of the application, so that our email client can properly link users to the correct web pages.
Next, go to config/application.rb
#+B bash
$ nano config/application.rb
#+E

Find the following line in the file.

#+B
$ config.domain = ENV["DOMAIN"]
#+E

Replace that line with the following.

#+B
$ config.domain = https://www.yourdomain.com
#+E
nks
*** 2.4 Compile Rails assets and run database migrations

Run the following command to compile assets for the Rails asset pipeline, and to run database migrations:
Expand Down Expand Up @@ -353,12 +396,17 @@ When you are done, restart Nginx:
$ sudo service nginx restart
#+END_SRC

**** 3.3.1 Setting your SSL certificate

Because this app handles sensitive information, it is strongly suggested you follow the below guide on setting up an SSL certificate for a ruby on rails app.
https://www.pluralsight.com/guides/ruby-ruby-on-rails/using-https-with-ruby-on-rails

*** 3.4 Test drive

You should now be able to access your app through the server's host name! Try running this from your local computer. Replace yourserver.com with your server's hostname, exactly as it appears in the Nginx config file's server_name directive.

#+BEGIN_SRC bash
$ curl http://yourserver.com/
$ curl https://yourserver.com/
...your app's front page HTML...
#+END_SRC

Expand Down
Binary file modified docs/serverSetup.pdf
Binary file not shown.
Loading

0 comments on commit ee6bd6f

Please sign in to comment.