Giter VIP home page Giter VIP logo

docker-php-fpm-swrm's Introduction

geschke/php-fpm-swrm

This is a minimalistic php-fpm Docker image based on the official Ubuntu images.
The image provides different PHP versions as seen below.

Supported tags

  • 8.3-fpm-ubuntu22.04-sury-n - PHP 8.3 from deb.sury.org PPA based on Ubuntu 22.04 LTS
  • 8.2-fpm-ubuntu22.04-sury-n - PHP 8.2 from deb.sury.org PPA based on Ubuntu 22.04 LTS
  • 8.1-fpm-ubuntu22.04-sury-n - PHP 8.1 from deb.sury.org PPA based on Ubuntu 22.04 LTS
  • 8.1-fpm-n, latest - PHP 8.1 included in the current Ubuntu 22.04 LTS distribution. This is the main branch as known before.
  • 8.0-fpm-ubuntu22.04-sury-n - PHP 8.0 from deb.sury.org PPA based on Ubuntu 22.04 LTS
  • 7.4-fpm-ubuntu22.04-sury-n - PHP 7.4 from deb.sury.org PPA based on Ubuntu 22.04 LTS
  • 7.4-fpm-n - PHP 7.4 included in the Ubuntu 20.04 LTS distribution

n = build number, higher numbers are newer builds

Usage

To download the image run

docker pull geschke/php-fpm-swrm

This is a minimalistic approach to build a php-fpm environment. It doesn't need configuration (and there is currently no way to modify the options without inheriting the image). Additional it installs the Composer dependency manager.

This image is intended for running as PHP-FPM backend in a Docker swarm mode environment.

For sure it is possible to start the container with the legacy "docker run" command, as seen in the following example.

To start the container, just run a command like this:

docker run -d --name phpfpm -p 127.0.0.1:9000:9000 \
     --volume /path/to/your/files/on/host:/var/www/html \
     geschke/php-fpm-swrm

In the above example you will start a container named "phpfpm" which mounts the volume /path/to/your/files/on/host to the internal directory /var/www/html. The -p option opens the port 9000 on localhost, so any Proxy or web server can reach the php-fpm target. If you want to access from another server, i.e. outside the current machine, just use the -p option without limiting the host, e.g. -p 9000:9000. But beware if you expose the port like this - without a firewall your php-fpm installation is open to the world!

Usage example with Nginx

To use Nginx, set up a configuration like this:

[...|
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
    # Use the tcp connection
    fastcgi_pass 127.0.0.1:9000;
    # ...but not the socket
    #fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
}
[...]

The example is from a working configuration of Nginx Ubuntu package. If not set in the fastcgi.conf, maybe it's necessary to add the following options:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

These options are set as default in the fastcgi.conf file and could be changed in the location settings.

At last, you have to configure the document root settings. Let's explain by example. The PHP files on your host are installed in:

/vol/www/phpapp1

So the volume parameter when starting the container has to be:

-v /vol/www/phpapp1:/var/www/html

So inside the Docker container any of your PHP files could be reached within /var/www/html.

Then you have to configure the document root as:

root /var/www/html;

in your Nginx sites configuration file, e.g. /etc/nginx/sites-available/default.

You can change this behaviour if you modify the SCRIPT_FILENAME option in the Nginx fastcgi options.

Usage example with Docker swarm mode

Have a look at some blog articles at www.kuerbis.org (German only, please use Google Translate).

Credits

This image is based on the official Ubuntu image, the Ubuntu or deb.sury.org PHP packages and uses some configuration snippets of the official PHP Docker image. Thank you all!

docker-php-fpm-swrm's People

Watchers

 avatar  avatar

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.