「インストール - Apache2(SUSE)」の版間の差分
編集の要約なし |
|||
| 1行目: | 1行目: | ||
== 概要 == | == 概要 == | ||
このページでは、SUSEにおいて、Webサーバを構築する手順を記載する。<br> | |||
<br><br> | <br><br> | ||
| 10行目: | 10行目: | ||
Webサーバが動作しているか確認するため、下記のようなテストページを作成する。<br> | Webサーバが動作しているか確認するため、下記のようなテストページを作成する。<br> | ||
sudo vi /srv/www/htdocs/index.html | sudo vi /srv/www/htdocs/index.html | ||
<br> | |||
index. | <syntaxhighlight lang="html"> | ||
index.htmlファイル | |||
<html> | <html> | ||
<body> | <body> | ||
<h1>Welcome to | <h1>Welcome to SUSE Web Site</h1> | ||
</body> | </body> | ||
</html> | </html> | ||
</ | </syntaxhighlight> | ||
<br> | <br> | ||
Webブラウザに http://localhost と入力する。<br> | Webブラウザに http://localhost と入力する。<br> | ||
| 27行目: | 27行目: | ||
CGIファイルのディレクトリのパスは/srv/www/cgi-bin/である。<br> | CGIファイルのディレクトリのパスは/srv/www/cgi-bin/である。<br> | ||
sudo vi /srv/www/cgi-bin/test.cgi | sudo vi /srv/www/cgi-bin/test.cgi | ||
<br> | |||
<syntaxhighlight lang="sh"> | |||
test.cgiファイル | |||
#!/usr/bin/env bash | |||
echo "Content-type:text/html" | echo "Content-type:text/html" | ||
echo " | echo "SUSE Test CGI" | ||
</syntaxhighlight> | |||
<br> | <br> | ||
また、一般ユーザでも実行できるようにするため、以下のコマンドを実行する。<br> | また、一般ユーザでも実行できるようにするため、以下のコマンドを実行する。<br> | ||
| 43行目: | 46行目: | ||
== PHPのインストール == | == PHPのインストール == | ||
次に、PHPをインストールする。<br> | 次に、PHPをインストールする。<br> | ||
PHPのインストール手順においては、[[インストール - PHP7 | PHPのインストール手順においては、[[インストール - PHP7]]を参照すること。<br> | ||
<br> | <br> | ||
PHPが正常に動作するか確認するため、/srv/www/htdocsディレクトリに、以下のようなPHPファイルを作成する。<br> | PHPが正常に動作するか確認するため、/srv/www/htdocsディレクトリに、以下のようなPHPファイルを作成する。<br> | ||
| 51行目: | 54行目: | ||
<br> | <br> | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
test.phpファイル | |||
<?php | <?php | ||
phpinfo(); | phpinfo(); | ||
| 57行目: | 62行目: | ||
<br> | <br> | ||
Webブラウザを起動して、http://localhost/test.php と入力する。<br> | Webブラウザを起動して、http://localhost/test.php と入力する。<br> | ||
インストール済みのPHPの情報が表示されていれば、Apache2が正しく動作している。<br> | |||
<br><br> | <br><br> | ||
| 69行目: | 74行目: | ||
Apache2の再起動は、以下のコマンドを実行する。<br> | Apache2の再起動は、以下のコマンドを実行する。<br> | ||
sudo systemctl restart apache2 | sudo systemctl restart apache2 | ||
<br> | |||
Apache2の自動起動は、以下のコマンドを実行する。<br> | Apache2の自動起動は、以下のコマンドを実行する。<br> | ||
sudo systemctl enable apache2 | sudo systemctl enable apache2 | ||
<br><br> | |||
== 仮想ホストの構築 == | |||
このセクションでは、SUSEにおいて、仮想ホストの構築手順を記載する。<br> | |||
<br> | |||
まず、/etc/apache2/vhosts.dディレクトリにアクセスする。<br> | |||
このディレクトリは、仮想ホストの設定ファイル(*.confファイル)を配置するディレクトリである。<br> | |||
cd /etc/apache2/vhosts.d | |||
<br> | |||
vhost.templateファイルをコピーして、vhost-sample.confファイルを作成する。<br> | |||
以下に示すように、vhost-sample.confファイルの内容を編集する。<br> | |||
<u>以下の例では、/home/<ユーザ名>/htdocsディレクトリをドキュメントルートとしている。</u><br> | |||
# /etc/apache2/vhosts.d/vhost-localhost.confファイル | |||
# 仮想ホスト1 | |||
<VirtualHost *:80> | |||
ServerAdmin webmaster@localhost | |||
ServerName localhost | |||
# DocumentRoot: The directory out of which you will serve your | |||
# documents. By default, all requests are taken from this directory, but | |||
# symbolic links and aliases may be used to point to other locations. | |||
DocumentRoot /srv/www/htdocs | |||
# if not specified, the global error log is used | |||
ErrorLog /var/log/apache2/localhost_error_log | |||
CustomLog /var/log/apache2/localhost_access_log combined | |||
# don't loose time with IP address lookups | |||
HostnameLookups Off | |||
# needed for named virtual hosts | |||
UseCanonicalName Off | |||
# configures the footer on server-generated documents | |||
ServerSignature On | |||
# Optionally, include *.conf files from /etc/apache2/conf.d/ | |||
# | |||
# For example, to allow execution of PHP scripts: | |||
# | |||
# Include /etc/apache2/conf.d/php5.conf | |||
# | |||
# or, to include all configuration snippets added by packages: | |||
# Include /etc/apache2/conf.d/*.conf | |||
# ScriptAlias: This controls which directories contain server scripts. | |||
# ScriptAliases are essentially the same as Aliases, except that | |||
# documents in the realname directory are treated as applications and | |||
# run by the server when requested rather than as documents sent to the client. | |||
# The same rules about trailing "/" apply to ScriptAlias directives as to | |||
# Alias. | |||
# | |||
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/" | |||
# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased | |||
# CGI directory exists, if you have one, and where ScriptAlias points to. | |||
# | |||
<Directory "/srv/www/cgi-bin"> | |||
AllowOverride None | |||
Options +ExecCGI -Includes | |||
<IfModule !mod_access_compat.c> | |||
Require all granted | |||
</IfModule> | |||
<IfModule mod_access_compat.c> | |||
Order allow,deny | |||
Allow from all | |||
</IfModule> | |||
</Directory> | |||
# UserDir: The name of the directory that is appended onto a user's home | |||
# directory if a ~user request is received. | |||
# | |||
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES | |||
# in /etc/sysconfig/apache2. | |||
# | |||
<IfModule mod_userdir.c> | |||
# Note that the name of the user directory ("public_html") cannot simply be | |||
# changed here, since it is a compile time setting. The apache package | |||
# would have to be rebuilt. You could work around by deleting | |||
# /usr/sbin/suexec, but then all scripts from the directories would be | |||
# executed with the UID of the webserver. | |||
UserDir public_html | |||
# The actual configuration of the directory is in | |||
# /etc/apache2/mod_userdir.conf. | |||
Include /etc/apache2/mod_userdir.conf | |||
# You can, however, change the ~ if you find it awkward, by mapping e.g. | |||
# http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/ | |||
#AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2 | |||
</IfModule> | |||
# | |||
# This should be changed to whatever you set DocumentRoot to. | |||
# | |||
<Directory "/srv/www/htdocs"> | |||
# | |||
# Possible values for the Options directive are "None", "All", | |||
# or any combination of: | |||
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews | |||
# | |||
# Note that "MultiViews" must be named *explicitly* --- "Options All" | |||
# doesn't give it to you. | |||
# | |||
# The Options directive is both complicated and important. Please see | |||
# http://httpd.apache.org/docs/2.4/mod/core.html#options | |||
# for more information. | |||
# | |||
Options Indexes FollowSymLinks | |||
# | |||
# AllowOverride controls what directives may be placed in .htaccess files. | |||
# It can be "All", "None", or any combination of the keywords: | |||
# Options FileInfo AuthConfig Limit | |||
# | |||
AllowOverride None | |||
# | |||
# Controls who can get stuff from this server. | |||
# | |||
<IfModule !mod_access_compat.c> | |||
Require all granted | |||
</IfModule> | |||
<IfModule mod_access_compat.c> | |||
Order allow,deny | |||
Allow from all | |||
</IfModule> | |||
</Directory> | |||
</VirtualHost> | |||
<br> | |||
# /etc/apache2/vhosts.d/vhost-example.confファイル | |||
# 仮想ホスト2 | |||
<VirtualHost *:80> | |||
ServerAdmin webmaster@<サーバ名> | |||
ServerName <サーバ名> | |||
# DocumentRoot: The directory out of which you will serve your | |||
# documents. By default, all requests are taken from this directory, but | |||
# symbolic links and aliases may be used to point to other locations. | |||
DocumentRoot /home/<ユーザ名>/htdocs | |||
# if not specified, the global error log is used | |||
ErrorLog /home/<ユーザ名>/htdocs/error/error_log | |||
CustomLog /home/<ユーザ名>/htdocs/error/custom_log combined | |||
# don't loose time with IP address lookups | |||
HostnameLookups Off | |||
# needed for named virtual hosts | |||
UseCanonicalName Off | |||
# configures the footer on server-generated documents | |||
ServerSignature On | |||
# Optionally, include *.conf files from /etc/apache2/conf.d/ | |||
# | |||
# For example, to allow execution of PHP scripts: | |||
# | |||
# Include /etc/apache2/conf.d/php5.conf | |||
# | |||
# or, to include all configuration snippets added by packages: | |||
# Include /etc/apache2/conf.d/*.conf | |||
# ScriptAlias: This controls which directories contain server scripts. | |||
# ScriptAliases are essentially the same as Aliases, except that | |||
# documents in the realname directory are treated as applications and | |||
# run by the server when requested rather than as documents sent to the client. | |||
# The same rules about trailing "/" apply to ScriptAlias directives as to | |||
# Alias. | |||
# | |||
ScriptAlias /cgi-bin/ "/home/<ユーザ名>/htdocs/cgi-bin/" | |||
# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased | |||
# CGI directory exists, if you have one, and where ScriptAlias points to. | |||
# | |||
<Directory "/home/<ユーザ名>/htdocs/cgi-bin"> | |||
AllowOverride None | |||
Options +ExecCGI -Includes | |||
<IfModule !mod_access_compat.c> | |||
Require all granted | |||
</IfModule> | |||
<IfModule mod_access_compat.c> | |||
Order allow,deny | |||
Allow from all | |||
</IfModule> | |||
</Directory> | |||
# UserDir: The name of the directory that is appended onto a user's home | |||
# directory if a ~user request is received. | |||
# | |||
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES | |||
# in /etc/sysconfig/apache2. | |||
# | |||
<IfModule mod_userdir.c> | |||
# Note that the name of the user directory ("public_html") cannot simply be | |||
# changed here, since it is a compile time setting. The apache package | |||
# would have to be rebuilt. You could work around by deleting | |||
# /usr/sbin/suexec, but then all scripts from the directories would be | |||
# executed with the UID of the webserver. | |||
UserDir public_html | |||
# The actual configuration of the directory is in | |||
# /etc/apache2/mod_userdir.conf. | |||
Include /etc/apache2/mod_userdir.conf | |||
# You can, however, change the ~ if you find it awkward, by mapping e.g. | |||
# http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/ | |||
#AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2 | |||
</IfModule> | |||
# | |||
# This should be changed to whatever you set DocumentRoot to. | |||
# | |||
<Directory "/home/suse/htdocs"> | |||
# | |||
# Possible values for the Options directive are "None", "All", | |||
# or any combination of: | |||
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews | |||
# | |||
# Note that "MultiViews" must be named *explicitly* --- "Options All" | |||
# doesn't give it to you. | |||
# | |||
# The Options directive is both complicated and important. Please see | |||
# http://httpd.apache.org/docs/2.4/mod/core.html#options | |||
# for more information. | |||
# | |||
Options Indexes FollowSymLinks | |||
# | |||
# AllowOverride controls what directives may be placed in .htaccess files. | |||
# It can be "All", "None", or any combination of the keywords: | |||
# Options FileInfo AuthConfig Limit | |||
# | |||
AllowOverride None | |||
# | |||
# Controls who can get stuff from this server. | |||
# | |||
<IfModule !mod_access_compat.c> | |||
Require all granted | |||
</IfModule> | |||
<IfModule mod_access_compat.c> | |||
Order allow,deny | |||
Allow from all | |||
</IfModule> | |||
</Directory> | |||
</VirtualHost> | |||
<br> | |||
次に、IPアドレスと仮想ホストのサーバ名の名前解決を行うため、/etc/hostsファイルを編集する。<br> | |||
sudo vi /etc/hosts | |||
<br> | |||
/etc/hostsファイル | |||
# Syntax: | |||
# | |||
# IP-Address Full-Qualified-Hostname Short-Hostname | |||
# | |||
...略... | |||
127.0.0.1 localhost | |||
127.0.0.1 <仮想ホストのサーバ名> | |||
...略... | |||
<br> | |||
仮想ホストの設定ファイル(*.confファイル)を反映させるため、Apache2を再起動する。<br> | |||
sudo systemctl restart apache2 | |||
<br><br> | <br><br> | ||
__FORCETOC__ | __FORCETOC__ | ||
[[カテゴリ:SUSE]] | [[カテゴリ:SUSE]] | ||
2020年12月31日 (木) 00:39時点における版
概要
このページでは、SUSEにおいて、Webサーバを構築する手順を記載する。
Apache2のインストール
まず、WebサーバーソフトウェアのApache2をインストールするため、以下のコマンドを実行する。
Apacheのルートディレクトリのパスは/srv/www/htdocs/である。
sudo zypper install apache2
Webサーバが動作しているか確認するため、下記のようなテストページを作成する。
sudo vi /srv/www/htdocs/index.html
index.htmlファイル
<html>
<body>
<h1>Welcome to SUSE Web Site</h1>
</body>
</html>
Webブラウザに http://localhost と入力する。
"It Works!"と記載された下記のWebページが表示されれば、Apache2のインストールは完了である。
また、test.cgiファイルを作成して表示する。test.cgiファイルの内容は下記の通りである。
CGIファイルのディレクトリのパスは/srv/www/cgi-bin/である。
sudo vi /srv/www/cgi-bin/test.cgi
test.cgiファイル
#!/usr/bin/env bash
echo "Content-type:text/html"
echo "SUSE Test CGI"
また、一般ユーザでも実行できるようにするため、以下のコマンドを実行する。
sudo chmod 755 /srv/www/cgi-bin/test.cgi
test.cgiファイルを実行するため、Webブラウザに http://localhost/cgi-bin/test.cgi と入力する。
Webブラウザに"openSUSE Test CGI"という文字が表示されていれば、正常に動作している。
PHPのインストール
次に、PHPをインストールする。
PHPのインストール手順においては、インストール - PHP7を参照すること。
PHPが正常に動作するか確認するため、/srv/www/htdocsディレクトリに、以下のようなPHPファイルを作成する。
以下のコマンドでテスト用のPHPファイルを作成して表示する。
PHPファイルの内容は下記の通りである。
sudo vi /srv/www/htdocs/test.php
test.phpファイル
<?php
phpinfo();
?>
Webブラウザを起動して、http://localhost/test.php と入力する。
インストール済みのPHPの情報が表示されていれば、Apache2が正しく動作している。
Apache2の起動・停止・再起動
Apache2の起動は、以下のコマンドを実行する。
sudo systemctl start apache2
Apache2の停止は、以下のコマンドを実行する。
sudo systemctl stop apache2
Apache2の再起動は、以下のコマンドを実行する。
sudo systemctl restart apache2
Apache2の自動起動は、以下のコマンドを実行する。
sudo systemctl enable apache2
仮想ホストの構築
このセクションでは、SUSEにおいて、仮想ホストの構築手順を記載する。
まず、/etc/apache2/vhosts.dディレクトリにアクセスする。
このディレクトリは、仮想ホストの設定ファイル(*.confファイル)を配置するディレクトリである。
cd /etc/apache2/vhosts.d
vhost.templateファイルをコピーして、vhost-sample.confファイルを作成する。
以下に示すように、vhost-sample.confファイルの内容を編集する。
以下の例では、/home/<ユーザ名>/htdocsディレクトリをドキュメントルートとしている。
# /etc/apache2/vhosts.d/vhost-localhost.confファイル
# 仮想ホスト1
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName localhost
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /srv/www/htdocs
# if not specified, the global error log is used
ErrorLog /var/log/apache2/localhost_error_log
CustomLog /var/log/apache2/localhost_access_log combined
# don't loose time with IP address lookups
HostnameLookups Off
# needed for named virtual hosts
UseCanonicalName Off
# configures the footer on server-generated documents
ServerSignature On
# Optionally, include *.conf files from /etc/apache2/conf.d/
#
# For example, to allow execution of PHP scripts:
#
# Include /etc/apache2/conf.d/php5.conf
#
# or, to include all configuration snippets added by packages:
# Include /etc/apache2/conf.d/*.conf
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have one, and where ScriptAlias points to.
#
<Directory "/srv/www/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
# Note that the name of the user directory ("public_html") cannot simply be
# changed here, since it is a compile time setting. The apache package
# would have to be rebuilt. You could work around by deleting
# /usr/sbin/suexec, but then all scripts from the directories would be
# executed with the UID of the webserver.
UserDir public_html
# The actual configuration of the directory is in
# /etc/apache2/mod_userdir.conf.
Include /etc/apache2/mod_userdir.conf
# You can, however, change the ~ if you find it awkward, by mapping e.g.
# http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/
#AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
</IfModule>
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/www/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
</VirtualHost>
# /etc/apache2/vhosts.d/vhost-example.confファイル
# 仮想ホスト2
<VirtualHost *:80>
ServerAdmin webmaster@<サーバ名>
ServerName <サーバ名>
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot /home/<ユーザ名>/htdocs
# if not specified, the global error log is used
ErrorLog /home/<ユーザ名>/htdocs/error/error_log
CustomLog /home/<ユーザ名>/htdocs/error/custom_log combined
# don't loose time with IP address lookups
HostnameLookups Off
# needed for named virtual hosts
UseCanonicalName Off
# configures the footer on server-generated documents
ServerSignature On
# Optionally, include *.conf files from /etc/apache2/conf.d/
#
# For example, to allow execution of PHP scripts:
#
# Include /etc/apache2/conf.d/php5.conf
#
# or, to include all configuration snippets added by packages:
# Include /etc/apache2/conf.d/*.conf
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/home/<ユーザ名>/htdocs/cgi-bin/"
# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have one, and where ScriptAlias points to.
#
<Directory "/home/<ユーザ名>/htdocs/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
# Note that the name of the user directory ("public_html") cannot simply be
# changed here, since it is a compile time setting. The apache package
# would have to be rebuilt. You could work around by deleting
# /usr/sbin/suexec, but then all scripts from the directories would be
# executed with the UID of the webserver.
UserDir public_html
# The actual configuration of the directory is in
# /etc/apache2/mod_userdir.conf.
Include /etc/apache2/mod_userdir.conf
# You can, however, change the ~ if you find it awkward, by mapping e.g.
# http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/
#AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
</IfModule>
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/home/suse/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
<IfModule !mod_access_compat.c>
Require all granted
</IfModule>
<IfModule mod_access_compat.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
</VirtualHost>
次に、IPアドレスと仮想ホストのサーバ名の名前解決を行うため、/etc/hostsファイルを編集する。
sudo vi /etc/hosts
/etc/hostsファイル # Syntax: # # IP-Address Full-Qualified-Hostname Short-Hostname # ...略... 127.0.0.1 localhost 127.0.0.1 <仮想ホストのサーバ名> ...略...
仮想ホストの設定ファイル(*.confファイル)を反映させるため、Apache2を再起動する。
sudo systemctl restart apache2