
將文件放入 html 目錄後出現此錯誤,我對此設定感到困惑。我想我必須打開該index.php
文件,但出現 500 錯誤。請告訴我您發現的任何錯誤。
這是數據來自/etc/apache2/sites-available/fullstack1.conf
:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName www.fullstack1.xyz
ServerAlias fullstack1.xyz
DocumentRoot /var/www/html/fullstack1
<Directory /var/www/html/fullstack1/public/>
DirectoryIndex index.php
AllowOverride All
Require all granted
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
LogLevel warn
</VirtualHost>
這是數據來自/etc/apache2/apache2.conf
:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
答案1
看起來您在文件中有幾個項目要查看fullstack1.conf
:
您
DocumentRoot
應該指向網站訪客將從該目錄開始的目錄,根據實體<Directory>
,該目錄應該是:/var/www/html/fullstack1/public
實體中的最後一個斜線
<Directory>
是不必要的:<Directory /var/www/html/fullstack1/public>
如果您執行的是現代版本的 Apache,則可以從實體中刪除這兩行
<Directory>
:Order allow,deny Allow from all
這些權限語句現在透過語句進行處理
Require
。如果 Apache 不知道當人們造訪裸域時要提供什麼服務,它將預設顯示目錄結構或出現錯誤。當您執行基於 PHP 的網站時,您可以在之後立即新增此行
DocumentRoot
:DirectoryIndex index.php index.html index.htm
index.php
這將首先在目錄中查找,如果 PHP 檔案不存在,則/public
首先查找失敗,然後查找.index.html
index.htm
處理完這些事項後,重新啟動(或重新載入)Apache 伺服器:
sudo service apache2 restart
這應該會給你你所需要的