Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

运行最小本地 nginx 服务器

Posted on 2025-06-16

我有一个 Ansible playbook,用于配置一次性的 FreeBSD Jail,其中包含 nginx 的裸安装以及一些上游组件,例如 php-fpm。但有时你需要更简单的方法,以便在当前目录中进行一些快速测试。

假设您已经从您选择的包管理器安装了 nginx:

 $ nginx -v ==> nginx version: nginx/1.27.5

这是我的轻量级nginx.conf文件。我甚至不需要一个外部的mime.types文件,因为它可能根据操作系统位于不同的位置,不过你可能更理性一些:

 ## Lightweight nginx.conf for local testing ## You would be wise not to use this in prod daemon off; worker_processes 1; events { worker_connections 4; } error_log error.log info; http { charset utf-8; types { application/atom+xml atom; application/rss+xml rss; application/javascript js; application/json json; image/gif gif; image/jpeg jpg; image/png png; image/svg+xml svg svgz; image/x-icon ico; text/html html htm; text/css css; text/plain txt; text/xml opml xml; } server { server_name localhost; listen 127.0.0.1:8080; root .; } }

然后运行一个小的server.sh脚本来启动它。这将在同一目录中启动一个 nginx 服务器。

 #!/usr/bin/env sh nginx -p $PWD -c ./nginx.conf

用我一位已故评论家的话来说,这真的没什么特别的,甚至没什么值得一提的。他在这方面绝对是对的。但我一直在用这个,所以就把它传下去,不管它值多少钱。

作者: Ruben Schade ,悉尼,2025 年 6 月 16 日。

原文: https://rubenerd.com/running-a-minimum-local-nginx-server/

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • eighty twenty
  • Elad Gil
  • Ellie Huxtable
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Rohit Patel
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme