Allowは、指定のホスト名、IPアドレス、IPアドレスの範囲のサーバからのアクセスを許可することを表すディレクティブ。
mod_access_compat - Apache HTTP サーバ バージョン 2.4
第9回 知っておきたいApacheの基礎知識 その5:UNIX的なアレ:gihyo.jp出張所|gihyo.jp … 技術評論社
デフォルトで、"/var/www/html"にアクセスできるが、今回は"/var/www/htmltest/"の下にindex.htmlを置いて、そこにアクセスできるかを試す。
[bg1@localhost ~]$ su パスワード: [root@localhost bg1]# cd /etc/httpd/conf [root@localhost conf]# ls httpd.conf magic [root@localhost conf]# vi httpd.conf
httpd.confを開いて、
# Further relax access to the default document root: <Directory "/var/www/html"> # # 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 Options 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 AllowOverride All # # Controls who can get stuff from this server. # Require all granted </Directory> Alias /htmltest /var/www/htmltest/ <Directory "/var/www/htmltest/"> Allow from all </Directory>
<Directory>ディレクティブの後に、
mod_alias - Apache HTTP サーバ バージョン 2.4
Aliasディレクティブで"/htmltest"を"/var/www/htmltest/"に置き換えるようにする。
そして、<Directory>ディレクティブで、"/var/www/htmltest/"のアクセス制御を書いていく。
Allow from allだから、すべてのアクセスを許可。
[root@localhost conf]# cd /var/www/html/ [root@localhost html]# ls index.html [root@localhost html]# cd .. [root@localhost www]# ls cgi-bin html [root@localhost www]# mkdir htmltest [root@localhost www]# cd htmltest/ [root@localhost htmltest]# cp ../html/index.html . [root@localhost htmltest]# ls index.html [root@localhost htmltest]# vi index.html
htmltestフォルダを作って、index.htmlを開いて、
<html> <head> <title>HtmlTest</title> </head> <body> HtmlTest </body> </html>
とする。
あとは、
[root@localhost conf]# ifconfig enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 inet6 fe80::550b:2cd:4bf8:bef9 prefixlen 64 scopeid 0x20<link> ether 08:00:27:19:ca:92 txqueuelen 1000 (Ethernet) RX packets 4093 bytes 2695063 (2.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3522 bytes 493888 (482.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 28 bytes 2945 (2.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 28 bytes 2945 (2.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost conf]#
IPは、10.0.2.15。
で、
[root@localhost conf]# apachectl start
Apacheを起動し、10.0.2.15/htmltest/index.htmlにアクセス。
HtmlTestが表示された。
すべてかどうかはチェックしてないけど、だいたい全てでしょ。