Code Monkey home page Code Monkey logo

nginx-php-fpm's Introduction

Docker Hub; wyveo/nginx-php-fpm nginx 1.25.2 php 8.2.9 License MIT

Introduction

This is a Dockerfile to build a debian based container image running nginx and php-fpm 8.2.x / 8.1.x / 8.0.x / 7.4.x / 7.3.x / 7.2.x / 7.1.x / 7.0.x & Composer.

Versioning

Docker Tag GitHub Release Nginx Version PHP Version Debian Version Composer
latest master Branch 1.25.2 8.2.9 bullseye 2.5.8
php82 php82 Branch 1.25.2 8.2.9 bullseye 2.5.8
php81 php81 Branch 1.21.6 8.1.3 bullseye 2.2.7
php80 php80 Branch 1.21.6 8.0.16 buster 2.0.13
php74 php74 Branch 1.21.6 7.4.28 buster 2.0.13
php73 php73 Branch 1.21.6 7.3.33 buster 2.0.13
php72 php72 Branch 1.21.6 7.2.34 buster 2.0.13
php71 php71 Branch 1.21.6 7.1.33 buster 2.0.13
php70 php70 Branch 1.21.6 7.0.33 buster 2.0.13

Building from source

To build from source you need to clone the git repo and run docker build:

$ git clone https://github.com/wyveo/nginx-php-fpm.git
$ cd nginx-php-fpm

followed by

$ docker build -t nginx-php-fpm:php82 . # PHP 8.2.x

Pulling from Docker Hub

$ docker pull wyveo/nginx-php-fpm:php82

Running

To run the container:

$ sudo docker run -d wyveo/nginx-php-fpm:php82

Default web root:

/usr/share/nginx/html

nginx-php-fpm's People

Contributors

battlecook avatar colinwilson avatar gusdnr9875 avatar manuasir avatar maxdmyers avatar pezhvak avatar vladbndko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-php-fpm's Issues

Laravel doesn't work

Running:

docker run -d -p 80:80 --restart=unless-stopped wyveo/nginx-php-fpm:latest

I can see the index.php generated automatically by Nginx, but when cloning the repository of a Laravel project on usr/share/nginx/html/ I get numerous errors, even with 777 permissions on files and folders.

add module headers-more-nginx-module to hide the Server information in the header

It would be great to have the headers-more-nginx-module module added by default.

I'm currently using it on my docker image and it's useful because have all the default libs I need. However, after a couple of penetration testing reports I had been asked to remove the Server: nginx value from the response header.

I've added server_tokens off; to the nginx config to hide the version, but I need to use more_clear_headers Server; to completely remove the information. I can only do with this module apparently, unless there is another way.

Any recommendation would be great to solve the problem sooner than awaiting for an eventual update.
Thank you for the hard work.
Sam

Wrong Web Server Root Path & php.in path

Hello, thank you very much for your docker image

i have problem after run your image, i have loaded on port 8080
and i got this as output

Congratulations!
You have successfully deployed a docker container running our NGINX with PHP-FPM 7.x image

NGINX: v1.21.6-1~buster
PHP-FPM: v7.4.28
LOADED CONFIG: /etc/php/7.4/fpm/php.ini
WEB ROOT: /usr/share/nginx/html
HOSTNAME: 61d41983fabc

Thank you for using wyveo.com

but there is no folder created /usr/share/nginx/html and even i create the folder and put my test index.php file it does not reflect the path
also it seem that also /etc/php/7.4/fpm/php.ini is not present


