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

feat: transition apache to use php-fpm/fcgi in dockers #385

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bradymiller
Copy link
Member

@bradymiller bradymiller commented Mar 8, 2024

fixes #384
(continued from #383)
transition apache to use php-fpm/fcgi in dockers

  1. First need to ensure this increases performance since does complicate the docker a little more (now have the php-fpm service also running in the docker along with the apache service).
  2. Then need to ensure nothing breaks (for example, api etc.)
  3. Then probably need to support some sort of monitoring mechanism when the php-fpm service breaks/dies on the docker (then in kubernetes type modes, can replace these broken dockers); note the docker already automatically breaks when the apache service dies/breaks.

To ensure that the apache php-fpm/fcgi is actually working: in OpenEMR, go to Admin->System->Diagnostic (SAPI setting should be fpm-fcgi)

@@ -3,20 +3,27 @@ FROM alpine:3.19
#Install dependencies and fix issue in apache
RUN apk --no-cache upgrade
RUN apk add --no-cache \
apache2 apache2-ssl apache2-utils apache2-proxy git php83 php83-tokenizer php83-ctype php83-session php83-apache2 \
apache2 apache2-ssl apache2-utils apache2-proxy git php83 php83-fpm php83-tokenizer php83-ctype php83-session \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note we are actually removing the php83-apache2 module :)

RUN sed -i "s/^user = [^ ]*/user = apache/" /etc/php83/php-fpm.d/www.conf
RUN sed -i "s/^group = [^ ]*/group = apache/" /etc/php83/php-fpm.d/www.conf
RUN sed -i "/^LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/ s/^/#/" /etc/apache2/httpd.conf
RUN sed -i "/LoadModule mpm_event_module modules\/mod_mpm_event.so/ s/# *//" /etc/apache2/httpd.conf
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above 2 lines will basically comment out the apache prefork MPM and then uncomment the apache event MPM

perl mysql-client tar curl imagemagick nodejs npm \
certbot openssl openssl-dev dcron \
rsync shadow ncurses \
&& sed -i 's/^Listen 80$/Listen 0.0.0.0:80/' /etc/apache2/httpd.conf
# Needed to ensure permissions work across shared volumes with openemr, nginx, and php-fpm dockers
RUN usermod -u 1000 apache

#BELOW LINE NEEDED TO SUPPORT PHP8 ON ALPINE 3.13+; SHOULD BE ABLE TO REMOVE THIS IN FUTURE ALPINE VERSIONS
#STEPS TO ENSURE php and php-fpm/fcgi both work, which configure proper user/group for php-fpm and set the alpine Event MPM
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will need to fix comment above and change alpine to apache

@@ -451,6 +451,8 @@ echo " > https://opencollective.com/openemr/donate"
echo ""

if [ "$OPERATOR" == "yes" ]; then
echo "Starting php-fpm!"
/usr/sbin/php-fpm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

off-to-the-races

@bradymiller
Copy link
Member Author

Noted some performance issues with this (appears it needs to be optimized dependent on server resources; out of box settings appear to not allow enough servers (a bunch of these settings) to optimally serve OpenEMR), so plan to make this turned on via a docker setting along with settings to optimize (nice excuse to learn more about php-fpm :) ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement support for PHP-FPM/FCGI in apache in dockers
2 participants