-
Notifications
You must be signed in to change notification settings - Fork 59
Linux(Ubuntu) Setup
After finishing this doc you will have VSCode(Optional if you have another code editor), Node.js, npm(included in Node), yarn, Git, and PostgreSQL installed on your machine.
- Vist VSCode to download VSCode.
- Launch the installer and follow the onscreen prompts.
- When you reach the section for
Additional tasks
, make sure every box is checked. - Click install and continue to follow and onscreen prompts.
Once you are done, you can open up a terminal (the Ubuntu App) and type code
to open VSCode. This may or may not require a restart first.
- Open the Ubuntu app and type
cd ~
to bring you into the Ubuntu FS. - Type
sudo apt-get update
. This will tell Ubuntu's apt tool to update. - After it is done updating run the command:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
then run:
sudo apt-get install -y nodejs
We will also install Node on Windows:
- Visit https://nodejs.org/en/download/ and download and run the Windows installer.
- Please run the following commands to import the repository’s GPG key and add the Yarn APT repository to your system:
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
- Then run this line to update your package list, and install Yarn:
sudo apt update
apt install --no-install-recommends yarn
- To verify installation, run this line:
yarn --version
Git is already installed on Ubuntu as it comes built in. VSCode however also uses Git for it's source-control tool to work. But since VSCode is a Windows application, it doesn't know how to use Ubuntu's version of Git.
-
Visit git-scm.com to download and install Git.
-
Follow the onscreen instructions.
- Choose the default values for each prompt...
-
EXCEPT when it asks you to
Choose the default editor used by Git
...- click the drop down and choose the VSCode option
- Do NOT choose the "VSCode Insiders" option.
- This will allow you to handle merge conflicts in your editor instead of in your command line which is another reason to have Git on Windows as well.
-
Continue choosing the default options to finish the installation.
The final step here is to add your email and name to the Git config. This will allow you to commit and push things to GitHub. Make sure to include the space after .email
and .name
, and always remember to close your quotes ' ' and " ".
- Close and re-open a new Ubuntu terminal
- Type
git config --global user.email 'your email here in single quotes'
. - Type
git config --global user.name 'Your Name In Single Quotes'
. - Type
git config --global core.editor 'code --wait'
.
By the time you’ve completed the guide, you should be able to run the following commands in your terminal:
git --version
node --version
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.
- Open a terminal (the Ubuntu app) and then go to the root of the Ubuntu Subsystem by typing
cd ~
. - Run
lsb_release -a
and make note of theCodename
listed. - Type
sudo nano ../../etc/apt/sources.list
. This will open a file on Ubuntu using the Nano editor. - At the bottom of this file, paste in the line
deb http://apt.postgresql.org/pub/repos/apt/ CODENAME-pgdg main
, replacing CODENAME with the word you noted in step 2. - When that's done, press
ctrl + x
together to close the file, pressy
when prompted to save your changes, andenter
to finally close. - Next, copy these 2 lines and paste them into your terminal:
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.
- After the update is complete, enter in the line
sudo apt-get install postgresql-10
and pressy
when prompted. - To launch the postgres service, type
sudo service postgresql start
.
Verifying Installation And Setting A Password
- You should be able to run the command
sudo -u postgres psql
. You will be asked for your administrator password - this is what you usually enter when you runsudo
commands. This will log you into the psql prompt as the user postgres. - You should now have a prompt that looks like
postgres=#
. You can run SQL commands from here, which must end in semicolons. - If you were not prompted for a default user or password, we will set one using psql. If you type
\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. - In your SQL shell, type the following:
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. - If successful, you will receive the feedback
CREATE ROLE
. - Now we need to grant that user administrative control. In your SQL shell, type the following:
ALTER ROLE your-username-here WITH superuser;
, replacing "your-username-here" with the username you created a role for in the previous step. - If successful, you will receive the feedback
ALTER ROLE
. - Next, we need to create a default database for your new user and assign ownership of it to your new account. In the SQL shell, type the following:
CREATE DATABASE your-username-here;
, replacing "your-username-here" with your username. On success, you will receive the feedbackCREATE DATABASE
.- Note: You might get a
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.
- Note: You might get a
- To change the owner of your database from the
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 feedbackALTER DATABASE
. - Close your SQL shell with
\q
orctrl-D
. Typepsql
again and your SQL shell should now open as your default user. Hooray!
If Using PostgreSQL Version > 11 OR Having Postgres Issues
-
Using your ubunutu WSL terminal, navigate to
/etc/postgresql/11/main
and open the postgresql.conf file withcode postgresql.conf
-
Search for the setting
fsync
, it may be commented out. -
The full line should read exactly:
fsync=off # flush data to disk for crash safety
Since typing out sudo service postgres 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.
- Open a terminal and type
cd ~
, then typenano .profile
. This will open your.profile
which controls what your terminal does and looks like. - Add this line next to any other aliases that you have:
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.