如何重新编译 nginx

发布于 2025-01-08 10:59:27 字数 727 浏览 5 评论 0原文

我正在设置一个新服务器(我的第一个!)。

我已经安装了 Passenger 并使用 passenger-install-nginx-module 来安装 nginx。我随后进行了设置并且一切正常。

但是我的应用程序是 Rails 3.1,因此使用资产管道,我没有意识到我需要 PCRE 库

nginx: [emerg] using regex "^/(assets)/" requires PCRE library in /opt/nginx/conf/nginx.conf:89

它需要它,以便 nginx.conf 中的以下内容正常工作:

location ~ ^/(assets)/  {  
  root /path/to/public;  
  gzip_static on; # to serve pre-gzipped version  
  expires max;  
  add_header  Cache-Control public;  
} 

我安装了 PCRE通过

sudo apt-get install libpcre3 libpcre3-dev

现在我已经添加了这个,我相信有必要重新编译 nginx。

我看过一些关于如何重新编译它的博客文章/nginx 帮助,但我真的是一个n00b。有人可以指出我的分步说明吗?

谢谢!

I'm setting up a new server (my first!).

I've installed Passenger and used passenger-install-nginx-module to install nginx. I've subsequently set it up and it all works.

However my app is Rails 3.1 and therefore uses the asset pipeline, and I didn't realize I needed to have the PCRE library

nginx: [emerg] using regex "^/(assets)/" requires PCRE library in /opt/nginx/conf/nginx.conf:89

It needs it so that the following in nginx.conf works properly:

location ~ ^/(assets)/  {  
  root /path/to/public;  
  gzip_static on; # to serve pre-gzipped version  
  expires max;  
  add_header  Cache-Control public;  
} 

I installed PCRE by

sudo apt-get install libpcre3 libpcre3-dev

Now that I've added this I believe it is necessary to recompile nginx.

I've seen a few blog posts/ the nginx help about how to recompile it, but I really am a n00b. Can someone point me at step by step instructions?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

め可乐爱微笑 2025-01-15 10:59:27

给出的答案将不起作用,因为您正在尝试将 Nginx 与 Passenger 一起使用,并且 Nginx 还需要编译 Passenger 模块。

只需再次运行 passenger-install-nginx-module 即可为您重新编译 nginx。如果没有,您可以在 /opt/nginx(这是 Passenger 安装 nginx 的默认位置)上尝试 rm -r。如果您重视的话,请务必备份您的 /opt/nginx/conf/nginx.conf 。

如果您使用的是 Passenger 独立版,并且需要重新编译它,请删除 ~/.passenger/YOUR-MOST-RECENT-INSTALL 并只需再次运行 Passenger start 即可。

The given answers will not work, because you are trying to use Nginx with Passenger, and Nginx needs the Passenger module also compiled.

Simply running passenger-install-nginx-module again will recompile nginx for you. If it doesn't, you can try rm -r on /opt/nginx (which is the default location nginx is installed into by Passenger). Be sure to backup your /opt/nginx/conf/nginx.conf if you value it.

If you are using passenger standalone, and you need to recompile that, remove ~/.passenger/YOUR-MOST-RECENT-INSTALL and simply run passenger start again.

给我一枪 2025-01-15 10:59:27

如果我没记错的话,只需要重新编译nginx即可。因为您在安装 PCRE 之前编译了 nginx,所以 nginx 无法与 PCRE 通信。

您可以通过编写

> nginx -V

复制您的参数来找到您的配置参数:并通过执行此操作重新编译 nginx

  1. 转到您的 nginx 下载文件夹
  2. > ./configure [您的配置参数位于此处]
  3. >制作
  4. > sudo make install

如果它不起作用,请尝试将 --with-pcre=[pcre 的路径] 添加到您的配置参数中

希望它能起作用;)

If I remember right, you only need to recompile nginx. Because you compiled your nginx before installed PCRE, nginx can not talk to PCRE.

You can find your configure arguments by writing

> nginx -V

Copy your arguments: and recompile nginx by doing this

  1. Go to your nginx download folder
  2. > ./configure [your configure arguments goes here]
  3. > make
  4. > sudo make install

If it does not work try to add --with-pcre=[path to pcre] to your configure arguments

Hope it will work ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文