Macbook
GitbookEnv2021-02-16
๐ ๆดๆฐ node ็ๆฌ
ๅ ไธบๆfsevents
่ญฆๅ๏ผ ้่ฆๆดๆฐ macbook ็node
็ๆฌ 8.11 -> v13.7.0
$ brew update
$ brew upgrade node
ๆ่
๏ผ
$ sudo n latest
๐ yarn
$ yarn cache clean
$ yarn list | grep fsevents
$ yarn install --check-files
$ yarn cache clean && yarn upgrade && yarn
๐ mysql ๅ nginx ไธ work ็่งฃๅณๆนๆณใ
$ xcode-select --install
$ brew services list
$ vi /usr/local/etc/nginx/nginx.conf
$ brew services start mysql; // start/restart/stop
$ brew services restart nginx
$ brew info nginx
$ netstat -ap tcp | grep -i listen
๐ช HTTPS protocol for localhost using NGINX in OSX
๐ ๅฎ่ฃ
nginx
$ brew install nginx
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/
.
To have launchd start nginx now and restart at login:
brew services start nginx
Or, if you donโt want/need a background service you can just run:
nginx
nginx
ๅฎ่ฃ
ๅจ/usr/local/Cellar/nginx/1.17.8
$ brew services restart nginx
$ sudo nginx -s reload
Important locations:
- Add configs in -> /usr/local/etc/nginx/servers/
- Default config -> /usr/local/etc/nginx/nginx.conf
- Logs will be in -> /usr/local/var/log/nginx/
- Default webroot in -> /usr/local/var/www/
- Default listen address -> http://localhost:8080
๐ openssl
WebServer ๅจ8000
็ซฏๅฃ่ฟ่ก๏ผnginx ้่ฟ ssl443
็ซฏๅฃๅๅไปฃ็
- ๅจ mac ไธ็ๆ่ฏไนฆ๏ผ
$ openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt
/etc/hosts
:
127.0.0.1 localhost test.local
3.
$ openssl x509 -text -noout -in localhost.crt
4.
$ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /Users/test/.localhost-ssl/localhost.crt
- /usr/local/etc/nginx/nginx.conf
events {}
http {
upstream backend {
server 127.0.0.1:8000;
}
server {
server_name local.website.dev;
rewrite ^(.*) https://local.website.dev$1 permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /path-to-file/localhost.crt;
ssl_certificate_key /path-to-file/localhost.key;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name local.website.dev;
location / {
proxy_pass http://localhost:4000;
}
}
}
๐ ่ฎฟ้ฎๆฌๅฐ SSL ็ซ็น
๐ install mongodb
$ brew update
$ brew tap mongodb/brew
$ brew install mongodb-community
๐ restart
$ brew services list
$ brew services restart mongodb-community
$ brew services restart mysql
๐ command
$ brew tap heroku/brew && brew install heroku
$ heroku login
$ brew services stop mongodb-community
$ brew services restart nginx (stop, start)
$ brew install mariadb; //brew uninstall mysql;
๐ mariadb vs mysql
๐ brew install
- heroku
- nginx
- mysqld (8.0)
- mongodb
๐ nginx.conf
1 server {
2 listen 80;
3
4 server_name mydomain.com;
5
6 location ~ ^/myApp/(libs/|img/|js/|css/) {
7 root /path/to/myApp/public;
8 access_log off;
9 expires max;
10 }
11
12 location /myApp {
13 proxy_pass http://mean-stack-ip:8080;
14 proxy_http_version 1.1;
15 proxy_set_header Upgrade $http_upgrade;
16 proxy_set_header Connection 'upgrade';
17 proxy_set_header Host $host;
18 proxy_cache_bypass $http_upgrade;
19 }
20 }