How to deploy Golang on Pagoda panel

PHPz
Release: 2023-04-03 14:26:03
Original
2852 people have browsed it

Pagoda Panel is a commonly used server management panel. It provides rich functions and supports one-click installation of multiple applications, which greatly simplifies the difficulty of server management. Quickly deploying Golang on the Pagoda panel can greatly improve development efficiency. This article will introduce how to deploy Golang on the Pagoda panel.

1. Install the Pagoda Panel

First, you need to install the Pagoda Panel on the server. We can directly download the panel installation program from the Pagoda official website. Download the installer via the following command:

wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
Copy after login

After the installation is complete, we can access the panel by accessing the server IP address and port 8091.

2. Create a website

In the Pagoda panel, we need to create a website first to facilitate the deployment of Golang applications on it. The specific steps are as follows:

  1. Log in to the Pagoda panel and select "Add Website" in the "Website" menu.
  2. Set the domain name and root directory. The root directory can be empty or any value.
  3. Click "Create" to complete website creation.

3. Install Golang

Next, we need to install Golang on the server. You can install it through the following command:

wget https://studygolang.com/dl/golang/go1.15.6.linux-amd64.tar.gz
Copy after login

After decompression, unzip the Golang binary folder Add it to the system environment variables for easy use.

4. Deploy Golang applications

In the Pagoda panel, we can upload the Golang program source code and build the program through the "File Management" function.

  1. Log in to the Pagoda panel and select "File Management" in the "File" menu.
  2. Enter the root directory corresponding to the website, create a new folder in the root directory and name it "go", and create a new folder in the "go" directory and name it "src".
  3. Upload the Golang program source code to the "src" directory.
  4. In the "src" directory, create a Golang main function program named "main.go".
  5. In the "Go" directory, create a log directory named "logs" to store the log files of the Golang program.
  6. Run the following command in the "src" directory to build the program:
go build -o ../goapp main.go
Copy after login

After the build is successful, a binary file named "goapp" will be generated in the "go" directory. This is the Golang program we need to deploy.

  1. Create a new file in the "go" directory, name it "restart.sh", and enter the following command:
killall goapp
nohup ./goapp > ../logs/goapp.log 2>&1 &
Copy after login

This script implements the program Restart the function and redirect the program's output to a log file.

5. Start the Golang application

In the "File Management" interface, enter the "go" directory and run the following command to start the Golang application:

sh restart.sh
Copy after login

The program started successfully After that, the website can be accessed through the browser and the Golang application can be accessed.

Summary

Rapid deployment of Golang applications through the Pagoda Panel can quickly improve development efficiency. This article introduces how to install Golang and deploy Golang applications on the Pagoda Panel. If you encounter problems you can seek help in the official forum.

The above is the detailed content of How to deploy Golang on Pagoda panel. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!