Docker上的Wordpress无法加载正确的页面:Nginx在404和/$uri/index.php之后发送301错误(没有此类文件或目录)

时间:2018-11-05 22:04:15

标签: php wordpress docker nginx docker-compose

此处的任务是将生产迁移到Docker上的开发环境。到目前为止,我已经在独立的容器上运行PHP和Nginx,因为我们需要为所有不同的网站使用许多不同的容器,但必须使用相同的nginx图像。

我已经加载了主页,但是从外观上看,WordPress并不是通过自定义URI来加载其页面,而是尝试将URI用作实际的子目录,然后加载{{1 }}。

我已经将她的index.phpnginx.confdocker-compose.yml输出包括在内。

将工作正常的WordPress网站从Prod迁移到Docker时,只会加载初始页面。

当我导航到/var/log/nginx/error.log时,确实收到了正确的响应:首页。

当我单击任何子链接或键入URL时:local.www.website.com local.www.website.com拒绝连接。`

使用curl时:http://local.www.website.com:8080/khat/, I receive an error in the browser:得到301。

当我检查Nginx错误日志(/ var / log / nginx / errors.log`时,我得到:

curl -v http://local.www.greenhousetreatment.com:8080/khat/

我的2018/11/05 21:37:33 [error] 187#187: *45 "/var/www/website.com/current/html/khat/index.php" is not found (2: No such file or directory), client: 172.26.0.1, server: local.www.website.com, request: "GET /khat/ HTTP/1.1", host: "local.www.website.com:8080" nginx文件如下:

website.conf

我的nginx容器暴露在端口“ 8080:80”上,而我的php-fpm暴露在“ 9000:9000”上

这是我的 server { server_name local.www.website.com; root /var/www/website.com/current/html; index index.php; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log warn; location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } location / { try_files $uri $uri/ /index.php?$args; } error_page 404 = /index.php?$args; # include /var/www/website.com/current/app/conf/nginx/redirects.conf; location ^~ /wp-content/uploads/ { proxy_pass https://s3-us-west-2.amazonaws.com/website.com/uploads/; } location ~* ^/listings/(.*[^/])$ { return 301 /listings/$1/; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 30d; access_log off; add_header Cache-Control "public"; } location ~ \.php$ { include fastcgi_params; fastcgi_pass php:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REMOTE_ADDR $http_x_forwarded_for; fastcgi_param DEFAULT_REMOTE_ADDR $remote_addr; fastcgi_param APP_ENV "prof"; fastcgi_param APP_WP_DB_NAME "website.com"; fastcgi_param APP_WP_DB_USER "root"; fastcgi_param APP_WP_DB_PASSWORD '1234'; fastcgi_param APP_WP_DB_HOST "mysql:3306"; fastcgi_param APP_WP_S3_UPLOADS_BUCKET "website.com"; fastcgi_param APP_WP_S3_UPLOADS_KEY "1234"; fastcgi_param APP_WP_S3_UPLOADS_SECRET '123/123/+123'; fastcgi_param APP_WP_S3_UPLOADS_REGION "us-west-2"; } }

docker-compose.yml

我想念什么?我尝试将docker-compose中的公开端口更改为version: "3" services: web: image: nginx:latest container_name: ght-nginx ports: - "8080:80" volumes: - ./website.com/current:/var/www/website.com/current - ./etc/nginx/sites-available/ght-nginx.conf:/etc/nginx/conf.d/site.conf - ./website.com/shared/logs/:/var/log/nginx/ - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf links: - php php: image: php7.0-fpm-aac container_name: ght volumes: - ./website.com/current:/var/www/website.com/current - ./website.com/shared/logs/:/var/log/nginx/ - ./sites/php/sites.conf:/etc/php/7.0/fpm/pool.d/php-fpm.conf ports: - "9000:9000" mysql: image: mysql:5.7 container_name: ght-mysql ports: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: 1234 volumes: - ./mysql/library/:/var/lib/mysql - ./mysql/dumps/:/tmp/mysql/dumps ,尝试添加和删除

9000:80

我尝试将以下代码块添加到location / { try_files $uri $uri/ /index.php?$args; }

的底部
wp-config.php

我不确定还需要做什么。任何帮助将不胜感激。

0 个答案:

没有答案