В настоящее время я хочу запустить несколько сайтов WordPress с несколькими доменами в 1 VPS.Я надеюсь, что смогу разделить каждый wordpress в отдельных подпапках.
Я пробовал разными способами, но всегда получаю ошибку 404 при первом посещении программы установки wordpress.
Вот моя ошибкавойти в nginx error.log
*6 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.63.1, server: site1.com, request: "GET / HTTP/1.0", upstream: "fastcgi://172.21.0.4:9000", host: "192.168.63.130"
Может кто-нибудь объяснить мне, что я делаю не так?Спасибо!
docker-compose.yml
version: '3.6'
services:
nginx:
image: nginx:1.15.7-alpine
container_name: nginx
ports:
- '80:80'
- '443:443'
volumes:
- ./nginx:/etc/nginx
- ./logs/nginx:/var/log/nginx
- ./wordpress:/var/www/html
- ./certs:/etc/letsencrypt
- ./certs-data:/data/letsencrypt
links:
- site1
- site2
restart: always
mysql:
image: mariadb
container_name: mysql
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=password
restart: always
site1:
image: wordpress:php7.2-fpm-alpine
container_name: site1
volumes:
- ./wordpress/site1:/var/www/html/
- ./php/conf.d/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
environment:
- WORDPRESS_DB_NAME=site1
- WORDPRESS_TABLE_PREFIX=wp_
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_PASSWORD=password
links:
- mysql
restart: always
site2:
image: wordpress:php7.2-fpm-alpine
container_name: site2
volumes:
- ./wordpress/site2:/var/www/html/
- ./php/conf.d/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
environment:
- WORDPRESS_DB_NAME=site2
- WORDPRESS_TABLE_PREFIX=wp_
- WORDPRESS_DB_HOST=mysql
- WORDPRESS_DB_PASSWORD=password
links:
- mysql
restart: always
/ nginx / sites-enabled / site1 (site2 - то же самое с заменой site1
на site2
fastcgi_cache_path /var/cache/nginx/site1 levels=1:2 keys_zone=site1:100m inactive=60m;
server {
# Ports to listen on
listen 80;
listen [::]:80;
# Server name to listen for
server_name site1.com;
# Path to document root
root /var/www/html/site1;
# File to be used as index
index index.php;
# Overrides logs defined in nginx.conf, allows per site logs.
access_log /var/log/nginx/site1.access.log;
error_log /var/log/nginx/site1.error.log crit;
# Default server block rules
include global/server/defaults.conf;
# Fastcgi cache rules
include global/server/fastcgi-cache.conf;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include global/fastcgi-params.conf;
fastcgi_pass site1:9000;
# Skip cache based on rules in global/server/fastcgi-cache.conf.
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
# Define memory zone for caching. Should match key_zone in fastcgi_cache_path above.
fastcgi_cache site1;
# Define caching time.
fastcgi_cache_valid 60m;
}
# Rewrite robots.txt
rewrite ^/robots.txt$ /index.php last;
# Uncomment if using the fastcgi_cache_purge module and Nginx Helper plugin (https://wordpress.org/plugins/nginx-helper/)
# location ~ /purge(/.*) {
# fastcgi_cache_purge fastcgi-cache.com "$scheme$request_method$host$1";
# }
}
# Redirect www to non-www
server {
listen 80;
listen [::]:80;
server_name www.site1.com;
return 301 $scheme://site1.com$request_uri;
}