【发布时间】:2021-06-03 15:35:32
【问题描述】:
我正在尝试将 worker_processes 添加到我的 docker 环境中的 nginx.conf 文件中,但是每当我尝试时,它都无法重新启动或加载。我相信我在这里遗漏了一些关键概念——无论如何:
这是我的 nginx.conf 文件(一切正常):
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/src;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/wp-json/ {
rewrite ^/wp-json/(.*?)$ /?rest_route=/$1 last;
}
}
我尝试在服务器方括号下方添加以下内容,但这会导致 nginx 无法加载。 enginx 的错误是: "worker_processes" 指令在 /etc/nginx/conf.d/nginx.conf:1 中是不允许的 :
worker_processes: 8;
server {
listen 80;
index index.php index.html;
etc. etc. etc.
这是我的文件夹结构:
这是我目前的 Dockerfile:
FROM php:7.4.15-fpm
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
zip \
unzip
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install mysqli pdo_mysql mbstring exif pcntl bcmath g
# Set working directory
WORKDIR /var/www
USER $user
【问题讨论】:
-
只是一个旁注:而不是
apt-get install和docker-php-ext-install使用github.com/mlocati/docker-php-extension-installer 怎么样?
标签: php docker nginx configuration