Sign inSign up

nicecollab/php8.2-apache-mysql

By nicecollab

•Updated over 2 years ago

A PHP 8.2 Apache Docker image with MySQL server, Node.js, and various PHP extensions.

Image
Developer tools
Web servers
2

2.4K

nicecollab/php8.2-apache-mysql repository overview

Docker Hub Repository Description:

PHP 8.2 Apache Docker Image with Integrated MySQL and Development Tools

This Docker image offers a comprehensive PHP development environment featuring Apache, PHP 8.2, and a variety of essential extensions and tools. It includes support for integrated MySQL, ImageMagick, MongoDB, Redis, Xdebug, and more. This image is optimized for developers seeking a robust setup for web development, providing Composer for dependency management and NVM with Node.js for JavaScript tooling.

Features:

  • PHP 8.2 with Apache
  • Extensions: gd, mysqli, pdo_mysql, zip, imagick, mongodb, redis, xdebug
  • Composer for PHP package management
  • NVM for Node.js version management, along with PM2 for process management
  • Apache modules enabled: rewrite, vhost_alias
  • Integrated MySQL server
  • Ready for development and production environments

Usage Instructions:

Docker

To use this image with Docker, you can pull it from Docker Hub and run it with the following command:

docker pull nicecollab/php8.2-apache-mysql
docker run -d -p 80:80 -v /path/to/your/code:/var/www/public nicecollab/php8.2-apache-mysql

Replace /path/to/your/code with the path to your PHP project. The -p 80:80 flag maps port 80 on the Docker container to port 80 on your host machine.

Docker Compose

For a more complex setup, you can use Docker Compose to manage the service along with other services as needed. Below is an example docker-compose.yml file:

version: '3.8'

services:
  web:
    image: nicecollab/php8.2-apache-mysql
    ports:
      - "80:80"
    volumes:
      - ./src:/var/www/public
    environment:
      MYSQL_ROOT_PASSWORD: yourpassword
      MYSQL_DATABASE: yourdatabase
      MYSQL_USER: youruser
      MYSQL_PASSWORD: yourpassword
    command: bash -c "service mysql start && apache2-foreground"

volumes:
  db_data:

To start the services, navigate to the directory containing the docker-compose.yml file and run:

docker-compose up -d

This command will start the web service, with your PHP application served from the src directory on your host machine. MySQL is included and configured within the same container, accessible using the specified environment variables for the root password, database name, user, and user password.

Using PM2 for Node.js Applications

PM2 is included in this image for managing Node.js processes. You can use PM2 to start, stop, and monitor your Node.js applications within the Docker container. Here's how to use PM2 in your setup:

  1. Starting a Node.js Application with PM2

    To start your Node.js application using PM2, first ensure your application is inside the Docker container. Then, use the following command:

    docker exec -it <container_name> pm2 start /path/to/your/app.js --name "your-app-name"
    

    Replace <container_name> with the name or ID of your running container, /path/to/your/app.js with the path to your Node.js application inside the container, and "your-app-name" with a descriptive name for your app.

  2. Viewing Application Status

    You can check the status of your application using:

    docker exec -it <container_name> pm2 status
    

    This will show the status of all applications managed by PM2 within the container.

  3. Stopping and Restarting Applications

    To stop an application:

    docker exec -it <container_name> pm2 stop your-app-name
    

    To restart:

    docker exec -it <container_name> pm2 restart your-app-name
    

    You can replace your-app-name with the name you assigned when starting the application with PM2.

  4. Persisting PM2 Process List Across Container Restarts

    To save the current list of processes managed by PM2 and restore them automatically on container start, use:

    docker exec -it <container_name> pm2 save
    

    Ensure PM2's process list is restored on container restart by adding the following command to your Docker container's entrypoint or startup script:

    pm2 resurrect
    

This setup provides a full-featured PHP and Node.js development environment, ready for use in both local development and production deployment.

Tag summary

Content type

Image

Digest

sha256:c1fa5b120…

Size

438.6 MB

Last updated

over 2 years ago

docker pull nicecollab/php8.2-apache-mysql