
ファイルを 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>
エンティティから次の 2 行を削除できます。Order allow,deny Allow from all
これらの権限ステートメントは、
Require
ステートメントを使用して処理されるようになりました。Apache が、ユーザーがベアドメインにアクセスしたときに何を提供するか分からない場合、デフォルトでディレクトリ構造を表示するか、エラーを表示します。PHP ベースのサイトを実行している場合は、 の直後に次の行を追加できます
DocumentRoot
。DirectoryIndex index.php index.html index.htm
index.php
これは、まずディレクトリ内でを検索し/public
、index.html
PHP ファイルが存在しない場合は で失敗し、次に で失敗しますindex.htm
。
これらの項目が処理されたら、Apache サーバーを再起動 (またはリロード) します。
sudo service apache2 restart
これで必要なものが手に入るはずです