WEBサーバー (Apache)

DNさん用。実習。

頂いたグローバルIPに接続してみる。当然まだ何もない。

f:id:hirose-test:20190721122013j:plain

$ sudo yum install httpd
 ~(中略)~
インストール中:
 httpd                 x86_64           2.4.6-89.el7.centos              updates           2.7 M
依存性関連でのインストールをします:
 httpd-tools           x86_64           2.4.6-89.el7.centos              updates            90 k
 mailcap               noarch           2.1.41-2.el7                     base               31 k
 ~(中略)~
インストール:
  httpd.x86_64 0:2.4.6-89.el7.centos

依存性関連をインストールしました:
  httpd-tools.x86_64 0:2.4.6-89.el7.centos             mailcap.noarch 0:2.1.41-2.el7

完了しました!
$ systemctl status httpdhttpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
$ sudo systemctl start httpd
$ sudo systemctl enable httpd
$ systemctl status httpd
 httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2019-07-21 12:14:13 JST; 11min ago
 ~(後略)~

f:id:hirose-test:20190721122132j:plain

$ pwd
/var/www
$ sudo mkdir -p vhosts/intern02.db-force.net/www/
$ cd vhosts/intern02.db-force.net/www/
$ pwd
/var/www/vhosts/intern02.db-force.net/www

ドキュメントルート変更

$ cd /etc/httpd/conf
$ ls
httpd.conf  magic
$ sudo cp -p ./httpd.conf httpd.conf.org
$ ls
httpd.conf  httpd.conf.org  magic
$ sudo vim httpd.conf
#
# 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 "/var/www/html"
 ↓ 変更
DocumentRoot "/var/www/vhosts/intern02.db-force.net/www"

テストページ作成

$ pwd
/var/www/vhosts/intern02.db-force.net/www
$ sudo vim index.html
$ sudo systemctl restart httpd

f:id:hirose-test:20190721194955j:plain

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