[root@snapshot-38872278-centos-16gb-hel1-1 nginx-php-fpm]# locate php.ini 
/etc/php.ini
/usr/share/doc/php-common-7.4.29/php.ini-development
/usr/share/doc/php-common-7.4.29/php.ini-production
/usr/share/phpMyAdmin/test/travis.php.ini
/var/lib/docker/aufs/diff/73ba5965c32d9a7ceccad7dee23909d3caf1c2b1862e3dd51228f6bcc1c94281/etc/php/7.4/cli/php.ini
/var/lib/docker/aufs/diff/73ba5965c32d9a7ceccad7dee23909d3caf1c2b1862e3dd51228f6bcc1c94281/etc/php/7.4/fpm/php.ini
/var/lib/docker/aufs/diff/73ba5965c32d9a7ceccad7dee23909d3caf1c2b1862e3dd51228f6bcc1c94281/usr/lib/php/7.4/php.ini-development
/var/lib/docker/aufs/diff/73ba5965c32d9a7ceccad7dee23909d3caf1c2b1862e3dd51228f6bcc1c94281/usr/lib/php/7.4/php.ini-production
/var/lib/docker/aufs/diff/73ba5965c32d9a7ceccad7dee23909d3caf1c2b1862e3dd51228f6bcc1c94281/usr/lib/php/7.4/php.ini-production.cli
/var/lib/docker/aufs/mnt/e5031e395d0e8790553d3f360c61e07cdf41feec11068960b7f6a1cf15777e75/etc/php/7.4/cli/php.ini
/var/lib/docker/aufs/mnt/e5031e395d0e8790553d3f360c61e07cdf41feec11068960b7f6a1cf15777e75/etc/php/7.4/fpm/php.ini
/var/lib/docker/aufs/mnt/e5031e395d0e8790553d3f360c61e07cdf41feec11068960b7f6a1cf15777e75/usr/lib/php/7.4/php.ini-development
/var/lib/docker/aufs/mnt/e5031e395d0e8790553d3f360c61e07cdf41feec11068960b7f6a1cf15777e75/usr/lib/php/7.4/php.ini-production
/var/lib/docker/aufs/mnt/e5031e395d0e8790553d3f360c61e07cdf41feec11068960b7f6a1cf15777e75/usr/lib/php/7.4/php.ini-production.cli

do i need to search and edit php.ini files into the container? do i need to use this folder for use /usr/share/nginx/html ?

thanks a lot

Installing PHP Modules

Is there a method to add additional PHP modules into this docker at runtime? I see that I could fork the code and add them into Dockerfile.

I'm building a Moodle docker and it requires xmlrpc and a couple other modules. I'm using docker-compose to configure.

PHP don't see ENV variables

How to get PHP to be able to read system environment variables ?
I have Inspect Environment and in docker they are exist but by php they are not visible

There is a problem here too
obraz

Add bcmath extension

Hello,

Would it be possible to add PHP's bcmath extension? It is needed for libs such as amqplib and Money :)
And BTW would it be possible to update PHP to version 7.2.12 ?

MSMTP support

This image is very nice, but....
I tested it with the Wordpress folder:
It is unable to send email
Can you add support for msmtp?

Adding php7.3/4-gmp when using this image requires interactive prompt to deal with changed fpm config

Dockerfile:

FROM wyveo/nginx-php-fpm:php74

LABEL maintainer [email protected]

# Remove existing webroot, configure PHP session handler for Redis, install postgresql-client (pg_dump)
RUN apt-get update && \
apt-get install -y libgmp-dev php7.4-gmp

Then build using docker build .

This will ask for a prompt:

Configuration file '/etc/php/7.4/fpm/pool.d/www.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** www.conf (Y/I/N/O/D/Z) [default=N] ? dpkg: error processing package php7.4-fpm (--configure):
 end of file on stdin at conffile prompt

Work-around is to answer the prompt like so:

FROM wyveo/nginx-php-fpm:php74

LABEL maintainer [email protected]

# Remove existing webroot, configure PHP session handler for Redis, install postgresql-client (pg_dump)
RUN apt-get update && \
echo "N" | apt-get install -y libgmp-dev php7.4-gmp

Permissions to edit files from the host

Is it an easy way to edit permissions to edit from the host?

I tried this on my Dockerfile but it is not working:

RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

# src is where all my code lives.
COPY --chown=www:www src /usr/share/nginx/html

As soon as the image starts all the files change to this:
image

Running this image on the server works perfectly. If it's possible I would like to use the same image on my development workflow too.

Readme is not beginner friendly

