PHP -Erweiterungen werden bei Verwendung von Docker [Duplicate] nicht korrekt installiert.Php

PHP-Programmierer chatten hier
Anonymous
 PHP -Erweiterungen werden bei Verwendung von Docker [Duplicate] nicht korrekt installiert.

Post by Anonymous »

Dies ist mein erstes Mal, dass ich versuche, Docker zu verwenden. Ich versuche, ein PHP -Projekt einzurichten, das die MySQLI -PHP -Erweiterung verwendet, aber aus irgendeinem Grund ist es nicht installiert, wenn ich meinen Docker -Container erstelle. Ich habe Php -m jedes Mal, wenn ein Wiederaufbau eine Liste aller Erweiterungen angezeigt, und MySQLI noch nie in dieser Liste angezeigt.

Code: Select all

# Use the official PHP with Apache image
FROM php:8.1-apache

# Install mysqli extension
RUN docker-php-ext-install mysqli

# Enable mysqli extension
RUN docker-php-ext-enable mysqli

# Copy the source code and other necessary files into the container
COPY src/ /var/www/src/        # Copy the src folder to /var/www/src/
COPY public/ /var/www/html/     # Copy the public folder to /var/www/html (web server document root)/
COPY vendor/ /var/www/vendor/   # Copy the vendor folder to /var/www/vendor (Composer dependencies)/

# Set the proper permissions for Apache to access the files
RUN chown -R www-data:www-data /var/www/html /var/www/src /var/www/vendor \
&& chmod -R 755 /var/www/html /var/www/src /var/www/vendor

# Set the working directory
WORKDIR /var/www/html

# Expose port 80 for web traffic
EXPOSE 80
< /code>
docker-compose.yml:
version: '3.8'

services:
php-apache:
image: php:8.1-apache
container_name: wishlist-php-app
ports:
- "8082:80"  # Map container port 80 to local 8080
volumes:
- ./public:/var/www/html  # Maps your public folder to the container's document root
- ./src:/var/www/src      # If you have source code outside the public folder
- ./vendor:/var/www/vendor  # Map the vendor folder
environment:
- MYSQL_HOST=host.docker.internal  # Connects to MySQL on your local machine (if running outside Docker)
- MYSQL_PORT=3306

# Optional: Use existing phpMyAdmin instance
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
ports:
- "8083:80"  # Access phpMyAdmin at http://localhost:8081
environment:
PMA_HOST: host.docker.internal  # Connects to MySQL on local machine
MYSQL_ROOT_PASSWORD: root # Replace with your root password
depends_on:
- php-apache

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post