1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Full stack for frontend kho tài liệu bách khoa

137 52 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 137
Dung lượng 5,02 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Nginx engine x“A HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server” ● reverse proxy ● http server... $ sudo apt-get install nginx install nginx $

Trang 1

Full Stack

for Frontend Engineers

Frontend Masters

Trang 2

Jem Young

Senior Software Engineer

Trang 4

How does the internet work?

Trang 5

http://www.cisco1900router.com/wp-content/uploads/2013/03/1-tutorial-osi-7-layer-model.gi f

Trang 6

Things you’ll learn

● Level up your command line skills

● How the internet works

● How to create and manage a web server

● Create a deploy system for a Node app

● Build a basic web page

Trang 8

Domains

Trang 11

www.jemyoung.com === 23.23.185.61

Trang 12

Ping

Trang 13

$ ping google.com

Trang 17

Trace Route

Trang 18

Trace Route

$ tracert netflix.com $ traceroute netflix.com

Trang 19

ICMP - Internet Control Message Packet

Trang 21

VIM

Trang 22

of which must be learned.”

http://www.vim.org/about.php

A ubiquitous text editor

Because servers don’t have GUI’s

Trang 23

$ vi

Trang 26

command modeinsert mode last-line mode

Trang 27

VIM - insert mode

1 press i

2 type “Haha VIM is easy”

https://vimgifs.com/i/

Trang 28

VIM - command mode

Trang 29

VIM - command mode

1 type “Hello, world!”

7 press n to search forward

8 press N to search backward

Trang 30

https://linuxmoz.com/vi-commands-cheat-sheet/

http://vim.wikia.com/wiki/Copy,_cut_and_paste

Trang 31

editing and saving in VIM

Trang 32

VIM - last-line mode

Trang 33

Take a few minutes to practice writing and saving We will be using VIM later.

Trang 35

Logging into server

Trang 36

Logging into a server

$ ssh student@138.197.253.87

*Updated 4/17/17

Trang 39

username/password

Authentication

ssh key

Trang 40

What’s wrong with logging in with a

password?

Trang 42

A day in the life of a server

Trang 43

Public Key Authentication

SSH - Secure Socket Shell

Trang 45

Creating an SSH key

Trang 46

Creating an SSH Key

$ cd ~/.ssh/

$ ssh-keygen -t rsa

Trang 48

Don’t lose your private key!

Trang 49

Servers

Trang 50

VPS - Virtual Private Server

● Dedicated server

● VPS

Trang 51

Dedicated Server

VPS VPS VPS VPS

Trang 52

VPS VPS VPS VPS

Trang 54

Buy a VPS

Trang 55

Buying a VPS

www.digitalocean.com

Trang 56

Buying a VPS

Trang 60

$ cat ~/.ssh/my_key.pub

paste your public key

Trang 61

Buying a VPS

Trang 62

Log into your very own server!

Trang 63

Log into your server

$ ssh -i ~/.ssh/my_key root@$YOUR_SERVER_IP

Trang 65

top

Trang 66

$ top

Trang 68

Set up your server

Trang 69

Set up your server

$ apt-get update

$ adduser $USERNAME

update software

create a new user

$ usermod -aG sudo $USERNAME add user to sudo group

$ apt-get upgrade

Trang 70

Set up your server

Trang 71

Set up your server

$ exit

$ exit

Trang 72

Set up your server

$ cat ~/.ssh/my_key.pub | ssh $USERNAME@$SERVER_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Trang 73

Set up your server

$ cat ~/.ssh/my_key.pub |

print the contents of

my_key.pub and pipe the output to the next command

$ ssh $USERNAME@$SERVER_IP ssh into your server

Trang 74

Set up your server

$ mkdir -p ~/.ssh

make a ssh folder in your home directory if it doesn’t already exist

$ cat >> ~/.ssh/authorized_keys"

write the contents of the output to the file

authorized_keys

Trang 75

Set up your server

$ cat ~/.ssh/my_key.pub | ssh $USERNAME@$SERVER_IP "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Trang 76

Set up your server

$ ssh -i ~/.ssh/my_key.pub $USERNAME@$SERVER_IP

Trang 77

Set up your server

disable root login!

Trang 80

Set up your server

$ sudo vi /etc/ssh/sshd_config

