views:

79

answers:

1

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.

+1  A: 

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*
Patrick
Thank you for the answer. I have found the rpm. I tried rpm -ivh nginx-xxxx.src.rpm but this just installs the file without leaving any traces behind.
Saif Bechan
what does "rpm2cpio nginx-xxx.src.rpm | cpio --list" give you? You can also unpack the package manually with "rpm2cpio nginx-xxx.rpm | cpio -ivd"
Patrick
Yes i found the problem, I did not get the src package but the compiled one. Now the files go in the right directories. Let me try the rebuild
Saif Bechan
Yes I think this method worked. I did not get any errors. Thank you for the nice response and your time.
Saif Bechan
Saif, I've added some discussion of what to do about updates. In brief, either get the new .src.rpm and build it, or exclude nginx from updates.
Patrick
Thank you I will try this right away!
Saif Bechan