不管是IT人員還是外貿人員,經常會發現有些網站無法訪問,Android開發者應該體會很深,Android官網無法訪問、API無法查看以及很多Android的最新資訊都無法及時瞭解。本文就教大家一個簡單的實現方法,就是在VPS上部署Shadowsocks,下面教大傢俱體實現步驟:
一、購買服務器
首先得需要一個VPS,這裏我用的是Vultr,現在可以用支付寶和微信來支付。
- 1、註冊:
- 2、充值:Vultr可以選支付寶或者微信來充值,最低充值10美元
- 3、充值完成後,點Servers,點右上角的加號來添加服務器
然後選擇服務器位置、配置以及系統版本,這邊有個網址大家可以測試下下載速度,根據速度選擇合適的服務器位置,套餐的話,選3.5或者5美元的2.5美元的是ipv6不建議選:
測速地址
系統的話,選擇CentOS7
接下來是選擇價格,選完直接點右下角的購買就可以了,其他選項可以不管。Vultr購買完不會馬上扣你錢,它是按小時收費的,用多久收多少,不用可以直接停掉
- 4、服務器購買完成後,等幾分鐘,等創建好之後點進去看詳情,記住IP地址、用戶名和密碼。
二、配置服務器
-
1、首先我們要做的是連接服務器,我們需要一個ssh客戶端來連接,我這邊用的是putty(文末附工具下載地址),打開putty後輸入服務器的ip地址點open就可以了,然後輸入用戶名和密碼(鼠標右鍵是粘貼,右鍵後直接按回車)就進去到你的遠程服務器了。
- 2、安裝python,安裝過程遇到Y/n的一律輸入Y(按順序執行下面命令):
yum install python-setuptools
- 3、安裝pip,依次執行下面幾個命令:
wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz --no-check-certificate tar -xzvf pip-1.3.1.tar.gz cd pip-1.3.1 python setup.py install
-
4、安裝Shadowsocks:
pip install shadowsocks
出現Successfully installed shadowsocks-XXX說明安裝成功了
- 5、按順序執行下面命令,在/etc目錄下新建文件夾“shadowsocks”,然後在shadowsocks文件夾下新建文件“config.json”:
mkdir /etc/shadowsocks vi /etc/shadowsocks/config.json
輸入完上面命令之後出現的頁面,就相當於Windows中的記事本。最下一行提示我們當前這個文件是新建的。
在這個視圖中有如下幾個按鍵需要記住“i”:按鍵盤上的i鍵,窗口最底下顯示“insert”,表示當前文件可編輯。“Esc”:編輯完之後按Esc退出編輯模式。“:”:半角的冒號,在非編輯模式下按鍵盤上的冒號(半角),可以進入輸入命令的模式。“w”:在命令模式中輸入w並回車,窗口最下顯示“written”,表示所做的更改已保存。“q”:在命令模式中輸入q並回車,可以退出當前的編輯器。
config.json的內容如下:
{
"server":"0.0.0.0",
"server_port":8388,
"password":"your_password",
"timeout":600,
"method":"aes-256-cfb",
"fast_open": false
}
"server":是你Vultr服務器的ip地址
"server_port"和"password"可以根據自己的要求設定
如果需要同時開多個端口,config.json的內容可以設置如下:
{
"server":"0.0.0.0",
"port_password": {
"8388": "your_password1",
"8389": "your_password2"
},
"timeout":600,
"method":"aes-256-cfb",
"fast_open": false
}
- 6、執行以下命令啓動Shadowsocks:
ssserver -c /etc/shadowsocks.json -d start
要停止Shadowsocks執行如下命令:
ssserver -c /etc/shadowsocks.json -d stop
- 7、設置Shadowsocks開機自啓動
執行下面的命令,創建shadowsocks.service文件:
vi /etc/systemd/system/shadowsocks.service
shadowsocks.service的內容如下:
[Unit]
Description=Shadowsocks
After=network.target
[Service]
Type=forking
PIDFile=/run/shadowsocks/server.pid
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /run/shadowsocks
ExecStartPre=/bin/chown root:root /run/shadowsocks
ExecStart=/usr/bin/ssserver --pid-file /var/run/shadowsocks/server.pid -c /etc/shadowsocks/config.json -d start
Restart=on-abort
User=root
Group=root
UMask=0027
[Install]
WantedBy=multi-user.target
保存退出即可。
接下來設置文件權限:
chmod 755 /etc/systemd/system/shadowsocks.service
啓動服務:
systemctl start shadowsocks
systemctl enable shadowsocks
- 8、開啓配置端口(以8888,8889端口爲例):
firewall-cmd --zone=public --add-port=8888/tcp --permanent
firewall-cmd --zone=public --add-port=8889/tcp --permanent
firewall-cmd --reload
三、Final
好了,到此,科學上網已經搭好了,你現在只要去下載shadowsocks的客戶端填上shadowsocks.json中的ip地址、端口號、以及密碼就可以上你想上的網站了。
有問題請聯繫QQ:931003200
Putty 下載地址:
Windows:https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
MAC:https://putty-for-mac.soft32.com/
shadowsocks客戶端下載地址:
Windows
https://github.com/shadowsocks/shadowsocks-windows/releases
Mac OS X
https://github.com/shadowsocks/ShadowsocksX-NG/releases
linux
https://github.com/shadowsocks/shadowsocks-qt5/wiki/Installation
https://github.com/shadowsocks/shadowsocks-qt5/releases
iOS
https://itunes.apple.com/app/apple-store/id1070901416?pt=2305194&ct=shadowsocks.org&mt=8
https://github.com/shadowsocks/shadowsocks-iOS/releases
https://play.google.com/store/apps/details?id=com.github.shadowsocks
https://github.com/shadowsocks/shadowsocks-android/releases