我在 AWS 上的自動縮放群組中擁有 Ubuntu 20.04 伺服器,並安裝了 EFS/mnt/efs/fs1
我使用 codedeploy 來部署非預設網站。 bitbucket 管線會建立一個包含網站配置和網站內容的 zip 檔案。 Codedeploy部署部分如下:
#extract content
unzip -o frontend-qa.zip
#copy site config
sudo mv /mnt/efs/fs1/sites-enabled/* /etc/apache2/sites-enabled/
#update permissions
sudo chown www-data:www-data -R /mnt/efs/fs1/www
sudo chmod 777 -R /mnt/efs/fs1/www
#reload apache
sudo systemctl reload apache2
/etc/apache2/apache2.conf
負責目錄和權限的部分
<Directory /mnt/efs/fs1/www>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
網站虛擬主機文件
<VirtualHost *:80>
ServerAdmin admin@the_site
ServerName the_site
ServerAlias www.the_site
DocumentRoot /mnt/efs/fs1/www/html/site_admin/public_html
# Directory path where code exists
<Directory /mnt/efs/fs1/www/html/site_admin/public_html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/the_site.site-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel error
CustomLog ${APACHE_LOG_DIR}/the_site.log combined
</VirtualHost>
網站根目錄的權限
ll /mnt/efs/fs1/www/html/site_admin/public_html/
total 2120
drwxrwxrwx 10 www-data www-data 6144 Nov 28 16:35 ./
drwxrwxrwx 3 www-data www-data 6144 Nov 16 13:31 ../
-rwxrwxrwx 1 www-data www-data 283 Nov 26 18:48 .gitignore*
-rwxrwxrwx 1 www-data www-data 13966 Nov 28 16:35 .htaccess*
-rwxrwxrwx 1 www-data www-data 305 Nov 26 18:48 .project*
-rwxrwxrwx 1 www-data www-data 23 Nov 26 18:48 HEAD*
-rwxrwxrwx 1 www-data www-data 343872 Nov 26 18:48 'Hi tea menu.pdf'*
drwxrwxrwx 15 www-data www-data 6144 Nov 5 23:39 application/
drwxrwxrwx 13 www-data www-data 6144 Nov 5 23:39 assets/
-rwxrwxrwx 1 www-data www-data 339 Nov 26 18:48 composer.json*
-rwxrwxrwx 1 www-data www-data 65865 Nov 26 18:48 composer.lock*
-rwxrwxrwx 1 www-data www-data 1640731 Nov 26 18:48 composer.phar*
-rwxrwxrwx 1 www-data www-data 66 Nov 26 18:48 config*
-rwxrwxrwx 1 www-data www-data 73 Nov 26 18:48 description*
-rwxrwxrwx 1 www-data www-data 66 Nov 26 18:48 desktop.ini*
-rwxrwxrwx 1 www-data www-data 0 Nov 26 18:48 error.log*
-rwxrwxrwx 1 www-data www-data 0 Nov 26 18:48 git*
drwxrwxrwx 2 www-data www-data 6144 Nov 5 23:39 hooks/
drwxrwxrwx 2 www-data www-data 14336 Nov 5 23:39 images/
-rwxrwxrwx 1 www-data www-data 6457 Nov 26 18:48 index.php*
drwxrwxrwx 2 www-data www-data 6144 Nov 5 23:39 info/
-rwxrwxrwx 1 www-data www-data 2496 Nov 26 18:48 license.txt*
drwxrwxrwx 8 www-data www-data 6144 Nov 5 23:40 system/
drwxrwxrwx 3 www-data www-data 6144 Nov 5 23:39 uploads/
drwxrwxrwx 22 www-data www-data 6144 Nov 5 23:46 vendor/
當我嘗試加載網站時,我得到403 Forbidden You don't have permission to access this resource.
/var/log/apache2/access.log
是空的
/var/log/apache2/error.log
有以下內容:
AH01630: client denied by server configuration: /var/www/html
/var/log/apache2/the_site.log
是空的
/var/log/apache2/the_site-error.log
也是空的
感謝您的協助
謝謝伊加爾
答案1
透過重新掛載 EFS 磁碟區解決了這個問題/var/www