编译具有动态模块支持的 Apache Web 服务器
我刚刚在全新安装的 Ubuntu 10.04.2 上编译了 Apache 2.2.17。这是一个学习练习,旨在发现编译某些内容时实际发生的情况,而不仅仅是使用 apt-get,因此避免使用 apt-get 而有利于自己编译该内容。
我跑了:
sudo ./configure --prefix=/etc/apache --enable-module=so --enable-rule=SHARED_CORE --enable-shared=max --enable-ssl=shared --enable-rewrite=shared
后面是强制性的:
sudo make && sudo make install
一切似乎都很顺利(Apache 启动没有问题),除了在 Apache 模块目录中,我本来希望看到 mod_rewrite.so 和 mod_ssl.so,但我看到:
#cd /etc/apache/modules
#ls -l
mod_rewrite.a
mod_rewrite.la
mod_ssl.a
mod_ssl.la
我怎样才能转动这些到 .so 文件中,以便我可以将它们与 Apache 配置中的 LoadModule 链接?
提前致谢。
I have just compiled Apache 2.2.17 on a fresh install of Ubuntu 10.04.2. It's a learning exercise to discover what actually goes on when you compile something rather than just using apt-get hence the avoidance of using apt-get in favour of compiling the thing myself.
I ran:
sudo ./configure --prefix=/etc/apache --enable-module=so --enable-rule=SHARED_CORE --enable-shared=max --enable-ssl=shared --enable-rewrite=shared
followed by the obligatory:
sudo make && sudo make install
All seemed to go well (Apache starts up no problems) except that in the Apache modules directory where I would have expected to see mod_rewrite.so and mod_ssl.so, instead I see:
#cd /etc/apache/modules
#ls -l
mod_rewrite.a
mod_rewrite.la
mod_ssl.a
mod_ssl.la
How can I turn these into .so files so I can link them with LoadModule in the Apache config?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您不应该以 root 身份运行所有内容。
./configure
和make
在没有 root 权限的情况下也能正常工作,make install
需要 root 权限才能写入/etc和<代码>/usr/bin。
/etc
不适合可执行文件,更不用说完整的 Apache 安装了。如果要将配置文件放在/etc/apache
中,请使用--sysconfdir=/etc/apache
。安装自定义构建 Apache 的正确位置是/usr/local
。要启用共享模块,您必须传递
--enable-so
选项,应编译为共享的模块应添加到--enable-mods-shared
。Apache + mod_ssl(共享模块)+ mod_rewrite(共享模块)的正确配置行是安装在
/usr/local/apache
中,配置文件位于/etc/apache
中:成功配置 Apache HTTPd 后,运行
make
,然后运行 sudo make install
。有关配置选项的更多信息,请参阅 Apache HTTPd 文档。
You should not run everything as root.
./configure
andmake
will work fine without root permissions,make install
requires root permissions for writing to directories like/etc
and/usr/bin
./etc
is not suitable for executables, let alone a full Apache installation. If you want to put your configuration files in/etc/apache
, use the--sysconfdir=/etc/apache
. The correct place to install a custom-build Apache is/usr/local
.To enable shared modules, you have to pass the
--enable-so
option, the modules which should be compiled as shared should be added to--enable-mods-shared
.The correct configure line for Apache + mod_ssl (shared module) + mod_rewrite (shared module) is, installed in
/usr/local/apache
with configuration files in/etc/apache
:After successful configuring Apache HTTPd, run
make
followed bysudo make install
.More information about the configure options can be found at the Apache HTTPd documentation.
我遇到了同样的问题:尝试将所有(可能的)模块编译为动态模块而不是静态模块来编译 apache 2.2.x。
即使我使用了配置选项(--enable-mods-shared =“list,of,modules”),模块也被编译为静态而不是共享。更糟糕的是,当尝试“httpd -M”或“apachectl configtest”时,找不到与“*.so”文件相关的错误,即使它们列在刚刚安装的 httpd.conf 中(gmake install)。
我调查了 FreeBSD ports 系统,发现他们的 port 确实创建了一个带有所有共享模块的 apache2.2.x,正如我想要的那样。我发现这是“配置”选项的问题。
为了解决这个问题,我所做的与端口完全相同,在配置时,我首先“禁用”了所有模块(很难找到它们的完整列表,但得到了它),并在配置中使用了许多“--disable-MODULE”条目。这是我的工作示例:
这样,所有 apache2.2.x 模块都构建为动态而不是静态。
如果您忘记“--disable-XXX”它们而只尝试“--enable-XXX”甚至“--enable-mods-shared=XXX,YYY,ZZZ”,则它不起作用。您必须在设置“--enable-mods-shared”配置选项之前禁用它们。
I have suffered the same problem: tried to compile apache 2.2.x with all (possible) modules compiled as dynamic modules and not statically.
Even though I have used the configure option (--enable-mods-shared="list,of,modules") the modules were compiled as static and not as shared. And worse, some errors appeared when trying to "httpd -M" or "apachectl configtest" related to "*.so" files not being found even though they are listed in the httpd.conf just installed (gmake install).
I have investigated the FreeBSD ports system and found that their port indeed create an apache2.2.x with all shared modules, as I wanted. I have found that it is an issue with the "configure" options.
To solve, I have done exactly as the ports, when configuring I have first "disabled" all modules (hard to find the complete list of them but got it) with many "--disable-MODULE" entries in configure. Here is my working example:
This way, all the apache2.2.x modules were built as dynamic instead of static.
If you forget to "--disable-XXX" them and only try to "--enable-XXX" or even "--enable-mods-shared=XXX,YYY,ZZZ", it does not work. You have to disable them before setting the "--enable-mods-shared" configure option.
试试这个
--enable-shared=max 无效。我想你想用“大多数”?
http://httpd.apache.org/docs/2.2/programs/configure.html
Try this
--enable-shared=max is invalid. I think you wanted to use "most"?
http://httpd.apache.org/docs/2.2/programs/configure.html
极好的。谢谢你们的帮助。
我尝试了几次,但终于成功了。我最终不得不下载早期版本 Apache 的源代码,然后模块才能正确编译,而不是生成 .a 和 .la 文件。不确定这是否是因为在配置/制作/安装过程中发生了某种我不知道的缓存事情,并且我之前的(不正确的)编译尝试的某些部分正在以某种方式重新运行,或者可能是这样这与 Apache 2.2.17 版本有关 - 不确定。不管怎样,最后还是成功了。
Fantastic. Thank you both for your help.
It took a couple of attempts but I finally got it working. I ended up having to download the source for an earlier version of Apache before the modules would compile correctly instead of producing the .a and .la files. Not sure if that was because there is some kind of caching thing going on during the configure/make/install process that I'm not aware of and some part of my previous (incorrect) attempts at compiling were being re-run somehow or maybe it was something to do with the 2.2.17 version of Apache - not sure. Anyway, it worked in the end.