Elastic Beanstalk 上的 Directus 部署
Directus deployment on Elastic Beanstalk
我从 github 克隆了 Directus 8。我 运行 它在我的本地服务器中。它运行良好,没有任何问题。
然后我将代码上传到 AWS Elastic Beanstalk (PHP, apache)。但它显示 500 Internal Server Error。
错误日志:/var/www/html/directus/public/.htaccess: <IfModule not allowed here
我将 .ebextensions/setup.config
文件添加到我的根文件夹,例如 this。
files:
"/etc/httpd/conf.d/enable_mod_rewrite.conf":
mode: "644"
owner: root
group: root
content: |
AllowOverride All
但是我的 Beanstalk 说 Unsuccessful command execution on instance id(s) 'i-0f6...'. Aborting the operation.
并进入了 degrading 状态。
如何解决这个问题?
此答案适用于 Directus 8 (PHP)
使用 .ebextensions 和 .platform 尝试了几乎所有的 apache 设置方法都没有用。
然后使用自定义 .platform 配置尝试 NGINX。 有效。回答我所做的步骤,可能对遇到同样问题的其他人有所帮助
Directus 文档有一些 configs for NGINEX,仔细阅读
在 .platform/nginx
文件夹下创建 nginex.conf
文件
- 我们将替换 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
。 (注意:我们可以只添加更改而不是替换,但在我尝试时它不起作用)
我从 github 克隆了 Directus 8。我 运行 它在我的本地服务器中。它运行良好,没有任何问题。
然后我将代码上传到 AWS Elastic Beanstalk (PHP, apache)。但它显示 500 Internal Server Error。
错误日志:/var/www/html/directus/public/.htaccess: <IfModule not allowed here
我将 .ebextensions/setup.config
文件添加到我的根文件夹,例如 this。
files:
"/etc/httpd/conf.d/enable_mod_rewrite.conf":
mode: "644"
owner: root
group: root
content: |
AllowOverride All
但是我的 Beanstalk 说 Unsuccessful command execution on instance id(s) 'i-0f6...'. Aborting the operation.
并进入了 degrading 状态。
如何解决这个问题?
此答案适用于 Directus 8 (PHP)
使用 .ebextensions 和 .platform 尝试了几乎所有的 apache 设置方法都没有用。
然后使用自定义 .platform 配置尝试 NGINX。 有效。回答我所做的步骤,可能对遇到同样问题的其他人有所帮助
Directus 文档有一些 configs for NGINEX,仔细阅读
在
.platform/nginx
文件夹下创建nginex.conf
文件
- 我们将替换 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
。 (注意:我们可以只添加更改而不是替换,但在我尝试时它不起作用)