在Elastic Beanstalk上进行Directus部署

问题描述

我从github克隆了Directus 8。我在本地服务器上运行它。它工作正常,没有任何问题。

然后,我将代码上传到AWS Elastic Beanstalk(PHP,Apache)。但显示500内部服务器错误

错误日志:struct ContentView_Previews: PreviewProvider { Group { NavigationView { ContentView() .environment(\.colorScheme,.light) } NavigationView { ContentView() .environment(\.colorScheme,.light) } } }

我将/var/www/html/directus/public/.htaccess: <IfModule not allowed here文件添加到了我的根文件夹中,例如this

.ebextensions/setup.config

但是我的Beanstalk说files: "/etc/httpd/conf.d/enable_mod_rewrite.conf": mode: "644" owner: root group: root content: | AllowOverride All 并进入了降解状态。

该如何解决

解决方法

此答案适用于 Directus 8 (PHP)

使用 .ebextensions 和 .platform 尝试了几乎所有的 apache 设置方式,但没有任何效果。

然后尝试使用自定义 .platform 配置的 NGINX它奏效了。回答我所做的步骤,可能对其有同样问题的其他人有所帮助


  1. Directus 文档中有一些 configs for NGINEX,请仔细阅读

  2. nginex.conf文件夹下创建.platform/nginx文件

platform/nginx

  1. 我们将替换 beantalk 中现有的 nginex.conf。使用 ssh 将现有的 nginex.conf 复制到 ec2 实例并添加文档中提到的自定义配置并将其粘贴到我们新创建的 .platform/nginx/nginex.conf

下面是我的自定义 .platform/nginx/nginex.conf

user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    32136;    
events {
    worker_connections  1024;
}    
http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include       conf.d/*.conf;

    map $http_upgrade $connection_upgrade {
        default     "upgrade";
    }

    server {
        listen 80 default_server;

        location / {
            try_files $uri $uri/ /index.php?$args;
        }

        location /admin {
            try_files $uri $uri/ /admin/index.html?$args;
        }

        location /thumbnail {
            try_files $uri $uri/ /thumbnail/index.php?$args;
        }

        # Deny direct access to php files in extensions
        location /extensions/.+\.php$ {
            deny all;
        }
        
        # All uploads files (originals) cached for a year
        location ~* /uploads/([^/]+)/originals/(.*) {
            add_header Cache-Control "max-age=31536000";
        }

        # Serve php,html and cgi files as text file
        location ~* /uploads/.*\.(php|phps|php5|htm|shtml|xhtml|cgi.+)?$ {
            add_header Content-Type text/plain;
        }

        # Deny access to any file starting with .ht,# including .htaccess and .htpasswd
        location ~ /\.ht {
            deny all;
        }

        # pass PHP scripts to FastCGI server
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php-fpm/www.sock;
            fastcgi_index  index.php;
            include /etc/nginx/fastcgi.conf;                
        }        

        access_log    /var/log/nginx/access.log main;

        # Include the Elastic Beanstalk generated locations
        include conf.d/elasticbeanstalk/*.conf;
    }
}
  1. 完成后,当我们上传它时,beanstalk 会自动将我们自定义的 nginex.conf 替换为现有的 nginex.conf。 (注意:我们只能添加更改而不是替换,但在我尝试时它不起作用)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...