From 0c0ef44420720d23f9c003d1fe8485c8165a503f Mon Sep 17 00:00:00 2001 From: tms Date: Mon, 25 Sep 2023 11:19:02 +0200 Subject: [PATCH] Added missing dependencies, fixed wrong NGINX rewrite --- omeka-s-docker/Dockerfile | 4 +- omeka-s-docker/config/database.ini | 5 +++ omeka-s-docker/config/nginx.conf | 72 ++++++++++++++---------------- omeka-s-docker/docker-compose.yaml | 6 ++- 4 files changed, 44 insertions(+), 43 deletions(-) create mode 100644 omeka-s-docker/config/database.ini diff --git a/omeka-s-docker/Dockerfile b/omeka-s-docker/Dockerfile index 6f240b0..7cd79eb 100644 --- a/omeka-s-docker/Dockerfile +++ b/omeka-s-docker/Dockerfile @@ -12,7 +12,7 @@ RUN apk --update add ca-certificates # Install packages RUN apk --no-cache add php82 php82-fpm php82-opcache php82-openssl php82-curl php82-pdo php82-pdo_mysql php82-session \ - nginx supervisor curl unzip + php82-mbstring php82-fileinfo php82-xml nginx supervisor curl unzip # https://github.com/codecasts/php-alpine/issues/21 #RUN ln -s /usr/bin/php7 /usr/bin/php @@ -38,7 +38,7 @@ RUN mkdir -p /var/www/html WORKDIR /tmp ADD https://github.com/omeka/omeka-s/releases/download/v4.0.4/omeka-s-4.0.4.zip /tmp RUN unzip omeka-s-4.0.4.zip -d /var/www/html/ && rm omeka-s-4.0.4.zip - +COPY config/database.ini /var/www/html/omeka-s/config/database.ini # Make sure files/folders needed by the processes are accessable when they run under the nobody user RUN chown -R nobody.nobody /var/www/html && \ chown -R nobody.nobody /run && \ diff --git a/omeka-s-docker/config/database.ini b/omeka-s-docker/config/database.ini new file mode 100644 index 0000000..2249e5b --- /dev/null +++ b/omeka-s-docker/config/database.ini @@ -0,0 +1,5 @@ +user = "omeka" +password = "uzu7ZoLaiGhiequi" +dbname = "omeka" +host = "127.0.0.1" +port = "3306" diff --git a/omeka-s-docker/config/nginx.conf b/omeka-s-docker/config/nginx.conf index 73bae9e..f572035 100644 --- a/omeka-s-docker/config/nginx.conf +++ b/omeka-s-docker/config/nginx.conf @@ -38,53 +38,47 @@ http { sendfile off; - root /var/www/html; - index index.php index.html; + root /var/www/html/omeka-s; + index index.php index.html index.htm; + rewrite ^/(.*)/$ /$1 permanent; + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location ~ \..*/.*\.php$ { + return 403; + } location / { - # First attempt to serve request as file, then - # as directory, then fall back to index.php - try_files $uri $uri/ /index.php?q=$uri&$args; + try_files $uri /index.php?$args; } - # Redirect server error pages to the static page /50x.html - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /var/lib/nginx/html; - } + # location /admin { + # try_files $uri /index.php?$args; + # } - # Pass the PHP scripts to PHP-FPM listening on 127.0.0.1:9000 location ~ \.php$ { - try_files $uri =404; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass unix:/run/php-fpm.sock; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_index index.php; - include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors on; + fastcgi_pass unix:/run/php-fpm.sock; } - location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { - expires 5d; - } - - # Deny access to . files, for security - location ~ /\. { - log_not_found off; - deny all; - } - - # Allow fpm ping and status from localhost - location ~ ^/(fpm-status|fpm-ping)$ { - access_log off; - allow 127.0.0.1; - deny all; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - fastcgi_pass unix:/run/php-fpm.sock; - } - } - + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } +} gzip on; gzip_proxied any; gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; diff --git a/omeka-s-docker/docker-compose.yaml b/omeka-s-docker/docker-compose.yaml index a3404f9..9327397 100644 --- a/omeka-s-docker/docker-compose.yaml +++ b/omeka-s-docker/docker-compose.yaml @@ -6,6 +6,8 @@ services: db: image: percona restart: always - # environment: - # MYSQL_ROOT_PASSWORD: example + env_file: + - sample.env + ports: + - 127.0.0.1:3306:3306