shinsenter / php Goto Github PK
View Code? Open in Web Editor NEW๐ฆ Simplified PHP Docker images for effortless customization and extension setup.
Home Page: https://hub.docker.com/r/shinsenter/php
License: GNU General Public License v3.0
๐ฆ Simplified PHP Docker images for effortless customization and extension setup.
Home Page: https://hub.docker.com/r/shinsenter/php
License: GNU General Public License v3.0
I'm using render.com to expose service on Symfony with API Platform (running on free plan). I have managed to generate Dockerfile for that service so it build and deploy as expected. The problem occurs while I run any request from defined API - it returns 502 nginx error. I have done some check's and can't find anywhere more parameters about buffer size for fastcgi (not sure tho if that's the issue as locally I'm working with symfony package with frankenphp and caddy).
Request should return correct response.
*58 upstream sent too big header while reading response header from upstream, client: ::1, server: _, request: "GET /api/users?page=1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "<host>", referrer: "https://<host>/api/docs"
Able to run locally but not in a container environment such as AWS ECS. When I do, I get error:
s6-overlay-suexec: fatal: can only run as pid 1
This is the Dockerfile contents:
FROM shinsenter/phpfpm-apache:php8.1
# Set environment variables
ENV PHP_PM_MAX_CHILDREN=100
ENV PHP_PM_START_SERVERS=20
ENV PHP_PM_MIN_SPARE_SERVERS=10
ENV PHP_PM_MAX_SPARE_SERVERS=35
ENV PHP_PM_MAX_REQUESTS=1000
ENV PHP_UPLOAD_MAX_FILESIZE=200M
ENV APP_PATH=/var/www/foo
ENV DOCUMENT_ROOT=/var/www/foo/html
# Update and install additional packages
RUN phpaddmod \
mcrypt \
memcache \
pgsql \
rdkafka \
soap \
stomp \
xdebug \
xsl
# Set the working directory
WORKDIR /var/www/foo
# Copy application files
COPY . .
# Copy Apache vhosts configuration
COPY docker/apache/vhosts.conf.template /etc/apache2/sites-available/vhosts.conf
# Enable the site configuration
RUN a2ensite vhosts.conf
# Copy and unzip server.zip
COPY docker/foo/server.zip /tmp/server.zip
RUN unzip /tmp/server.zip -d /var/www/conf/ \
&& rm /tmp/server.zip
# Run Composer install commands
RUN composer install --no-dev --no-scripts --prefer-dist -o -d /var/www/foo \
&& composer install --no-dev --no-scripts --prefer-dist -o -d /var/www/foo/includes/classes/Azure/ExternalAPI
# Modify PHP settings and create necessary directories
RUN sed -i \
-e 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT \& ~E_WARNING \& ~E_NOTICE/g' \
"$PHP_INI_DIR/php.ini" \
&& mkdir -p /mnt/file_archive/{logs,dx,dx_archive,storage,cached} \
&& mkdir -p /var/www/conf \
&& mkdir -p /var/www/foo/html/foo/css/cached \
&& chown -R www-data:www-data /var/www
# Expose necessary ports
EXPOSE 80
I also tried the following suggestion
CMD [ "exec", "/init" ]
When requesting a php page it shows the PHP source.
Use this docker file:
FROM shinsenter/phpfpm-apache:php8.2
Requesting a php file in a browser, should return the parsed PHP-code.
It seems the fpm socket is pointing to /run/php/php-fpm.sock
The actual fpm socket is located at /run/php/php8.2-fpm.sock
Adding these lines fixes the problem:
ENV PHPFPM_SOCK_PATH=/run/php/php8.2-fpm.sock
RUN a2enconf php8.2-fpm
Hello, after a successful setup from Flarum on my Synology the logs show recurrently this error:
[Mon May 29 08:48:45.815751 2023] [:crit] [pid 303] (38)Function not implemented: AH00141: Could not initialize random number generator
Flarum is not accessible but the container is running.
sysadmin@iHome:/$ uname -a
Linux iHome 3.10.105 #25556 SMP Tue Mar 21 22:22:21 CST 2023 x86_64 GNU/Linux synology_cedarview_1812+
1.Install Flarum on a Synology DSM 6.2.4 or higher (confirmed in the nextcloud github with DSM 7.x)
2.
3.
I know the issue is not directly related with your container, but have you any idea how to solve this?
You can see the similar issue for phpmyadmin: phpmyadmin/docker#373
The same with nextcloud: nextcloud/docker#1574
Hello,
I want to express my gratitude for your dedication to this repository. Really awesome work!
Our team utilizes the Docker image for development purposes.
Firstly, I'm curious if there's a specific build tag intended for production usage. Despite the frequent changes, is there a stable tag or version we can rely on for building? It would be helpful if you could provide guidance on its usage in a production environment.
Additionally, are there any optimizations recommended for the production environment?
Thank you.
Looks like a php-fpm.sock issue. This worked fine with the image from January.
Using the image 'shinsenter/crater:php8.1-tidy'
2024/02/01 11:58:40 [crit] 1934#1934: *5 open() "/var/lib/nginx/tmp/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 10.42.2.35, server: localhost, request: "GET /invoices/pdf/ODR8nvGjg82gLqp4m26r HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm.sock:", host: "crater", referrer: "https://crater/admin/invoices/23/view"
Hi there,
Currently i got errors in my docker container
AH00526: Syntax error on line 125 of /etc/apache2/httpd.conf: User takes one argument, Effective user id for this server [26-Jan-2024 10:12:21] ERROR: failed to open configuration file '/usr/local/etc/php-fpm.d/zz-generated-settings.conf': No such file or directory (2) [26-Jan-2024 10:12:21] ERROR: failed to load configuration file '/usr/local/etc/php-fpm.d/zz-generated-settings.conf' [26-Jan-2024 10:12:21] ERROR: FPM initialization failed
This has been happening lately, and I see you've done something there, am I missing something?
HI there. I was wondering if you can make an example for use with traefik. For me it isn't working with traefik. I get 503 errors or redirect loops in an TYPO3 installation. Without traefik it worked. So I think there is an error for me.
Hey,
As a beginner I wanted to use your image for a project where I need to install mongodb via pecl, though I couldn't make it work because of the state of php and pecl
At first, just using pecl command was problematic :
PHP Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
ERROR: The default config file is not a valid config file or is corrupted.
I found someone on internet saying I should rm /usr/local/etc/pear.conf, and it did make it pass the warning but trying:
root@66b184571134:/var/www/html# pecl install mongodb
PHP Warning: Failed to set memory limit to 0 bytes (Current memory usage is 2097152 bytes) in Unknown on line 0
Invalid channel name "pecl.php.net"
invalid package name/package file "mongodb"
install failed
Even though I'm still getting this weird memory error I think the important thing here is about the channel name, I couldn't find anything about it, and it is repeated in a lot of the commands I'm trying
Can someone help ?
Hello,
I'm having an issue with the cron jobs. They do not work. Here is my Dockerfile:
FROM shinsenter/phpfpm-apache:php8.2
ENV APP_UID=1004
ENV APP_GID=1005
ENV TZ="UTC"
ENV APP_PATH="/var/www/html"
ENV DOCUMENT_ROOT="/public"
ENV ENABLE_CRONTAB=1
ENV DEBUG=1
ENV FIX_APP_PATH_PERMISSION=1
COPY docker/.env /.env
COPY app/crons /crons/
COPY app/crontab /etc/cron.d/crontab
RUN chmod 0644 /etc/cron.d/crontab
RUN mkdir -p /var/log/cron
RUN crontab /etc/cron.d/crontab
And the crontab file
* * * * * /crons/cron-test.sh
And the cron-test.sh file
#!/bin/dash
php /var/www/html/crons-php/cron-test.php >> /var/log/cron/cron.log
And the cron-test.php file
<?php
echo "Cron job worked \n";
Hi..
What is the difference with shinsenter/phpfpm-nginx and shinsenter/php using nginx and php-fpm??
Hi, crater docker is very nice. But there is a problem. It does not accept database information on the url/install page. I get the following error. So I checked the .env file, everything seems correct. Thank you in advance for your help!
SQLSTATE[HY000] [1045] Access denied for user 'crater'@'172.18.0.6' (using password: YES)
Note: I couldn't find your Crater Invoice project here, but I was able to follow it from hub.docker.com.
I get multiple errors when starting the docker image with the given example compose file.
docker-compose.yml
and start it with docker-compose up
. Attention: I used different ports for crater and myql, and the network part is taken from crater's docker-compose example.version: '3'
services:
crater:
# do not update until https://github.com/shinsenter/php/issues/18#issuecomment-1366262015 is fixed
image: shinsenter/crater:php8.1
restart: always
volumes:
- ./volumes/crater:/var/www/html:rw
# - ./ssl-certs:/etc/ssl/web
environment:
TZ: Europe/Vienna
PUID: ${UID:-9999}
PGID: ${GID:-9999}
# REDIS_HOST: redis
DB_HOST: mysql
DB_DATABASE: crater
DB_USERNAME: root
DB_PASSWORD: mydb_p@ssw0rd
# CRATER_QUEUE_ENABLED: true
# CRATER_QUEUE_OPTIONS: --timeout=60 --tries=3 redis
# CRATER_SCHEDULE_ENABLED: true
ports:
- "3050:80"
# - "443:443"
links:
- mysql
# - redis
networks:
- crater
mysql:
image: mysql:8.0.32
restart: always
environment:
TZ: Europe/Vienna
MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd
MYSQL_DATABASE: crater
volumes:
- "./volumes/mysql/data:/var/lib/mysql"
# - "./volumes/mysql/dump:/docker-entrypoint-initdb.d"
ports:
- "3060:3306"
networks:
- crater
# redis:
# image: redis:7.0.8-alpine
# ports:
# - "6379:6379"
networks:
crater:
driver: bridge
Not sure why this is happening at the moment
Values are not taken from the compose file as expected
The port is not taken from the compose file, which leads to an error as expected
Even when I change the port to the one in the compose file it does not work:
At cold starts, for a brief time, we get 503 errors.
[Mon Jan 09 19:35:42.278107 2023] [proxy:error] [pid 1131:tid 68609648887360] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /var/run/php/php-fpm.sock (localhost:8000) failed
[Mon Jan 09 19:35:42.278549 2023] [proxy_fcgi:error] [pid 1131:tid 68609648887360] [client 169.254.1.1:63202] AH01079: failed to make connection to backend: httpd-UDS
169.254.1.1 - - [09/Jan/2023:19:35:42 +0000] "GET /i.php HTTP/1.1" 503 473 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
2023-01-09 21:35:42.287 EET
GET 503 1,016 B 4.9s Chrome 108 https://example.org/i.php
create a i.php phpinfo() file to host container
503 errors should not happen before proper booting of environment
My suspicion is that Apache is up sooner than FPM PHP, and this causes the errors.
FROM shinsenter/phpfpm-apache:php8.2
ENV PHP_OPEN_BASEDIR /
RUN echo 'error_log = /var/log/php_error_log' >> /etc/php/8.2/fpm/php.ini \
&& echo 'ignore_repeated_errors = on' >> /etc/php/8.2/fpm/php.ini \
&& sed -i 's/80/8080/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf \
&& echo "ServerSignature Off" >> /etc/apache2/apache2.conf
COPY . /var/www/html
EXPOSE 8080
I've encountered an issue with the shinsenter/php
Docker image, where .html
files result in a "Forbidden" error, while .php
files are served as expected. It's unclear if this behavior is by design or an oversight.
Firstly, I want to express my gratitude for the effort put into creating and maintaining these images. Your work greatly facilitates our development processes, and it is much appreciated.
Expected: Both .php
and .html
files should be served without issue.
Actual: .html
files result in a "AH01630: client denied by server configuration" response, indicating a potential configuration issue.
shinsenter/php:8.2-fpm-apache
image..php
and .html
files in the web directory..html
file through a browser.Could you please clarify if the "Forbidden" status for .html
files is intended? Any guidance on serving .html
files or a potential fix would be greatly appreciated.
Thank you for your ongoing support and dedication to the community.
With the latest changes, my install no longer works.
It gets stuck on the apt-get line, with "no installation candidate" for both php7.4-dev and php-pear
Am I going to need to change something, or is this a bug?
FROM shinsenter/phpfpm-apache:php7.4
# Update and install packages
RUN apt-get update && apt-get install -y libmcrypt-dev php7.4-dev php-pear
# Install mcrypt via PECL
RUN pecl config-set php_ini "${PHP_INI_DIR}/php.ini"
RUN pecl install mcrypt
# And and Enable BZ2 and Mcrypt extensions
RUN phpaddmod bz2 && phpenmod bz2 mcrypt
# Enable RemoteIP to get proper client IP when Cloudflare and/or AWS Load Balancer is present
RUN a2enconf remoteip
RUN echo "RemoteIPHeader X-Forwarded-For" > /etc/apache2/conf-available/remoteip.conf
# Control your timezone
ENV TZ="America/Chicago"
# sets GID and UID
ENV PUID=33
ENV PGID=33
# Sets the directory from which Apache will serve files
ENV WEBHOME="/srv/www"
ENV FIX_WEBHOME_PERMISSION="true"
# Set Apache root folder within $WEBHOME
ENV APACHE_DOCUMENT_ROOT="/public_html"
# Set root path of what PHP is allowed to access (to get access to the "data" folder from EFS)
ENV PHP_OPEN_BASEDIR="/srv"
# Copy source to the right place and setup proper ownership
COPY . /srv/www/
WORKDIR $WEBHOME
Hi there,
Using this Docker image for quite some time, thank you for your efforts.
Today, I tried to create a Docker image with the following base-image:
ARG PHP_VERSION=8.2
ARG PHP_VARIATION=fpm-apache
FROM shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} AS base
ARG BUILD_TAG
# Set the environment variable based on the tag
ENV BUILD_VERSION=$BUILD_TAG
ENV WEBHOME="/app"
ENV APACHE_DOCUMENT_ROOT="/web"
ENV TZ="Europe/Amsterdam"
ENV PHP_POST_MAX_SIZE="200M"
ENV PHP_UPLOAD_MAX_FILE_SIZE="200M"
RUN phpaddmod imagick
Above image is unable to build for me;
12.30 Installing curl
12.31 Reading package lists...
12.64 Building dependency tree...
12.72 Reading state information...
12.82 curl is already the newest version (7.88.1-10+deb12u5).
12.82 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
12.82 Installing PHP modules: imagick
13.53 Installing PHP modules: imagick
13.55 install-php-extensions v.2.1.81
13.55 #StandWithUkraine
13.58 /usr/local/aliases/php: line 2: cd: /app: No such file or directory
------
Dockerfile:20
--------------------
18 |
19 |
20 | >>> RUN phpaddmod imagick
--------------------
ERROR: failed to solve: process "/bin/sh -c phpaddmod imagick" did not complete successfully: exit code: 1
Any tips as of why this might happening? Thanks in advance!
./src/php/common/rootfs/etc/cont-init.d/10-project: echo '<?php phpinfo();' >"$APPROOT/index.php"
Please fix this, you are currently placing this in the apache document root.
In your CI4 image, the index.php is mandatory in the urls even when configured for remover in the CI4 settings. I don't know if you have to enable something in apache in your image to have the rewrite. I've tested other CI4 images and haven't seen this issue.
Crater container is not usable due to a Symfony exception. This occurs 100% of the time
docker compose up -d
An installation guide most likely, I don't know what to expect really.
docker-compose.yaml
version: "3.5"
networks:
default:
npm_default:
external: true
services:
mariadb:
image: lscr.io/linuxserver/mariadb:latest
container_name: crater_mariadb
environment:
- PUID=1000
- PGID=1000
- TZ=America/Toronto
- MYSQL_ROOT_PASSWORD=RelieveFutureEarly
- MYSQL_DATABASE=crater
- MYSQL_USER=crater
- MYSQL_PASSWORD=DespoticLudicrousWorkerUnrestrained
volumes:
- ./appdata/mariadb:/config
restart: unless-stopped
redis:
restart: unless-stopped
container_name: crater_redis
image: redis:latest
crater:
image: shinsenter/crater:latest
restart: unless-stopped
container_name: crater
ports:
- '3080:80'
volumes:
- ./appdata/crater:/var/www/html
environment:
- TZ=America/Toronto
- PUID=1000
- PGID=1000
- REDIS_HOST=redis
- DB_HOST=mariadb
- DB_DATABASE=crater
- DB_USERNAME=crater
- DB_PASSWORD=DespoticLudicrousWorkerUnrestrained
# - CRATER_QUEUE_ENABLED=true
# - CRATER_QUEUE_OPTIONS=--timeout=60 --tries=3 redis
# - CRATER_SCHEDULE_ENABLED=true
links:
- mariadb
- redis
The symfony exception
When my "startup" scripts run (from the /startup folder), it used to be relative to the APP_PATH (I use WORKDIR $APP_PATH
as the last line in my Dockerfile). But I noticed yesterday in some other testing that my scripts were failing to find files I was accessing. I went ahead and added cd $APP_PATH to the top of my script and that resolved my issue.
So, I guess at some point in some of your recent updates, something changed and the process is no longer in WORKDIR when the startup scripts run?
Hi there,
I have a custom apache config that I add to the image:
ADD ./docker/apache/custom.conf /etc/apache2/docker.d/custom.conf
The contents of this file is;
LogFormat "{ \"time\":\"%t\", \"remoteIP\":\"%a\", \"host\":\"%V\", \"request\":\"%U\", \"query\":\"%q\", \"method\":\"%m\", \"status\":\"%>s\", \"userAgent\":\"%{User-agent}i\", \"referer\":\"%{Referer}i\", \"originalUri\": \"%{Plugin-Original-Uri}i\" }" combined
CustomLog ${APACHE_ACCESS_LOG} combined
However, I cannot see the json logs in the terminal when visiting a page. What can I do to achieve this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.