LoginSignup
0
1

More than 3 years have passed since last update.

Ubuntu 18.04 バーチャルホスト

Last updated at Posted at 2020-03-07
  • バージョン

Ubuntu 18.04.4 LTS
Apache/2.4.29 (Ubuntu)


  • ホームディレクトリに、public_htmlディレクトリを作成する
    mkdir /home/user/public_html
    ※ 例: ユーザー名は、userの例

  • index.htmlファイルを作成する
    vi /home/user/public_html/index.html

  • index.htmlファイルに表示する内容を記述する

<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
</head>
<body>
テスト
</body>
</html>

  • 管理者権限にする
    sudo su -

  • 設定ファイルのディレクトリへ移動する
    cd /etc/apache2/sites-available

  • 設定ファイルのテンプレートをコピーする
    cp 000-default.conf test.com.conf
    ※ 例: test.comという名前のバーチャルホストを作成する例

  • test.com.confファイルをviエディタで編集して保存する
    vi test.com.conf

ServerName test.com
DocumentRoot /home/user/public_html/

※ 例: ユーザー名は、userの例

  • ホームディレクトリ内に置いたファイルを Webサイトとして公開できるようにする
    a2enmode userdir

  • test.com.confファイルを反映する
    a2ensite test.com

  • アパッチを再起動する
    systemctl restart apache2


  • ブラウザで、test.comにアクセスする
0
1
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
0
1