創(chuàng)建用戶
useradd username
password username # 修改用戶名密碼
給新建用戶添加 sudo 權限
visudo
然后像下面一樣水慨,在 root ALL=(ALL) ALL
后添加配置
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
username ALL=(ALL) ALL
Nginx
Centos 7
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
編輯 nginx 配置
vim /etc/nginx/nginx.conf
退出卡死的 ssh
先回車万哪,然后輸入 “~.”
? ~ man ssh
A single tilde character can be sent as ~~ or by following the tilde by a character other than those described
below. The escape character must always follow a newline to be interpreted as special. The escape character
can be changed in configuration files using the EscapeChar configuration directive or on the command line by the
-e option.
The supported escapes (assuming the default ‘~’) are:
~. Disconnect.
vim 保存時 獲得 root 權限
w !sudo tee %
Nginx 配置 socket.io websocket
upstream socket_nodes{
server 127.0.0.1:3002;
keepalive 15;
}
server {
listen 80;
server_name api.domain.com;
location /location/api {
proxy_pass http://127.0.0.1:3001;
}
location /socket.io/ {
# 設定正確的header
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# nginx 1.13版本以上沮翔,支持websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_pass http://socket_nodes;
}
}