LoginSignup
9
9

More than 5 years have passed since last update.

Ubuntu で apache2のDocument rootを変更する方法

Last updated at Posted at 2019-01-13

この記事の目的

個人的にGCE上UbuntuでWordpressを使ってサイトを立ち上げた際に実施した、
Document Rootを変更作業の備忘録。

開発環境

  • Ubuntu 18.10
  • Apache 2.4.34

設定手順

1. apache2.cnf を編集し、コンテンツのディレクトリを変更する。

自分の場合は、/etc/apache2/apache2.cnf を編集する。
今回は、/var/www/html/wordpress フォルダにあるコンテンツを表示してほしいので、下記の様に"/html/wordpress"をに追加する。

$ sudo vim /etc/apache2/apache2.conf 
~
170 <Directory /var/www"ここから"/html/wordpress"ここまで追加">
171         Options Indexes FollowSymLinks
172         AllowOverride All
173         Require all granted
174 </Directory>
175 
~

2. 000-default.conf を編集し、1の変更を反映する。

000-default.confは/etc/apache2/sites-available ディレクトリにあり、
virtual hostの設定が書いてあるファイル。
下記の様に、変更する。

$ sudo vim /etc/apache2/sites-available/000-default.conf
~

 10 
 11         ServerAdmin webmaster@localhost
 12         DocumentRoot /var/www"ここから"/html/wordpress"ここまで追加"
 13 
~

3. Apache2を再起動する。

変更を反映させるため、Apache2を再起動します。

$ sudo service apache2 restart

終わりに

これで、Document Rootが変更できました。

参考記事

こちら

9
9
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
9
9