The following tutorial column of golang will introduce to you how to deploy the go program to run on linux. I hope it will be helpful to friends in need!
go language version: go1.9.2
Development environment: win10
Deployment environment: ubuntu 14.04.6
1. Execute the set CGO_ENABLED=0, set GOOS=linux, and set GOARCH=amd64 commands in the src directory in sequence
##2. Linux side ubuntu
2. Start the program
1), execute the ./main command
If a "Permission denied" error is reported
Solution: Give the main file executable permissions
chmod 777 main
Run ./main again, the program starts normally
2), start the program in the background
./ The main startup method will stop the program when the console exits. We can use the nohup ./main & command to let the program run in the background.
nohup ./main &
3) Check whether the program is running normally
ps aux|grep main
##You can see that the program is running normally on 32297pid
At this point, the Go application deployment and running on the Linux server has been completed.The above is the detailed content of How to deploy go program to run on linux. For more information, please follow other related articles on the PHP Chinese website!