The run command doesn't map any port. So, how may I run a webpage? php-fpm run on port 9000. should I use another Ngnix proxy and do proxy_pass to port 9000. I am trying to do load balancing two or more Nginx + php-fpm instances on separate machine.

Why are we using supervisord?

I notice you're trying to run nginx and php-fpm under supervisord - which makes little sense.

nginx and php-fpm already do what supervisord does - or am I missing something?

supervisord logs are written to filesystem

Due to these lines in supervisord.conf
https://github.com/wyveo/nginx-php-fpm/blob/master/supervisord.conf#L6-L9

[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB        ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10           ; (num of main logfile rotation backups;default 10)

supervisord logs are written to the container's writable layer. This can cause problems if there is a filesystem quota applied to the container. Typically Docker containers write all logs directly to stdout/stderr to be captured by external log drivers, so this behavior is unexpected.

Using an incorrect PGP key for the 81 image

Using the following Dockerfile:

FROM wyveo/nginx-php-fpm:php81

RUN apt-get update

Results in an error:

#5 6.126 Err:4 https://packages.sury.org/php bullseye InRelease
#5 6.126   The following signatures were invalid: EXPKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key <[email protected]>
#5 7.472 Get:9 http://nginx.org/packages/mainline/debian bullseye/nginx amd64 Packages [37.0 kB]
#5 10.58 Reading package lists...
#5 12.86 W: GPG error: https://packages.sury.org/php bullseye InRelease: The following signatures were invalid: EXPKEYSIG B188E2B695BD4743 DEB.SURY.ORG Automatic Signing Key <[email protected]>
#5 12.86 E: The repository 'https://packages.sury.org/php bullseye InRelease' is not signed.

Adjusting the Dockerfile to be:

FROM wyveo/nginx-php-fpm:php81

RUN apt-key del 95BD4743
RUN wget -q -O - https://packages.sury.org/php/apt.gpg | apt-key add -

RUN apt-get update

Lets this pass, aside from the apt-key deprecation warnings - I'm sure there's a better way to fix this upstream. This is as much for anyone finding the issue as it is in anticipation of a fix.

index.php

I've run container, before this I updated index.php file. but still see default page with "Congratulations..."
Why this file hasn't updated inside container

in dockerfile I see
COPY html /usr/share/nginx/html

Thanks

php7.0-mcrypt missing?

It looks like php7.0-mcrypt is missing from the recent changes to php70 branch. Was it intentional?

php.ini changes done aren't reflected

Even though the php file is set as php_conf=/etc/php/7.4/fpm/php.ini the loaded configuration file is as follows
php -i | grep 'Loaded Configuration File' Loaded Configuration File => /etc/php/7.4/cli/php.ini

how can we fix this?

GPG keyserver receive failed: Connection timed out (Ubuntu)

I'm unable to install on new Ubuntu servers.

The error reported that:
# gpg: keyserver receive failed: No name
# + echo Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from hkp://keyserver.ubuntu.com:80
# + apt-key adv --batch --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
# Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from hkp://keyserver.ubuntu.com:80
# Warning: apt-key output should not be parsed (stdout is not a terminal)
# Executing: /tmp/apt-key-gpghome.p27TNrX1j6/gpg.1.sh --batch --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62

I have tried changing my dns, or like changing hkp://keyserver.ubuntu.com:80 to http-proxy=https://keyserver.ubuntu.com but all attempts are futile.

Can you help me fix this problem?

Make a docker tag for php 7.2

Please make a Docker tag for php72. This allows me to lock in my team to a specific version of extensions, nginx etc. Otherwise the dev who just joined the project ends up with a different php config from the dev who hasn't rebuilt his image in the past 4 months.

Getting 404 after startup

Hey,

This is great, just can't seem to get around this issue. After running sudo compose-build up and opening my localhost, I get this error:

web_1      | 2017/04/13 00:16:55 [crit] 18#18: *1 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.17.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "127.0.0.1"
web_1      | 2017/04/13 00:16:55 [error] 18#18: *1 open() "/usr/share/nginx/html/50x.html" failed (2: No such file or directory), client: 172.17.0.1, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock", host: "127.0.0.1"
web_1      | 172.17.0.1 - - [13/Apr/2017:00:16:55 +0000] "GET / HTTP/1.1" 404 564 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"

Any ideas what might be going on?

Composer upgrade on PHP 7.x images

Hi there,

I would like to ask if there is any particular reason for which Composer is locked to version 1 on PHP 7.x images.
I am going to fork the repository to upgrade those for personal use, would like to know as I can PR easily.

Thanks,
David.

Support for apple silicon linux/arm64/v8 platform

Running on Apple Silicon chip, observed error/warning : The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

container status Exited (255)

Thanks.

Dockerfile ADD statement

nginx-php-fpm/Dockerfile

Lines 106 to 109 in d10d5bf

ADD ./supervisord.conf /etc/supervisord.conf
# Override nginx's default config
ADD ./default.conf /etc/nginx/conf.d/default.conf

Since this is not currently used for tar extraction nor URLs, shouldn't we use COPY instead of ADD? According to the best practices in the Docker official documentation:

Although ADD and COPY are functionally similar, generally speaking, COPY is preferred. That’s because it’s more transparent than ADD. COPY only supports the basic copying of local files into the container, while ADD has some features (like local-only tar extraction and remote URL support) that are not immediately obvious. Consequently, the best use for ADD is local tar file auto-extraction into the image, as in ADD rootfs.tar.xz /.

Share your thoughts on this, I can open PRs if it sounds good to you.

Cheers

Web Server Root Path

First I'd like to pay a compliment to the very well put together Docker base image you've created. Nicely done, and thank you.

Regarding /usr/share/nginx/html, as the web root directory, though this may sound very pedantic, I wanted to point out a bit of history informing the choice of web root paths, which are typically /var/www in most Linux distributions, including Debian. In contrast, this project uses /usr/share/nginx/html, the Nginx package's installed location for default HTML files.

In the 1994 Filesystem Hierarchy Standard[0] (The "standard guidelines for file and directory placement under UNIX-like operating systems"), it's noted that:

/var contains variable data files [...] /var is specified here in order to make it possible to mount /usr read-only. Everything that once went into /usr that is written to during system operation (as opposed to installation and software maintenance) must be in /var.

However, note that Nginx does correctly use /usr/share as the location to place it's "read-only" package installed data/sample files.[1]

Any program or package which contains or requires data that doesn't need to be modified should store that data in /usr/share. [...] It is recommended that a subdirectory be used in /usr/share for this purpose.

The FHS Standard makes this example for games:

Game data stored in /usr/share/games must be purely static data. Any modifiable files, such as score files, game play logs, and so forth, should be placed in /var/games.

An insightful discussion can be found on StackOverflow[2].

[0] https://www.pathname.com/fhs/pub/fhs-2.3.html#PURPOSE31
[1] https://www.pathname.com/fhs/pub/fhs-2.3.html#USRSHAREARCHITECTUREINDEPENDENTDATA
[2] https://unix.stackexchange.com/questions/47436/why-is-the-root-directory-on-a-web-server-put-by-default-in-var-www

Fails when run in OpenShift

Running the image plain as such in OpenShift results in this error

sed: couldn't open temporary file /etc/nginx/sednQggFi: Permission denied
--
  | Error: Can't drop privilege as nonroot user
  | For help, use /usr/local/bin/supervisord -h

It makes sense as it is against the standard guidelines that a container when run should not require root privileges. https://opensource.com/article/18/3/just-say-no-root-containers

Happy to spend some time fixing it, if anybody advises on how to go about it.

How to build dockerfile with php71 ?

I clone your source and build
# docker build -t nginx-php-fpm:php71 .

I can't found php7.1 but i found php 8.0 in default.conf

how can i solve this problem.

Getting 500 after startup with Laravel

I used these command with nomal index.php It's ok.
When i deployed laravel i got error 500. Help me please

docker pull wyveo/nginx-php-fpm
docker run --name ams -p 8001:80  -v /var/www/html/nginx-php/ams-v2/public:/usr/share/nginx/html wyveo/nginx-php-fpm:latest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.