# Apm-server on FreeBSD

**URL:** <https://discuss.elastic.co/t/apm-server-on-freebsd/324532>\
**Category:** APM\
**Tags:** server\
**Created:** [February 2, 2023, 11:38am UTC](https://discuss.elastic.co/t/apm-server-on-freebsd/324532 "2023-02-02T11:38:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michbsd](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@michbsd](https://discuss.elastic.co/u/michbsd)\
**Post date:** [February 2, 2023, 11:38am UTC](https://discuss.elastic.co/t/apm-server-on-freebsd/324532/1 "2023-02-02T11:38:24Z")

</div>

Is there a way to get apm-server running on FreeBSD?

thanks

---

<div class="post-metadata">

**Author:** ![michbsd](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@michbsd](https://discuss.elastic.co/u/michbsd)\
**Post date:** [February 2, 2023, 12:56pm UTC](https://discuss.elastic.co/t/apm-server-on-freebsd/324532/2 "2023-02-02T12:56:58Z")

</div>

Looks like adding linux compat might have solved it

---

<div class="post-metadata">

**Author:** ![revenue-pwright](https://avatars.discourse-cdn.com/v4/letter/r/a9adbd/32.png) [@revenue-pwright](https://discuss.elastic.co/u/revenue-pwright)\
**Post date:** [February 3, 2023, 3:30pm UTC](https://discuss.elastic.co/t/apm-server-on-freebsd/324532/3 "2023-02-03T15:30:02Z")

</div>

I was able to build it from source using the following diff then running `gmake`:

```auto
diff --git a/Makefile b/Makefile
index 4594aa87d..d6a5c49a4 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,8 @@ APM_SERVER_BINARIES:= \
        build/apm-server-windows-386.exe \
        build/apm-server-windows-amd64.exe \
        build/apm-server-darwin-amd64 \
- build/apm-server-darwin-arm64
+ build/apm-server-darwin-arm64 \
+ build/apm-server-freebsd-amd64
 
 # Strip binary and inject the Git commit hash and timestamp.
 LDFLAGS := \
@@ -58,12 +59,13 @@ LDFLAGS := \
 # the apm-server binaries.
 .PHONY: $(APM_SERVER_BINARIES)
 $(APM_SERVER_BINARIES):
- env CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) \
+ env CGO_ENABLED=1 GOOS=$(GOOS) GOARCH=$(GOARCH) \
        $(GO) build -o $@ -trimpath $(GOFLAGS) $(GOMODFLAG) -ldflags "$(LDFLAGS)" ./x-pack/apm-server
 
 build/apm-server-linux-%: GOOS=linux
 build/apm-server-darwin-%: GOOS=darwin
 build/apm-server-windows-%: GOOS=windows
+build/apm-server-freebsd-%: GOOS=freebsd
 build/apm-server-%-386 build/apm-server-%-386.exe: GOARCH=386
 build/apm-server-%-amd64 build/apm-server-%-amd64.exe: GOARCH=amd64
 build/apm-server-%-amd64 build/apm-server-%-amd64.exe: GOFLAGS+=-buildmode=pie
@@ -259,7 +261,7 @@ gofmt: $(GOIMPORTS) add-headers
 ##############################################################################
 
 MODULE_DEPS=$(sort $(shell \
- $(GO) list -deps -tags=darwin,linux,windows -f "{{with .Module}}{{if not .Main}}{{.Path}}{{end}}{{end}}" ./x-pack/apm-server))
+ $(GO) list -deps -tags=darwin,linux,windows,freebsd -f "{{with .Module}}{{if not .Main}}{{.Path}}{{end}}{{end}}" ./x-pack/apm-server))
 
 notice: NOTICE.txt
 NOTICE.txt build/dependencies-$(APM_SERVER_VERSION).csv: go.mod tools/go.mod

```

it passes tests, and i'm actually using it in our pre-prod environment for testing. The only thing I'm unsure about is the change to set `CGO_ENABLED=1` which is required to compile, but I am unsure of the side effects. `gmake test` works though.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 24, 2023, 11:30am UTC](https://discuss.elastic.co/t/apm-server-on-freebsd/324532/4 "2023-02-24T11:30:31Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
