Skip to content

Commit

Permalink
Added use of php-fpm and http2 for hub
Browse files Browse the repository at this point in the history
Ticket: ENT-11440
Changelog: title
  • Loading branch information
craigcomstock committed Oct 7, 2024
1 parent 288007a commit 7f4df91
Show file tree
Hide file tree
Showing 12 changed files with 678 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deps-packaging/apache/cfbuild-apache.spec
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ CPPFLAGS=-I%{buildprefix}/include
--prefix=%{prefix}/httpd \
--enable-so \
--enable-mods-shared="all ssl ldap authnz_ldap" \
--enable-http2 \
--with-z=%{prefix} \
--with-ssl=%{prefix} \
--with-ldap=%{prefix} \
--with-apr=%{prefix} \
--with-apr-util=%{prefix} \
--with-pcre=%{prefix}/bin/pcre2-config \
--with-mpm=prefork \
CPPFLAGS="$CPPFLAGS"

%build
Expand Down
1 change: 0 additions & 1 deletion deps-packaging/apache/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ build-stamp:
--with-apr=$(PREFIX) \
--with-apr-util=$(PREFIX) \
--with-pcre=$(PREFIX)/bin/pcre2-config \
--with-mpm=prefork \
CPPFLAGS="$(CPPFLAGS)"
make

Expand Down
18 changes: 13 additions & 5 deletions deps-packaging/apache/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,19 @@ LogLevel warn

</IfModule>


LoadModule php_module modules/libphp.so
AddHandler php-script .php
AddType application/x-httpd-php-source php

# Use mod_http2
LoadModule http2_module modules/mod_http2.so
# Prefer http2 protocol
Protocols h2 h2c http/1.1

# Setup php to be handled by php-fpm. Required for use of mod_http2 due to threading issues in php.
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
# need to pass Authorization headers to fpm for API requests
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

<Directory "/var/cfengine/httpd/htdocs/public">

Expand Down
13 changes: 8 additions & 5 deletions deps-packaging/php/cfbuild-php.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Version: %{version}
Release: 1
Source0: php-%{php_version}.tar.gz
Source1: php.ini
Source2: php-fpm.conf
Source3: www.conf
License: MIT
Group: Other
Url: http://example.com/
Expand Down Expand Up @@ -45,10 +47,7 @@ LDFLAGS=""
--enable-mbstring \
--enable-sockets \
--disable-mbregex \
--without-fpm-user \
--without-fpm-group \
--without-fpm-systemd \
--without-fpm-acl \
--enable-fpm \
--without-layout \
--without-sqlite3 \
--without-bz2 \
Expand Down Expand Up @@ -114,6 +113,9 @@ make
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}%{prefix}/httpd/conf
cp %{prefix}/httpd/conf/httpd.conf ${RPM_BUILD_ROOT}%{prefix}/httpd/conf
mkdir -p ${RPM_BUILD_ROOT}%{prefix}/httpd/php/etc/php-fpm.d
cp ${RPM_BUILD_ROOT}/../../SOURCES/php-fpm.conf ${RPM_BUILD_ROOT}%{prefix}/httpd/php/etc
cp ${RPM_BUILD_ROOT}/../../SOURCES/www.conf ${RPM_BUILD_ROOT}%{prefix}/httpd/php/etc/php-fpm.d

INSTALL_ROOT=${RPM_BUILD_ROOT} make install

Expand Down Expand Up @@ -168,7 +170,8 @@ CFEngine Build Automation -- php -- development files
%prefix/httpd/php/lib
%prefix/httpd/php/bin
%prefix/httpd/php/php
%prefix/httpd/php/lib/php.ini
%prefix/httpd/php/etc
%prefix/httpd/php/sbin

%dir %prefix/httpd/modules
%prefix/httpd/modules/libphp.so
Expand Down
3 changes: 3 additions & 0 deletions deps-packaging/php/debian/cfbuild-php.install
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/var/cfengine/httpd/php/php
/var/cfengine/httpd/modules/libphp.so
/var/cfengine/httpd/php/lib/php.ini
/var/cfengine/httpd/php/etc/php-fpm.conf
/var/cfengine/httpd/php/etc/php-fpm.d/www.conf
/var/cfengine/httpd/php/sbin/php-fpm
8 changes: 4 additions & 4 deletions deps-packaging/php/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ build-stamp:
--enable-mbstring \
--enable-sockets \
--disable-mbregex \
--without-fpm-user \
--without-fpm-group \
--without-fpm-systemd \
--without-fpm-acl \
--enable-fpm \
--without-layout \
--without-sqlite3 \
--without-bz2 \
Expand Down Expand Up @@ -97,6 +94,9 @@ install: build

mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/httpd/conf
cp $(PREFIX)/httpd/conf/httpd.conf $(CURDIR)/debian/tmp$(PREFIX)/httpd/conf/httpd.conf
mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/httpd/php/etc/php-fpm.d
cp $(CURDIR)/php-fpm.conf $(CURDIR)/debian/tmp$(PREFIX)/httpd/php/etc/
cp $(CURDIR)/www.conf $(CURDIR)/debian/tmp$(PREFIX)/httpd/php/etc/php-fpm.d/

INSTALL_ROOT=$(CURDIR)/debian/tmp CPPFLAGS="-I$(PREFIX)/include" LD_LIBRARY_PATH="$(PREFIX)/lib" LD_RUN_PATH="$(PREFIX)/lib" $(MAKE) install

Expand Down
144 changes: 144 additions & 0 deletions deps-packaging/php/php-fpm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/var/cfengine/httpd/php). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var/cfengine/httpd/php/var
; Default Value: none
;pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /var/cfengine/httpd/php/var
; Default Value: log/php-fpm.log
;error_log = log/php-fpm.log
error_log = /var/cfengine/httpd/logs/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
;log_level = notice

; Log limit on number of characters in the single line (log entry). If the
; line is over the limit, it is wrapped on multiple lines. The limit is for
; all logged characters including message prefix and suffix if present. However
; the new line character does not count into it as it is present only when
; logging to a file descriptor. It means the new line character is not present
; when logging to syslog.
; Default Value: 1024
;log_limit = 4096

; Log buffering specifies if the log line is buffered which means that the
; line is written in a single write operation. If the value is false, then the
; data is written directly into the file descriptor. It is an experimental
; option that can potentially improve logging performance and memory usage
; for some heavy logging scenarios. This option is ignored if logging to syslog
; as it has to be always buffered.
; Default value: yes
;log_buffering = no

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /var/cfengine/httpd/php otherwise
include=/var/cfengine/httpd/php/etc/php-fpm.d/*.conf
Loading

0 comments on commit 7f4df91

Please sign in to comment.