Question

Hello I asked this question to superuser but I did not get a good question there and i really need the answer. I know some of you here can answer this question.

I have installed nginx via yum. Now I want to add a module, but I have to compile the source again and include the the new module.

But i can't find the source. Does someone know what I have to do to recompile the source and get the module in.

Update

I did everything in the answer from Patrick and it worked out great. However when now when I run the yum update it wants to update the installed rpm with the same version.

Can I just let it update, or should i specify that it is already up to date.

Was it helpful?

Solution

Redhat and related distributions (fedora, centos) keep their source rpms in a highly regular directory tree. for RHEL5 you want: ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/ for other releases, you can browse the ftp server until you find what you want. Otherwise, google for the exact version of nginx you have (rpm -q nginx)

Assuming you can find the srpm, install it with rpm:

rpm -ivh nginx-xxxx.src.rpm

This'll put the sources and build files in /usr/src/redhat/{BUILD,SPEC,SRC,SOURCES}. You can modify the .spec file in /usr/src/redhat/SPEC to build the module you want along with the rest of nginx, or you can build nginx manually.

Which module do you want to build? In fedora's nginx.spec, several modules are specified when configure is run. This may be as simple as adding a line here:

./configure \
[snip...]
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_perl_module \
[snip...]

After adding whatever changes to nginx.spec, you can build the final rpm with rpmbuild:

rpmbuild -ba nginx.spec

Assuming the package builds without error, rpmbuild will leave it in /usr/src/redhat/RPMS/

Update: yum will want to replace your nginx package as updates become available. You will probably want to rebuild each new package as it becomes available, using the same process as above. However, If security is not a concern, you can simple exclude nginx from the update list by adding the following to your yum config (probably /etc/yum.repos.d/${repo}.repo or similar. Be sure to associate it with the right repo):

exclude=nginx*

Or running yum with the --exclude option

yum --exclude=nginx*
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top