Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please checkout the change to enable building fcgiwrap as RPM package #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
targetdir = $(DESTDIR)@prefix@@sbindir@
man8dir = $(DESTDIR)@prefix@@mandir@/man8
targetdir = $(DESTDIR)@sbindir@
man8dir = $(DESTDIR)@mandir@/man8
datarootdir =

.PHONY: clean distclean
Expand Down
66 changes: 61 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fcgiwrap
:Author: Grzegorz Nosek <[email protected]>
:Contributors: W-Mark Kubacki <[email protected]>
Jordi Mallach <[email protected]>
Justin Zhang <[email protected]>


This page has been translated into `Spanish <https://www.webhostinghub.com/support/es/misc/fcgiwrap>`_ language by Maria Ramos from `Webhostinghub.com/support/edu <https://www.webhostinghub.com/support/edu>`_.
Expand All @@ -17,9 +18,11 @@ Features
- handles environment in a sane way (CGI scripts get HTTP-related env. vars from FastCGI parameters and inherit all the others from ``fcgiwrap``'s environment)
- no configuration, so you can run several sites off the same ``fcgiwrap`` pool
- passes CGI stderr output to ``fcgiwrap``'s stderr or FastCGI stderr stream
- support systemd socket activation, launcher program like spawn-fcgi
is no longer required on systemd-enabled distributions

Installation
============
Install from source
===================

requirements
------------
Expand All @@ -41,9 +44,62 @@ To install::
*fcgiwrap* will be copied to ``/usr/local/sbin/fcgiwrap`` if you did not set
``--prefix`` for configure or ``DESTDIR`` for the makefile.

usage
-----
Most probably you will want ``fcgiwrap`` be launched by `www-servers/spawn-fcgi <https://redmine.lighttpd.net/projects/spawn-fcgi>`_. Or you could use the author's Perl launcher - see the homepage for that.
Install from RPM package
========================

requirements
------------
At the time of writing, the *fcgiwrap* RPM is not included in any public
repository. As a result, You have to build the RPM from scratch by following
the procedure below:

build the RPM package
---------------------
Install required dependencies RPM build tools::

sudo yum install -y autoconf automake fcgi-devel pkgconfig rpm-build

On systemd enabled OS, you need additional ``systemd-devel`` pacakge::

sudo yum install -y systemd-devel

Then you download appropriate version of the fcgiwrap source tarball from
Github or clone this repository and build the source tarball by using this
command::

git archive --format tgz --prefix fcgiwrap-1.1.0/ HEAD > fcgiwrap-1.1.0.tgz

Then you can kick off the RPM build by running::

rpmbuild -ta fcgiwrap-1.1.0.tgz

and locate the result .rpm file at ~/rpmbuild/RPMS.

install the RPM package
-----------------------
The RPM package of *fcgiwrap* include the excutable ``/usr/sbin/fcgiwrap``
and manual page. If you build the RPM package on systemd enabled OS, the
systemd unit files are included in this package as well. To install the
package, run command like below::

sudo rpm -Uhv fcgiwrap-1.1.0-1.fc18.armv6hl.rpm

The exact name of the RPM package file depends on the OS and hardware
architecture where you build the RPM.

Usage
=====
If you are on traditional SysV init systems, most probably you will want
``fcgiwrap`` be launched by `www-servers/spawn-fcgi
<https://redmine.lighttpd.net/projects/spawn-fcgi>`_. Or you could use
the author's Perl launcher - see the homepage for that. On the systemd
enabled distributions like Fedora 14+, RHEL 7+, you can take advantage
of systemd socket activation feature instead of the extra launcher like
spawn-fcgi. The systemd unit files ``fcgiwrap.socket`` and
``fcgiwrap.service`` is included in the tarball release under
``systemd`` directory. You can also build the RPM package by following
the instructions aforementioned. The RPM package installs and enables
the socket activation for fcgiwrap automatically on systemd enabled OS.

There are two modes of ``fcgiwrap`` operation:
- when *SCRIPT_FILENAME* is set, its value is treated as the script name and executed directly.
Expand Down
95 changes: 95 additions & 0 deletions fcgiwrap.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
%define systemd_test_str %(
if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then
echo "yes"
else
echo "no"
fi
)
%if "%{systemd_test_str}" == "yes"
%define with_systemd 1
%endif

Name: fcgiwrap
Version: 1.1.0
Release: 1%{?dist}
Summary: Simple FastCGI wrapper for CGI scripts
Group: System Environment/Daemons
License: BSD-like
URL: https://nginx.localdomain.pl/wiki/FcgiWrap
Source0: %{name}-%{version}.tgz
BuildRequires: autoconf automake fcgi-devel pkgconfig
%{?with_systemd:BuildRequires: systemd-devel systemd}
Requires: fcgi


%description
This package provides a simple FastCGI wrapper for CGI scripts with/
following features:
- very lightweight (84KB of private memory per instance)
- fixes broken CR/LF in headers
- handles environment in a sane way (CGI scripts get HTTP-related env.
vars from FastCGI parameters and inherit all the others from
environment of fcgiwrap )
- no configuration, so you can run several sites off the same
fcgiwrap pool
- passes CGI stderr output to stderr stream of cgiwrap or FastCGI
- support systemd socket activation, launcher program like spawn-fcgi
is no longer required on systemd-enabled distributions


%prep
%setup -q


%build
autoreconf -i
%configure
make %{?_smp_mflags}


%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{_sbindir}/fcgiwrap
#TODO: figure out why the manpage file is compressed automatically
%doc %{_mandir}/man8/fcgiwrap.8.gz
%{?with_systemd:
%{_unitdir}/*.service
%{_unitdir}/*.socket
}


%post
# enable socket activation for fcgiwrap
if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then
/usr/bin/systemctl enable fcgiwrap.socket
/usr/bin/systemctl start fcgiwrap.socket

cat <<BANNER
==================================================
FCGI service fcgiwrap is ready!!!
==================================================
BANNER
fi


%preun
# stop and disable socket activation for fcgiwrap
if [[ -z $(pkg-config --print-errors libsystemd-daemon 2>&1) ]]; then
/usr/bin/systemctl stop fcgiwrap.socket
/usr/bin/systemctl disable fcgiwrap.socket
fi


%changelog
* Tue Apr 22 2014 Justin Zhang <schnell18[AT]gmail.com> - 1.1.0-1
- version 1.1.0
- Create RPM spec file for the fcgiwrap