我认为这是一个简单的项目 - 但似乎让我的网站进入Docker比我预想的更复杂!有一些症状 - 但我怀疑它可能归结为一个问题 - php配置。
哦 - 还有一个问题。我一直在寻找正确的魔法咒语,但我的黑客攻击一直是最小的音符(但我一直在进行定期备份)。
最初的问题是网站可以使用html加载 - 但是尝试加载php文件只会导致下载php文件。
我修复了这个问题只是为了在尝试加载php文件时遇到白屏死机(这是我备份的配置之一!)。可悲的是,这个成功'还带来了任何试图加载网站而不附加' index.html'导致错误 -
rewrite or internal redirection cycle while internally redirecting to "////////////"
我在试图解决问题时更多地摆弄 - 现在每当我尝试加载网站时,我都会遇到 500内部服务器错误。曾经希望你没有开始做什么吗?
可悲的是(奇怪的是)即使在恢复所有原始配置后,错误仍然存在。如果有人有任何狡猾的想法来解决这个烂摊子,我很乐意听到他们!
搬运工-compose.yml
web:
image: nginx:latest
ports:
- '80:80'
- '443:443'
links:
- phpfpm
volumes:
- ./logs:/var/log/nginx
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/fastcgi.conf:/etc/nginx/fastcgi.conf
- ./nginx/sites-available:/etc/nginx/sites-available
- ./nginx/sites-enabled:/etc/nginx/sites-enabled
- ./public:/var/www
phpfpm:
image: 'bitnami/php-fpm'
ports:
- '9000:9000'
volumes:
- ./public:/var/www
working_dir: /var/www
mysql:
image: 'mariadb'
ports:
- '3306:3306'
volumes:
- ./db-data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=notgivingoutmypassword
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10 10;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 4096k;
client_header_timeout 10;
client_body_timeout 10;
send_timeout 10;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied any;
# gzip_comp_level 6;
gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
mywebsite.conf (在sites_available中)
upstream php {
server phpfpm:9000;
}
server {
server_name www.mywebsite.com;
server_tokens off;
error_log "/var/log/nginx/mywebsite-error.log";
access_log "/var/log/nginx/mywebsite-access.log";
location / {
root /var/www/mywebsite/htdocs;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
fastcgi_index index.php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
fastcgi.conf
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
PHP-fpm.conf
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
; All relative paths in this configuration file are relative to PHP's install
; prefix (/opt/bitnami/php). This prefix can be dynamically changed by using the
; '-p' argument from the command line.
;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;
[global]
; Pid file
; Note: the default prefix is /opt/bitnami/php/var
; Default Value: none
;pid = run/php-fpm.pid
; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /opt/bitnami/php/var
; Default Value: log/php-fpm.log
error_log = /opt/bitnami/php/logs/php-fpm.log
; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon
; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm
; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = warning
; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0
; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0
; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0
; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128
; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless specified otherwise
; Default Value: no set
; process.priority = -19
; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes
; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024
; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll
; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10
;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;
; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)
; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /opt/bitnami/php otherwise
include=/opt/bitnami/php/etc/php-fpm.d/*.conf
错误文件包含以下问题:
error.log中
2018/02/08 15:46:38 [emerg] 1#1: upstream "php" may not have port 9000 in /etc/nginx/sites-enabled/mywebsite.conf:24
2018/02/08 16:47:02 [emerg] 1#1: upstream "php" may not have port 9000 in /etc/nginx/sites-enabled/mywebsite.conf:24
(我已经检查了php配置 - 它被配置为侦听端口9000.正如您从yml中看到的那样,似乎也正确配置了)
每次连接尝试都已正确记录在 mywebsite-access.log 中,因此我不打算在此逐字粘贴。
mywebsite-error.log中
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs//" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs///" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs//////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs///////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs////////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/////////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs//////////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs///////////" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:03:06 [error] 5#5: *4 rewrite or internal redirection cycle while internally redirecting to "////////////", client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:50 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:50 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:53 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:53 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:55 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:55 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:56 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:56 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:58 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:39:58 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:43 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:43 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:43 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:43 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:47 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:47 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET / HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:47 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:47 [crit] 5#5: *4 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:48 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:48 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/index.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /index.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:55 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/indejx.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /indejx.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:55 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/indejx.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /indejx.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:57 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/indejx.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /indejx.html HTTP/1.1", host: "www.mywebsite.com"
2018/02/08 17:41:57 [crit] 5#5: *1 stat() "/var/www/mywebsite/htdocs/indejx.html" failed (13: Permission denied), client: 88.202.149.194, server: www.mywebsite.com, request: "GET /indejx.html HTTP/1.1", host: "www.mywebsite.com"
权限被拒绝错误看起来很有希望 - 但该站点的目录(和所有子目录)的权限是:
drwxrwxr-- 4 www-data www-data 4096 Feb 8 14:58 .
drwxrwxr-x 13 headbanger headbanger 4096 Feb 8 16:54 ..
drwxrwxr-- 2 www-data www-data 4096 Feb 8 14:58 default
drwxrwxr-- 3 www-data www-data 4096 Feb 8 14:58 mywebsite
一如既往,所有的帮助都感激不尽。这真是烤我的面条!