disable root login

PermitRootLogin no

$ sudo service sshd restart restart ssh

PasswordAuthentication no allow only ssh to login

Trang 82

Buy a domain

Trang 83

Buy a domain

www.namecheap.com

Trang 84

Buy a domain

Trang 85

1 Get the IP address of your VPS

2 Add 2 A Records with your IP address

○ @

○ www

Trang 86

Buy a domain

Trang 87

“The A record maps a name to one or more IP addresses, when the IP are known and stable.”

“The CNAME record maps a name to another name.”

https://support.dnsimple.com/articles/differences-between-a-cname-alias-url/

Trang 88

jemyoung.com

23.23.185.61

Trang 89

http://keycode.info/

https://github.com/wesbos/keycodes/blob/gh-pages/CNAME

Trang 91

Two main types of server operating systems

BSD linux* solarisfreeBSD

OSX/MacOS ubuntu red hat

* there are a lot more than 3

debian

Trang 93

Common unix commands

Trang 94

Ubuntu

Trang 95

Nginx (engine x)

“A HTTP and reverse

proxy server, a mail

proxy server, and a

generic TCP/UDP

proxy server”

● reverse proxy

● http server

Trang 97

PROXY

Trang 98

PROXY NODE

Trang 99

Nginx

Trang 100

$ sudo apt-get install nginx install nginx

$ sudo service nginx start start nginx

type your server's IP address into a browser

Trang 101

$ sudo cat /etc/nginx/sites-available/default

$ sudo less /etc/nginx/sites-available/default

Trang 102

jemyoung.com

23.23.185.61

Nginx/Apache

Trang 103

Setup continued

$ sudo apt-get install git install git

$ sudo apt-get install nodejs npm install node and npm

Trang 104

Setup continued

$ sudo mkdir -p /var/www make a web directory (if

it doesn’t already exist)

$ sudo ln -s /usr/bin/nodejs /usr/bin/node

symlink nodejs to node

Trang 105

Setup continued

$ sudo chown -R $USER:$USER /var/www

change ownership of the web directory to the current user

$ cd /var/www move into to web directory

Trang 106

Setup continued

$ git clone https://github.com/young/Dev-Ops-for-Frontend.git

clone the git repo

Trang 107

Setup continued

$ mv Dev-Ops-for-Frontend/ app/ rename directory to app/

Trang 108

Setup continued

type in your server’s IP

address in a browser,

port 3001

Trang 111

type in your server’s IP address or domain name in a browser

Trang 112

$ sudo service nginx reload

Trang 113

Nginx jemyoung.com

23.23.185.61

Nginx/Apache

Node

Trang 114

html

Trang 115

$ cd /var/www/app/ move into to app directory

$ git checkout -b some_branch_name make a new branch

$ vi index.html

modify the html to your hearts content

Trang 116

Part 5

Deploy

● Build a gulp file

● Build a deploy system

Trang 117

How do we build and

deploy our app?

Trang 119

Gulp

Trang 120

Create gulp tasks

Trang 121

Create gulp tasks

1 Open gulpfile.js in VI It’s in the root directory of the demo

project

2 Fill in the gulp task clean-css so that any css files in the dist

folder are removed

3 Add your new task to build task

Trang 122

Create gulp tasks

1 Create a gulp task to compile and concat your less files The css should be placed in the dist folder.

2 Add your new task to build task.

Trang 123

Gulp

Trang 124

$ sudo mkdir -p /usr/local/lib/node_modules

https://docs.npmjs.com/getting-started/fixing-npm-permissions

Trang 125

How do we keep our app up

and running?

Trang 127

Run Forever

Trang 128

Run Forever

$ pwd/var/www/app

$ npm i -g forever

Trang 129

Run Forever

$ sudo mkdir /var/log/forever create a log file for the

forever process

$ sudo chown -R $USER /var/log/forever

change owner to current user

Trang 130

Run Forever

$ forever start app.js >> /var/log/forever/forever.log

start forever and log the output

Trang 131

tailing a log file

Trang 132

$ sudo tail -f /var/log/auth.log

Trang 133

Putting it all together

Trang 135

Build and Deploy

$ npm run deploy

Trang 136

HOORAY!!

Ngày đăng: 16/11/2019, 21:02

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN