VirtualHost の設定

設定の確認

# pwd
/var/www/vhosts/intern02.db-force.net/www
# cd /var/www/vhosts/
# mkdir -p hirose.com/www
# cd hirose.com/www/
# pwd
/var/www/vhosts/hirose.com/www
# cd ../../;ls
hirose.com  intern02.db-force.net

DNS設定前なので、とりあえずWindowsのHostsファイル編集で名前解決する

C:\Windows\System32\drivers\etc\hosts
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
 ~(中略)~ ↓ 追記
XXX.XXX.XXX.201 intern02.db-force.net
XXX.XXX.XXX.201 hirose.com

ログ保存用ディレクトリを作成

$ pwd
/var/www/vhosts/intern02.db-force.net
$ sudo mkdir logs
$ ls
logs  www

$ cd ../hirose.com/
$ pwd
/var/www/vhosts/hirose.com
$ sudo mkdir logs
$ ls
logs  www

$ pwd
/etc/httpd/conf.d
$ sudo vim virtualhost.conf
<VirtualHost *:80>
  Servername    intern02.db-force.net
  DocumentRoot  /var/www/vhosts/intern02.db-force.net/www
  CustomLog     /var/www/vhosts/intern02.db-force.net/logs/intern_access_log common
  ErrorLog      /var/www/vhosts/intern02.db-force.net/logs/intern_error_log
</VirtualHost>

<Directory /var/www/vhosts/intern02.db-force.net/www>
  Require all granted
</Directory>

<VirtualHost *:80>
  Servername    hirose.com
  DocumentRoot  /var/www/vhosts/hirose.com/www
  CustomLog     /var/www/vhosts/hirose.com/hirose_access_log common
  ErrorLog      /var/www/vhosts/hirose.com/hirose_error_log
</VirtualHost>

<Directory /var/www/vhosts/hirose.com/www>
  Require all granted
</Directory>
$ sudo systemctl restart httpd

f:id:hirose-test:20190722175939p:plain

f:id:hirose-test:20190722175957p:plain

/* -----codeの行番号----- */