Probleme, mit Docker/Nginx Localhost zu erreichenPhp

PHP-Programmierer chatten hier
Anonymous
 Probleme, mit Docker/Nginx Localhost zu erreichen

Post by Anonymous »

Ich versuche, eine lokale Entwicklerumgebung mit Docker und Nginx einzurichten. Ich bin neu in beiden. Ich habe ein Verzeichnis mit den Konfigurationsdateien (Docker-Compose, Nginx.conf und Dockerfile sowie ein Unterabweis mit PHP-INI-Dateien) und ein Projektverzeichnis. In dem Projektverzeichnis habe ich jeweils ein paar Unterverzeichnisse, die ein eigenes kleines Projekt sind. Wenn ich versuche, sie im Browser (d. H. Localhost/Tests/Test.php) zu besuchen, arbeiten sie. Das Problem ist, dass eines dieser Verzeichnisse eine WordPress -Site ist. Wenn ich versuche, das im Browser zu besuchen, funktioniert es manchmal und manchmal erhalte ich "Diese Seite kann nicht erreicht werden.



< /> Ich kann nicht herausfinden, warum es manchmal funktioniert und manchmal nicht. Ich kann nichts darüber in den Docker -Protokollen finden. Wenn es nicht funktioniert, scheint es nicht einmal die Anfrage an die URL zu registrieren, soweit ich das beurteilen kann. < /p>

Code: Select all

services:
php:
build: .
container_name: php
restart: always
volumes:
- ./projects:/var/www/html/projects
- ./php:/usr/local/etc/php/conf.d

db:
image: mariadb:latest
container_name: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: ***
MYSQL_DATABASE: brightleaf
MYSQL_USER: ***
MYSQL_PASSWORD: ***
volumes:
- db_data:/var/lib/mysql

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
restart: always
depends_on:
- db
ports:
- "8080:80"
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: ****
UPLOAD_LIMIT: 200M

nginx:
image: nginx:latest
container_name: nginx
restart: always
depends_on:
- php
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./projects:/var/www/html/projects
ports:
- "80:80"

volumes:
db_data:
< /code>
und die nginx.conf wie folgt:
< /p>
worker_processes auto;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
client_header_timeout 600s;
client_body_timeout 600s;
send_timeout 600s;
fastcgi_read_timeout 600s;

server {
listen 80;
server_name localhost;

# Root directory for all projects
root /var/www/html/projects;

# Single location block for all projects
location / {
# Serve files from the correct subdirectory
index index.php index.html;

# Try to serve the requested file, fallback to brightleaf or 404
try_files $uri $uri/ /brightleaf/index.php?$args;

# Enable directory listing if no index file is found
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}

error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log;
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post