如何重新编译 nginx
我正在设置一个新服务器(我的第一个!)。
我已经安装了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
给出的答案将不起作用,因为您正在尝试将 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 tryrm -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.
如果我没记错的话,只需要重新编译nginx即可。因为您在安装 PCRE 之前编译了 nginx,所以 nginx 无法与 PCRE 通信。
您可以通过编写
复制您的参数来找到您的配置参数:并通过执行此操作重新编译 nginx
如果它不起作用,请尝试将 --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
Copy your arguments: and recompile nginx by doing this
If it does not work try to add --with-pcre=[path to pcre] to your configure arguments
Hope it will work ;)
页面末尾有一个 关于 nginx wiki 的非常简短的操作方法,较大版本似乎仅提供俄语。
There's a really short how-to on nginx wiki at the end of the page, the larger version seems to be available only in russian.