Go && Ali cloud server (Ubuntu) - Golang project (beego) server deployment

The written language go project published to the server, complete the following steps:

1. Download and install the installation package go:

(1) go Language Download: Go Language Chinese network

 Download linux version installation package.

(2) using the installation package Xftp uploaded to the specified path:

(3) extracting and moved to / usr / local / under:

Enter the specified directory, view existing file and unzip the file:

After the extraction is completed directory found one more go folder:

Move the folder to / usr / local /

2. Configure environment variables:

(1) go into the destination directory folder to see whether the move was successful:

(2) create a file in usr folder, used to store their own projects:

  • mkdir workspace

(3) into the new directory workspace new three folders:

  • mkdir src
  • mkdir pkg
  • mkdir bin

Description:

  • src directory contains the source code is our go different project code to distinguish the package name
  • Pkg files generated after compilation
  • bin folder named store go install the resulting executable file (this folder will be configured to the environment variable)

(4) configuration environment variable:

Enter / etc file modification profile:

In this folder on FIG tagging code is as follows:

// 设置go安装路径
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

// 设置工程目录
export GOPATH=/usr/workspace
export PATH=$PATH:$GOPATH/bin

 (5) to refresh the environment variables:

source /etc/profile

 (6) go to see whether the configuration environment:

go version

The results are as follows:

(7) to view detailed configuration:

go env

The results are as follows:  

 3. Upload Item Code:

In the workspace file you just created three newly created folder, src directory is our go to store source code, will pass up our project and the required dependencies:

 Contains many rely on my dependencies (github.com) in the following figure:

4. Run:

(1) where the file into the project folder:

cd usr/workspace/src/liteblog/

 (2) run the project:

go run main.go

 Item start successfully

Browser to access available the following figure:

 Other web projects should be similar deployment method, in fact, local feel and are very similar, regardless of the server or ubuntu centos, both local and project a definite link, if in doubt please contact me.

From: micro-channel public number [Li Xu Xu]

Author: Li Xu Xu

扫码关注,领取众多粉丝福利,阅读更多原创文章,联系作者

发布了312 篇原创文章 · 获赞 570 · 访问量 41万+

Guess you like

Origin blog.csdn.net/qq_42410605/article/details/96479892