我一直在尝试在Elasticbeanstalk服务器上部署我的Laravel项目,我不断收到此错误:
前端错误:
您无权访问此服务器上的内容。
日志文件出错:
无法提供目录/ var / www / html / public /:无匹配 发现DirectoryIndex(index.html,index.php)和服务器生成的
Options指令禁止的目录索引
我将根目录中的.htaccess和index.php放在公共文件夹中。
的.htaccess
* * * * *
.ebextensions / 01-main.config
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
.ebextensions / 02-project.config
container_commands:
01-optimize:
command: "/usr/bin/composer.phar dump-autoload --optimize"
02-migrations:
command: "php artisan migrate --env=production"
03-cache:
command: "php artisan cache:clear"
cwd: "/var/app/ondeck"
04-optimize:
command: "php artisan optimize --force"
cwd: "/var/app/ondeck"
05-permissions:
command: "chmod 777 -R /var/app/ondeck"
cwd: "/var/app/ondeck"
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99_make_storage_writable.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
echo "Making /storage writeable..."
chmod -R 777 /var/app/current/storage
if [ ! -f /var/app/current/storage/logs/laravel.log ]; then
echo "Creating /storage/logs/laravel.log..."
touch /var/app/current/storage/logs/laravel.log
chown webapp:webapp /var/app/current/storage/logs/laravel.log
fi
if [ ! -d /var/app/current/public/storage ]; then
echo "Creating /public/storage symlink..."
ln -s /var/app/current/storage/app/public /var/app/current/public/storage
fi
"/opt/elasticbeanstalk/tasks/publishlogs.d/laravel-logs.conf":
mode: "000755"
owner: root
group: root
content: |
/var/app/current/storage/logs/*.log
"/etc/httpd/conf.d/https_redirect.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=307,L]
任何帮助将不胜感激。
由于
答案 0 :(得分:1)
你做到了吗?
打开Elastic Beanstalk控制台。
导航至您所在环境的管理页面。
选择配置。
在软件配置卡上,选择修改。
对于文档根目录,请键入 / public 。
应用配置
参考:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/php-laravel-tutorial.html
答案 1 :(得分:0)
您必须使用chmod设置为公共文件夹的权限为755
答案 2 :(得分:0)
这意味着您的服务器配置文件未正确创建。
默认配置文件root是“/ var / www / html / public /”,但是在你的服务器中没有这样的目录。
您需要执行以下操作。(尊重Apache服务器)
/etc/apache2/site-available/default.conf
)并更改laravel公用文件夹的路径sudo a2dissite default.conf
目录中的/etc/apache2/site-available
)并创建您自己的配置文件并启用它(sudo a2ensite laravel.conf
)。sudo chmod -R 0777 /storage
和sudo chmod -R 0777 /public