Server setup Flashcards
What are the types of DNS records?
A records: map a name to an IP address.
CNAME: maps name to name (e.g. a subdomain first maps to the domain name, which then maps to the IP address).
Bash command for running previous command as sudo?
sudo !!
bash command for opening a file and showing me anything new that happens in it in real time
sudo tail -f /var/log/auth.log (tail shows end of the file, -f is for follow, which means it always shows the bottom even after updates)
What is a very good way to debug a server when you can’t figure out what is going on?
“sudo tail -f” your log files and then log in to the server and see what the log file reveals…
What does sshd stand for?
ssh daemon. it is a service that is always running in the background. you can edit it (for example to prevent root login) using $vi /etc/ssh/sshd_config.
If you updated it, you would have to restart the service so it picks up the new config: $sudo service sshd restart
What is nginx?
One of the most popular web servers (another popular one is apache…which goes super well with PHP). Nginx is lightweight and extremely fast.
- reverse proxy (takes a single request and can route it to a number of different places)
- web server
- proxy server (takes a number of requests and can route them to a single place)
- file server
What does a web server do?
It receives web traffic and does something with it (routes it somewhere).
When a request hits the server, it has to figure out where to go - should it go to the app, should it go to the db, should it go to a different server?
Nginx helps route the requests to the correct place.
What is a proxy server? What is a reverse proxy server?
- proxy server (takes a number of requests and can route them to a single place)
- reverse proxy (takes a single request and can route it to a number of different places)
What is a directive in nginx?
A directive is a macro for doing something, e.g. try_files, which tries to find any of the files listed, and if it can’t find them it 404s, or proxy_pass, which passes your requests to another part of the server.
e.g.
location / {
proxy_pass http://127.0.0.1:3000/;
}
This basically tells nginx that any request it receives to / should be forwarded to port 3000 at this ip address, which is the port on which the express server is running, so it is basically saying let our app server handle any requests to /.
What is the difference between a web server and an application server?
The web server just receives web traffic and does something with it. The application server does all the heavy lifting.
What is node.js?
It’s a single-threaded JS engine that executes JS and can handle requests.
It is a JS engine that runs on top of V8 (which was developed by google chrome) .
Single-threaded means that it can handle async very well, i.e. it doesn’t block the execution until a request returns a response. It’s easy for JS developers to take this single-threaded async nature for granted, but almost all other languages (e.g. python or java) are not like this, and if you make a request for a large piece of data it will block everything while you are waiting for the request to resolve.
This async nature of node is what is known as the event loop.
This is a good reason to use node for servers.
What is a good reason for using node for a server?
Because it is single-threaded. Single-threaded means that it can handle async very well, i.e. it doesn’t block the execution until a request returns a response. It’s easy for JS developers to take this single-threaded async nature for granted, but almost all other languages (e.g. python or java) are not like this, and if you make a request for a large piece of data it will block everything while you are waiting for the request to resolve.
This async nature of node is what is known as the event loop.
It is not the fastest, java or go are probably the fastest. You will rarely be limited by the speed of the engine that you’re using, but by the code that you wrote.
Why is application architecture important?
Thinking about this is the difference between a junior engineer/programmer and a senior software engineer. Thinking about: - long-term maintainability - how you arrange: -- files -- code
Migrating files is not fun.
What is a very basic example app architecture?
- UI
- css
- js
- html
- helpers
- utils
- authentication
Command line: how would you change a user’s permissions for a folder?
sudo chown -R $USER:$USER /opt/iul