Completion of the following setup tasks are all to be submitted in a single Canvas assignment. Keep a log of any errors or difficulties you encounter, and include those with your submission.
This doc assumes you are using the WSL in the way described in the 201 prework, or in this guide.
Create a directory $wr/codefellows/301/
to hold your work for this course, by running the command:
mkdir -p $wr/codefellows/301
Go to this link and follow the standalone install instructions (NOT the Windows instructions, NOT the Ubuntu instructions). This will install the Heroku CLI on your Ubuntu FS. This allows the CLI to run in a POSIX environment, fixing the Heroku:pg push
issue that exists on Windows.
Verify Installation
From the command line, type heroku --version
to verify that your Heroku installation was successful. Skip taking a screenshot (for your canvas assignment) until you can verify PostgreSQL as well.
You are now done with the Heroku CLI! Next you will be installing PostgreSQL 10!
In Code 301, Nodemon is a tool that is used to restart the server when changes are made in your server code.
In your terminal, run npm i -g nodemon. Run the command nodemon –version to confirm proper installation of Nodemon.
This doc explains how to install PostgreSQL 10 for Windows WSL
We are installing this through the Ubuntu command line since we want this software to run in the Linux environment. You can check out the PostgreSQL Linux install docs here.
cd ~
.lsb_release -a
and make note of the Codename
listed.sudo nano ../../etc/apt/sources.list
. This will open a file on Ubuntu using the Nano editor.deb http://apt.postgresql.org/pub/repos/apt/ CODENAME-pgdg main
, replacing CODENAME with the word you noted in step 2.ctrl + x
together to close the file, press y
when prompted to save your changes, and enter
to finally close. wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
This will add postgresql 10 to your repositories so you can install the latest version of Postgresql.
sudo apt-get install postgresql-10
and press y
when prompted.sudo service postgresql start
.Verifying Installation And Setting A Password
sudo -u postgres psql
. You will be asked for your administrator password - this is what you usually enter when you run sudo
commands. This will log you into the psql prompt as the user postgres.postgres=#
. You can run SQL commands from here, which must end in semicolons.\du
, you can get a list of users associated with PostgreSQL. You should see a single user, postgres
. You will need to set up a new role for your machine’s default user. This is the username that appears at the beginning of your terminal prompt, and when you log into your machine.CREATE ROLE your-username-here WITH LOGIN PASSWORD 'your-password-here';
, replacing “your-password-here” with whatever you want it to be. Remember that your password must be wrapped in quotes. The username should not be wrapped in quotes. Don’t forget the semicolon.CREATE ROLE
.ALTER ROLE your-username-here WITH superuser;
, replacing “your-username-here” with the username you created a role for in the previous step.ALTER ROLE
.CREATE DATABASE your-username-here;
, replacing “your-username-here” with your username. On success, you will receive the feedback CREATE DATABASE
.
WARNING: could not flush dirty data: Function not implemented
warning many times when you run this command. This is okay! Let the command keep running, and you should eventually see success.postgres
user to your user, type the folliwing: ALTER DATABASE your-username-here OWNER TO your-username-here;
, replacing “your-username-here” with your username. On success, you will receive the feedback ALTER DATABASE
.\q
or ctrl-D
. Type psql
again and your SQL shell should now open as your default user. Hooray!If Using PostgreSQL Version > 11 OR Having Postgres Issues
/etc/postgresql/11/main
and open the postgresql.conf file with code postgresql.conf
Search for the setting fsync
, it may be commented out.
fsync=off # flush data to disk for crash safety
Since typing out sudo service postgresql start
all the time can be tedious, and you’ll need to run this when you restart your computer, we recommend you set up an alias for this.
cd ~
, then type nano .profile
. This will open your .profile
which controls what your terminal does and looks like.alias pgstart='sudo service postgresql start'
This will allow you to type pgstart
to start running the psql service. This is an example of a Quality of Life enhancement, something that makes your life easier and faster as a developer.
You can change pgstart
to what ever you want, but just be careful you don’t overwrite something that postgres might use.
When you are finished installing the Heroku CLI and PostgreSQL, please move here to complete your Final Steps.