# 安装 nginx

nginx 可以以不同的方式安装，安装方式取决于当前的操作系统。

## 在 Linux 上安装

对于 Linux，可以使用 nginx.org 的 nginx [软件包](/nginx-docs/qi-ta/linux-bao.md)。

## 在 FreeBSD 上安装

在 FreeBSD 上，可以从 [软件包](http://www.freebsd.org/doc/handbook/pkgng-intro.html) 或通过 [ports](http://www.freebsd.org/doc/handbook/ports-using.html) 系统安装 nginx。ports 系统提供更大的灵活性，提供了各种选项可供选择。port 将使用指定的选项编译 nginx 并进行安装。

## 从源码安装

如果需要某些特殊功能软件包和 ports 无法提供，那么可以从源码中编译 nginx。虽然此方式更加灵活，但对于初学者来说可能会很复杂。更多信息请参阅 [从源码构建 nginx](/nginx-docs/readme/cong-yuan-ma-gou-jian-nginx.md)。

## 原文档

<http://nginx.org/en/docs/install.html>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docshome.gitbook.io/nginx-docs/readme/an-zhuang-nginx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
