Home > Article > Backend Development > How Golang is packaged and deployed on Linux
How to package and deploy Golang on Linux
1. Compile Golang program locally
cmd Go to the main.go file directory in the console and execute:
set GOARCH=amd64 set GOOS=linux go build main.go
At this time, a binary file without a suffix will be generated
main
2. Upload the Golang binary file to the Linux server
Put the file into a folder in the linux system
Give permissions
chmod 777 main
Finally execute ./main .
If you want the project to execute in the background: execute nohup ./main & , so that the program can run in the background.
For more golang knowledge, please pay attention to the golang tutorial column on the PHP Chinese website.
The above is the detailed content of How Golang is packaged and deployed on Linux. For more information, please follow other related articles on the PHP Chinese website!