Giter Club home page Giter Club logo

apache-php-fpm-alpine's Introduction

project description

A super light docker web server with Apache and php-fpm on top of Alpine Linux for development purposes

  • Apache 2.4.48 with SSL
  • php-fpm 8.0.8 or 7.4.21
  • Xdebug 3.0.4 - debugger and profiler
  • SPX prolifer 0.4.10
  • composer 2.1.3
  • zsh 5.8

The docker image size is 58 MB.

Note: for the web server plus MariaDB, check https://github.com/8ctopus/php-sandbox

cool features

  • php 8 or 7
  • Apache and php configuration files are exposed on the host.
  • Just works with any domain name.
  • https is configured out of the box.
  • All changes to config files are automatically applied (hot reload).
  • Xdebug is configured for remote debugging (no headaches).

start container

Starting the container with docker-compose offers all functionalities.

# start container (php 8 by default)
docker-compose up

# CTRL-Z to detach

# stop container
docker-compose stop

Alternatively the container can also be started with docker run.

# php 8
docker run -p 80:80 -p 443:443 --name web 8ct8pus/apache-php-fpm-alpine:latest

# php 7.4
docker run -p 80:80 -p 443:443 --name web 8ct8pus/apache-php-fpm-alpine:1.1.3

CTRL-Z to detach

docker stop container

access website

http://localhost/
https://localhost/

The source code is located inside the html directory.

set website domain name

To set the domain name to www.test.com, edit the environment variable in the docker-compose file

environment:
  - DOMAIN=www.test.com

Add this line to the system host file. Editing the file requires administrator privileges.

C:\Windows\System32\drivers\etc\hosts

127.0.0.1 test.net www.test.net

add https

To remove "Your connection is not private" nag screens, import the certificate authority file under ssl/certificate_authority.pem in the browser's certificates under Trusted Root Certification Authorities.

guide: https://support.globalsign.com/digital-certificates/digital-certificate-installation/install-client-digital-certificate-windows-using-chrome

Xdebug debugger

This repository is configured to debug php code in Visual Studio Code. To start debugging, open the VSCode workspace then select Run > Start debugging then open the site in the browser.

For other IDEs, set the Xdebug debugging port to 9001.

To troubleshoot debugger issues, check the log\xdebug.log file.

If host.docker.internal does not resolve within the container, update the xdebug client host within etc\php\conf.d\xdebug.ini to the docker host ip address.

xdebug.client_host          = 192.168.65.2

Xdebug profiler

To start profiling, add the XDEBUG_PROFILE variable to the request as a GET, POST or COOKIE.

http://localhost/?XDEBUG_PROFILE

Profiles are stored in the log directory and can be analyzed with tools such as webgrind.

SPX profiler

To start profiling with SPX:

  • Access the SPX control panel
  • Check checkbox Whether to enable SPX profiler for your current browser session. No performance impact for other clients.
  • Run script to profile
  • Refresh the SPX control panel tab and the report will be available at the bottom of the screen. Click it to show the report in a new tab.

Note Disable Xdebug debugger xdebug.remote_enable for accurate measurements.

access container through command line

docker exec -it web zsh

build docker development image

docker build -t apache-php-fpm-alpine:dev .

extend docker image

In this example, we add the php-curl extension.

docker-compose up --detach
docker exec -it web zsh
apk add php-curl
exit
docker-compose stop
docker commit web apache-php-fpm-alpine-curl:dev

To use this image, update the reference in docker-compose.yml.

more info on php-fpm

https://php-fpm.org/about/

notes

In Windows hot reload doesn't work with WSL 2, you need to use the legacy Hyper-V.

apache-php-fpm-alpine's People

Contributors

8ctopus 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.