如何解决在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。 它奏效了。回答我所做的步骤,可能对其有同样问题的其他人有所帮助
-
Directus 文档中有一些 configs for NGINEX,请仔细阅读
-
在
nginex.conf
文件夹下创建.platform/nginx
文件
- 我们将替换 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;
}
}
- 完成后,当我们上传它时,beanstalk 会自动将我们自定义的
nginex.conf
替换为现有的nginex.conf
。 (注意:我们只能添加更改而不是替换,但在我尝试时它不起作用)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。