安装软件

python3

现在的服务器是centOS7,默认python版本为2.7,需要安装python3

  • 安装教程
  • 这个过程大概是先安装pip,用pip安装了wget,用wget下载python3的源码包,解压安装配置
  • 安装完成后python命令被指向了python3.6版本,但实际上我习惯了用python3,只要执行:ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3 创建一个python3的软链就行了
  • 添加pip3的软链:ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
  • 注意安装过程中最好不要把python链接到python3,最好直接创建一个python3去链接,系统有些服务的引用是python,而他们需要的是python2,如果把python指向了python3可能会出问题
  • 添加pip3的软链
    1
    2
    ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

在国外的服务器上搭建ss服务

  • 在~目录下创建并切换到shadowsocks目录
  • 执行:
    1
    2
    3
    4
    5
    6
    # 下载
    wget –no-check-certificate https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks.sh
    # 授权
    chmod +x shadowsocks.sh
    # 运行
    ./shadowsocks.sh 2>&1 | tee shadowsocks.log
  • 这里需要配置ss服务的参数:密码、端口、加密方式(建议使用aes-256-cfb)
  • 最后界面上回显示红色标记的内容就是ss的连接信息了

shadowsocks全局翻墙(旧版)

  • 安装教程
  • 可能会遇到用sslocal的时候命令行找不到该命令,全局搜一下这个文件的路径,我的在python3下面的,然后把sslocal和 ssserver都复制到/bin目录去就ok了
  • 将别名写到~/.bashrc里面,不然每次会话结束别名就失效了,写完之后用source ~/.bashrc,能让它立即生效
  • zsh的时候需要写到~/.bash_profile里面同样source执行,这个配置文件应该是全局的,上面那个只对bash这个shell生效
  • 跟着教程完成安装后执行ssinit初始化shadowsocks,执行sson运行shadowsocks,执行ssoff关闭

全局翻墙(新版)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!--下载和执行脚本-->
wget https://install.direct/go.sh
chmod +x go.sh
./go.sh

<!--修改配置文件-->
<!--路径:/etc/v2ray/config.json-->
{
"inbound": {
"port": 7070,
"protocol": "socks",
"settings": {
"userLevel": 0
}
},
"inboundDetour": [{
"port": 7080,
"protocol": "http",
"settings": {
"userLevel": 0
}
}],
"outbound": {
"tag": "vps-jp",
"protocol": "shadowsocks",
"settings": {
"servers": [
{
"address": "207.148.115.199",
"port": 15505,
"method": "aes-256-cfb",
"password": "mcmmxbt"
}
]
}
},
"outboundDetour": [{
"tag": "direct",
"protocol": "freedom",
"settings": {
"userLevel": 0
}
}],
"routing": {
"strategy": "rules",
"settings": {
"domainStrategy": "IPOnDemand",
"rules": [
{"type":"field", "domain":"geosite:cn", "outboundTag":"direct"},
{"type":"field", "ip":"geoip:cn", "outboundTag":"direct"},
{"type":"field", "ip":"geoip:private", "outboundTag":"direct"}
]
}
}
}

<!--启动服务-->
sudo systemctl start v2ray.service
<!--查看服务状态-->
sudo systemctl status v2ray.service
<!--将服务加入开机自启-->
sudo systemctl enable v2ray.service
<!--测试-->
curl ip.me
curl -x 127.0.0.1:7080 ip.me
curl -x 127.0.0.1:7080 www.google.com
<!--进行命令行代理-->
export http_proxy="http://127.0.0.1:7080"
export https_proxy="http://127.0.0.1:7080"
<!--测试-->
curl www.google.com

安装zsh

配置项目外网访问

  • 这里就以目前搭的vue cli项目为例
  • 搭建过程参考vue cli环境搭建
  • 当vue cli 项目被创建并成功启动后,默认是通过http://localhost:8080访问的,这时在命令行通过curl已经能过访问通了,但是这个localhost本质指向了127.0.0.1只能在本地访问,所以要到config/index.js中将localhost改为0.0.0.0这是一个虚拟地址指向当前机器ip
  • 现在用的是iview的模板,这个模板里面修改webpack.dev.config.js,在module.exports标签里面添加
    1
    2
    3
    4
    devServer:{
    port:8080,
    host:'0.0.0.0'
    },
  • 阿里云有加密机制需要配置一下授予8080端口外网访问的权限,具体是在服务器的管理台找到“安全组”,选择右侧的‘配置规则’,添加安全组规则阿里云8080外网访问
  • 还需要在服务器上配置防火墙
    • 关于防火墙firewalld
    • 查看状态:systemctl status firewalld
    • 开启:systemctl start firewalld
    • 关闭:systemctl stop firewalld
    • 开放8080:sudo firewall-cmd –zone=public –add-port=8080/tcp –permanent
    • 修改后重启:sudo systemctl restart firewalld.service
    • 查看是否生效:sudo firewall-cmd –query-port=8080/tcp (输出yes)
  • 补充:后来设置mysql的3306端口时候防火墙起不来了,但是好像没有什么影响,远程连接可以连通
  • 应该一切ok了,通过ip+端口就能访问了

配置vim

安装一些vim的插件来方便开发