ssh root@公网ip地址
ubuntn升级更新
sudo apt-get update && sudo apt-get upgrade
安装nginx
apt-get install nginx
service nginx start
查看硬盘使用情况
df -h
配置zsh快捷访问服务器
vi ~/.zshrc
//添加
alias ssh_binperson="ssh root@119.23.48.128"
source .zshrc
ssh_binperson
iptables
iptables -F
vi /etc/iptables.up.rules
*filter
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A OUTPUT -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
COMMIT
iptables-restore < /etc/iptables.up.rules
激活防火墙
ufw enable
安装服务器模块
sudo apt-get update
sudo apt-get install vim openssl build-essential libssl-dev wget curl git
安装node.js
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
nvm install node
nvm use node
npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global
npm i pm2 webpack gulp grunt-cli -g
增加系统文件监控数
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
移除apache
apache2 stop
apt-get remove apache2
sudo apt-get update
nginx 配置
cd /etc/nginx/
cd conf.d/
vi binperson-3000.conf
nginx -t
cd ../
vi nginx.conf
nginx -s reload
upstream cookie {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name 119.23.48.128;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://cookie;
proxy_redirect off;
}
}
去掉Server:nginx/1.4.6 (Ubuntu)版本
cd /etc/nginx
vi nginx.conf
server_tokens off;//打开
service nginx reload