How To Install V2ray On Amazon EC2 And Google Cloud Ubuntu Linux

V2ray is similar but better than ShadowSocks. This article will tell you how to install v2ray server on ubuntu linux. It also tell you how to use v2ray client to access the v2ray server. Before start you should know that v2ray has strict requirements on time. It is required that the absolute value of the time difference between the server and the client cannot exceed 2 minutes, so you must ensure that the time is accurate enough. Fortunately, v2ray does not require consistent time zones on server and client.

1. Update Linux Server Date Time.

  1. Get linux server current date time.
    $ date
    Thu Feb 27 11:48:59 UTC 2020
  2. Change linux date time and time zone.
    date --set="Fri Jun 28 15:05:15 CST 2020"

2. Install V2ray On Ubuntu Linux Server.

  1. First you should install unzip manually. Otherwise the v2ray installation will fail.

    $ sudo apt install unzip
  2. Change to root user.
    $ sudo su
    [email protected]:/home/ubuntu#
  3. Install v2ray on linux server.
    # bash <(curl -L -s
    Installing V2Ray v4.22.1 on x86_64
    Downloading V2Ray:
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   608  100   608    0     0   2068      0 --:--:-- --:--:-- --:--:--  2068
    100 11.6M  100 11.6M    0     0  3171k      0  0:00:03  0:00:03 --:--:-- 3619k
    Archive:  /tmp/v2ray/
      inflating: /usr/bin/v2ray/geoip.dat  
      inflating: /usr/bin/v2ray/geosite.dat  
      inflating: /usr/bin/v2ray/v2ctl    
      inflating: /usr/bin/v2ray/v2ray    
    Archive:  /tmp/v2ray/
      inflating: /etc/systemd/system/v2ray.service  
    Created symlink /etc/systemd/system/ → /etc/systemd/system/v2ray.service.
    V2Ray v4.22.1 is installed.
  4. If you meet below error when run above shell script, then you need browse to see the new v2ray install method.
    # bash <(curl -L -s
    ERROR: This script has been DISCARDED, please switch to fhs-install-v2ray project.
  5. Below is the new v2ray install steps.
    # first install curl
    # apt update
    # apt install curl
    # download v2ray install shell script file.
    # curl -O
    # curl -O
    # install v2ray.
    # bash
    # install geoip.dat, geosite.dat
    # bash
    # if you want to remove v2ray
    # bash --remove
  6. Use vim to edit v2ray configuration file. The file path is /etc/v2ray/config.json.
    # vim /etc/v2ray/config.json
  7. Go to to generate a new unique id and replace it in above config.json file inbounds —> settings —> clients —> id value. The port number is also decided by yourself. For more configuration settings, please read article V2ray Configuration Overview.
      "inbounds": [{
        "port": 10086,
        "protocol": "vmess",
        "settings": {
          "clients": [
              "id": "10fdwe3c8-uyer3-df343-t256-df89f7df8",
              "level": 1,
              "alterId": 64
      "outbounds": [{
        "protocol": "freedom",
        "settings": {}
        "protocol": "blackhole",
        "settings": {},
        "tag": "blocked"
      "routing": {
        "rules": [
            "type": "field",
            "ip": ["geoip:private"],
            "outboundTag": "blocked"
  8. Enable v2ray auto start when os start.
    # systemctl enable v2ray
  9. Run command systemctl start v2ray to start v2ray service.
    systemctl start | stop | restart v2ray

3. Install And Configure V2ray Client.

You can go to the official v2ray client download page to get the v2ray client which match your needs. I use MacOS, so i just installed V2RayX. Below is the steps about how to use V2RayX.

  1. Download, install and start V2RayX.
  2. Click V2RayX icon at Mac top menu bar, then click Configure… menu item.
    v2rayx configure menu
  3. Input v2ray server ip address ( or domain name ), listen port number, User ID in the red line input box, input a name in the Tag input box, click OK button to save it. Do not need to modify other fields.
    v2rayx configure dialog
  4. Now this newly added v2ray server will be shown in V2RayX —> Server list, check it.
  5. Check the V2RayX —> Global Mode menu item.
  6. You can add multiple v2ray server, if you do not want to use it, you can click V2RayX —> Unload core. If you want to use it again, you can first select it in V2RayX —> Server list, then click V2RayX —> Load core menu.
  7. For more v2ray configuration, please go to V2ray Configuration Overview. Client and server use same configuration file. But client’s inbounds settings should map to server outbounds settings vice versa.

4. Add V2ray Server Port Number In Amazon Or Google Cloud Firewall.

If you use amazon aws or google cloud linux VPS server, generally, your v2ray server port number should be blocked by amazon or google cloud firewall by default. So you should add the port number in amazon aws or google cloud firewall to allow it.

4.1 Amazon AWS.

Please refer section 5. Edit EC2 Linux Instance Used Security Group. in article How To Install ShadowSocks Server On Amazon EC2 Linux

4.2 Google Cloud.

Please refer section 1. Create A Firewall Rule In Google Cloud. in article How To Install ShadowSocks On Google Cloud Linux

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.