caddyserver / xcaddy

Build Caddy with plugins
Apache License 2.0
851 stars 105 forks source link

-bash: xcaddy: command not found #5

Closed Ninzero closed 4 years ago

Ninzero commented 4 years ago

Hi,

I hope this is not a terrible question, I did try my best to solve the problem, but it just doesn't work.

I first installed go 1.14.2 following this page: Getting Started. I did remember to add /usr/local/go/bin to $PATH. Everything was fine and this test succeeded.

Then I set $GO111MODULE to on. And I ran go get -u github.com/caddyserver/xcaddy/cmd/xcaddy as instructed. I tried to run this command almost everywhere: my home directory, I cloned caddy and run this command. But whatever I do, there is no such command called xcaddy.

mholt commented 4 years ago

go get will install the binary into your $GOPATH/bin, which is different from /usr/local/go/bin. It doesn't seem to be very well-documented anymore, unfortunately. If you add that path to your PATH then it should work. Look in $HOME/go/bin for the xcaddy binary.

(Closing, but feel free to reopen if this turns out to be an issue with our repo!)

ghhk commented 4 years ago

I get that error too! When I use cd /root/go/bin I see a file named xcaddy. But when I run any command about xcaddy it give me an error like "-bash: xcaddy: command not found"

MrChadMWood commented 7 months ago

For anyone coming from AWS, I got this to work on AWS Linux 2023 AMI. Note that I'm just building with the route53 plugin.

#!/bin/bash

# Update and upgrade system packages
sudo yum update
sudo yum upgrade

# Download and extract Go
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
tar -xvf go1.21.5.linux-amd64.tar.gz

# Move Go to the system directory
sudo mv go /usr/local

# Set up Go environment variables
echo 'export GOROOT=/usr/local/go' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> ~/.bashrc
source ~/.bashrc

# Install xcaddy
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest

# Build Caddy with Route 53 DNS plugin
xcaddy build --with github.com/caddy-dns/route53

# Move Caddy to the system binaries directory
sudo mv caddy /usr/local/bin