
我的設定:
ubuntu 22.04
Apache/2.4.52 (Ubuntu) Server
I created /etc/apache2/sites-available/test.mysite.conf:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName test.xxxxxxxx.com
DocumentRoot /home/test/deploy/current
<Directory /home/test/deploy/current>
AllowOverride all
Options -MultiViews
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/test/error.log
CustomLog ${APACHE_LOG_DIR}/test/access.log combined
</VirtualHost>
我禁用了內建的 000-default.conf,如下所示:
sudo a2dissite 000-default.conf
並驗證它不再位於 /etc/apache2/sites-enabled 中
並啟用虛擬主機:
sudo a2ensite test.mysite.conf
並驗證它現在位於 /etc/apache2/sites-enabled 中
我確認配置沒問題:
sudo apache2ctl configtest
並重新啟動apache伺服器:
sudo systemctl restart apache2
這是權限列表
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-x--- test test test
drwxr-xr-x test test deploy
drwxrwxr-x test test current
-rw-rw-r-- test test index.html
這是託管在AWS上的,所以我也去了AWS,並驗證了安全群組的入站規則,允許從我的家庭IP位址(我有固定IP位址)進行連接。我也沒有在伺服器上啟用防火牆。
但當我這樣做時http://test.xxxxxxxx.com
我在瀏覽器中收到以下訊息:
Forbidden
You don't have permission to access this resource.
Apache/2.4.52 (Ubuntu) Server at test.xxxxxxxx.com Port 80
有任何想法嗎?
答案1
裡面的權限/home/test/
太受限了。
drwxr-x--- test test test
不允許任何人test
進入該目錄,因此 Apache 無法讀取該目錄。
/home/
無論如何,這不是放置網路根目錄的正確位置。代替使用/var/www
。