我有 nginx 文件,而不是 wordpress 页面。如何解决?

我是初学者,需要一些答案。

我有一个包含 nginx 文件的页面,而不是 wordpress 页面。如何解决?请帮助。

在图片中我的负面结果 - enter image description here

docker-compose.yaml

version: '3.7'

services:
    db:  
      image: mysql:8.0
      container_name: db
      restart: always
      networks:
        - app-network
      environment: 
        - MYSQL_ROOT_PASSWORD=Ruslan
        - MYSQL_ALLOW_EMPTY_PASSWORD=Ruslan
        - MYSQL_RANDOM_ROOT_PASSWORD=Ruslan
    wordpress:
      build: ./requirements/wordpress/
      depends_on: 
          - db
      container_name: wordpress
      restart: always
      networks:
        - app-network
    nginx:
      build: ./requirements/nginx/
      depends_on:
        - wordpress
      container_name: nginx
      restart: always
      ports:
          - 443:443
      networks:
          - app-network

这里我尝试搭建了 3 个服务 mysql、wordpress 和 nginx。

用于 nginx 的 dockerfile

FROM debian:buster

RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y nginx vim procps openssl net-tools php-gd php-xml
COPY ./nginx.conf /etc/nginx/sites-available/default
RUN mkdir -p /etc/ssl/private
RUN chmod 700 /etc/ssl/private
RUN openssl req -x509 -nodes -days 365 -subj "/C=RF/ST=London/L=London/O=innoaca/OU=student/CN=Ruslan" -newkey rsa:2048 -keyout /etc/ssl/nginx-selfsigned.key -out /etc/ssl/nginx-selfsigned.crt;
CMD ["nginx","-g","daemon off;"]

在 nginx 的 dockerfile 中,我刚刚安装了它。

nginx.conf

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name localhost;
    
    ssl on;

    ssl_certificate /etc/ssl/nginx-selfsigned.crt;
    ssl_certificate_key /etc/ssl/nginx-selfsigned.key;
    
    ssl_protocols TLSv1.3;
    autoindex on;
    root /var/www/html;
    index index.php;

    location / {
            try_files $uri $uri/ =405;
    }


    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass wordpress:9000;
    }
}

这里我尝试使用套接字,我需要 nginx 和 worpress 在 9000 端口上进行通信。

wordpress 的 dockerfile

FROM debian:buster

RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install vim wget php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl mariadb-server php7.3 php7.3-fpm

WORKDIR /var/www/html/
RUN wget https://wordpress.org/latest.tar.gz
RUN tar -xvzf latest.tar.gz
RUN rm -rf latest.tar.gz
COPY ./wp-config.php ./wordpress/
RUN chown -R www-data:www-data /var/www/html/wordpress
RUN chmod -R 755 /var/www/html/wordpress
RUN sed -i '36 s/\/run\/php\/php7.3-fpm.sock/9000/' /etc/php/7.3/fpm/pool.d/www.conf
RUN service php7.3-fpm start
CMD ["/usr/sbin/php-fpm7.3","-F"]

wp-config.php

<?php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME','wpdb' );

/** MySQL database username */
define( 'DB_USER','wpuser' );

/** MySQL database password */
define( 'DB_PASSWORD','dbpassword' );

/** MySQL hostname */
define( 'DB_HOST','localhost' );

*/
define( 'AUTH_KEY','put your unique phrase here' );
define( 'SECURE_AUTH_KEY','put your unique phrase here' );
define( 'LOGGED_IN_KEY','put your unique phrase here' );
define( 'NONCE_KEY','put your unique phrase here' );
define( 'AUTH_SALT','put your unique phrase here' );
define( 'SECURE_AUTH_SALT','put your unique phrase here' );
define( 'LOGGED_IN_SALT','put your unique phrase here' );
define( 'NONCE_SALT','put your unique phrase here' );

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers,letters,and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,* visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define( 'WP_DEBUG',false );

/* That's all,stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH',dirname( __FILE__ ) . '/' );
}

/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );
?>

wordpress 的配置是默认的。

有人知道,我该怎么办?我什么都试过了。

fleia 回答:我有 nginx 文件,而不是 wordpress 页面。如何解决?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/947.html

大家都在问