1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ubuntu上のapache2で公開するディレクトリを変更する方法

Last updated at Posted at 2019-11-26

背景

/var/www/html内の作業していましたがサイトの内容をリセットすることにしました。リセットするにあたってついでに作業ディレクトリも変更しようと思い立ち解決策を探しました。

環境

  1. Windows Subsystem for Linux (ubuntu18.04LTS)

解決方法

以下のファイルを編集(170行目くらい)

/etc/apache2/apache2.conf
# デフォルトで定義されていたディレクトリ
# <Directory /var/www/html>
 #Options Indexes FollowSymLinks
 #Allow Override None
 #Require all granted
 #EnableSendfile off
# </Directory>

# 新たに定義したいディレクトリ
<Directory /home/"user"/html>
 Options Indexes FollowSymLinks
 Allow Override None
 Require all granted
 EnableSendfile off
</Directory>

以下のファイルも編集

/etc/apache2/sites-enabled/000-default.conf
# DocumentRoot /var/www/html
DocumentRoot /home/"user"/html

以下のコマンドでapacheを再起動
service apache2 restart

蛇足

ネットで調べるとhttpd.confに関するものが多くて「そんなファイルないぞ!」と途方に暮れていました。
今は WSL → Windows10 間での通信しかしていないのでセキュリティに関する設定はまったく気にしていませんが、今後AWS上で公開するときにはapache2.conf内のオプションについて勉強する必要がありますね。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?