17.2 Nginx

安装

# pkg install nginx

# cd /usr/ports/www/nginx/ 
# make install clean

查找相关的软件包

  • ports: $ ls /usr/ports/www/ | grep nginx

  • pkg: $ pkg search -o nginx

启动

root@ykla:~ # service nginx enable
nginx enabled in /etc/rc.conf
root@ykla:~ # service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.

你可以通过 sockstat -4 | grep nginx 检查 nginx 是否启动并正常运行:

浏览网页

本机打开 localhost,或者 ip,如 http://192.168.179.150/

NGINX FreeBSD

配置文件

配置教程可参阅 官方文档

本文仅简单说明 FreeBSD 中如何启动 Nginx 及 Nginx 的配置文件。

在 FreeBSD 中,Nginx 的配置文件位于 /usr/local/etc/nginx/ 中,而主要的配置文件则在 /usr/local/etc/nginx/nginx.conf

默认配置中 Nginx 的根目录为 /usr/local/www/nginx/,如果需要更改目录位置,请将 /usr/local/etc/nginx/nginx.conf 中的

改成你想要的目录位置,例如 root /path/to/new/webroot

示例文件(Nginx + Typecho 伪静态 + SSL)

最后更新于

这有帮助吗?