我刚刚安装了乘客:
gem install passenger
cd /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2
env NOEXEC_DISABLE=1 /usr/local/rvm/gems/ruby-2.4.0/wrappers/rake nginx:clean nginx RELEASE=yes
然后编辑/etc/apt/sources.list
并添加:
deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
然后apt-get update
,cd /var/tmp
和apt-get source nginx
。在正确的位置添加--add-module=/usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/src/nginx_module \
到。debian\rules
在使用 Passenger 模块支持编译 nginx 时出现问题:
apt-get build-dep nginx
dpkg-buildpackage -b
-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie -ldl -lpthread -lpthread -lcrypt /var/tmp/ngx_pagespeed-1.12.34.2-beta/psol/lib/Release/linux/x64/pagespeed_automatic.a -lstdc++ -lrt -pthread -lm -lexpat /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Logging.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Exceptions.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils/SystemTime.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils/StrIntUtils.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils/StrIntUtilsNoStrictAliasing.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils/IOUtils.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/WatchdogLauncher.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/AppTypes.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Utils/CachedFileStat.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/UnionStationFilterSupport.o /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libboost_oxt.a -lstdc++ -lpthread -lm -lrt -lpcre -lssl -lcrypto -ldl -lz -lGeoIP \ -Wl,-E /usr/bin/ld.bfd.real: /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Logging.o: 在创建共享对象时不能使用针对“.bss”的重定位 R_X86_64_32;使用 -fPIC 重新编译 /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/buildout/common/libpassenger_common/Logging.o: 添加符号时出错:错误值 collect2:错误:ld 返回 1 退出状态 objs/Makefile:344:目标‘objs/nginx’的配方失败 make[2]: *** [objs/nginx] 错误 1 make[2]: 离开目录 '/var/tmp/t/nginx-1.10.3/debian/build-nginx' Makefile:8:目标‘build’的配方失败 make[1]: *** [构建] 错误 2 make[1]: 离开目录 '/var/tmp/t/nginx-1.10.3/debian/build-nginx' debian/rules:60:目标‘build-arch.nginx’的配方失败 make:*** [build-arch.nginx] 错误 2 dpkg-buildpackage:错误:debian/rules build 给出错误退出状态 2
这是输出passenger-config --nginx-addon-dir
:
/usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/src/nginx_module
奇怪的是,如果我尝试从源代码编译 nginx,passenger-install-nginx-module
一切都正常。
无论如何,有人知道我该如何解决这个问题吗?对我来说,按照上述步骤编译 nginx 是必须的。我希望能够在解决问题的同时遵循上述步骤。
谢谢 :)
答案1
最后我编辑/usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2/src/ruby_supportlib/phusion_passenger/platform_info/cxx_portability.rb
并将此行替换flags << "-fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED"
为flags << "-fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -fPIC"
。然后通过运行之前的 rake 命令编译 Passenger env NOEXEC_DISABLE=1 /usr/local/rvm/gems/ruby-2.4.0/wrappers/rake nginx:clean nginx RELEASE=yes
。