ApacheでWebサーバを作ろう!
ここでは、Apacheのインストール手順を掲載しています。
Apacheとは…?
Apacheはオープンソースで開発されているWebサーバ(HTTPサーバ)です。HTTPとはHyperText Transfer Protocolの略で、Webページで使われるHTMLや画像ファイルのデータ(コンテンツ)を送受信するためのルールのことです。
長年シェアナンバー1だったのですが、最近はNginxなどの新サーバが台頭してきています。
が!Rocky Linux 8では、標準でインストールということで、今回はApacheを採用しています。
Apacheの設定
[root@rl8 ~]# vi /etc/httpd/conf/httpd.conf
ServerTokens OS
↓
ServerTokens ProductOnly
ServerAdmin root@localhost
↓
ServerAdmin ************@gmail.com (管理者のメールアドレス)
#ServerName www.example.com:80
↓
ServerName mhserv.info:80 (取得したドメイン)
<Directory "/var/www/html">
Options Indexes FollowSymLinks
↓
Options Includes ExecCGI FollowSymLinks
AllowOverride None
↓
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir disable
↓
#UserDir disable
#UserDir public_html
↓
UserDir public_html
</IfModule>
DirectoryIndex index.html
↓
DirectoryIndex index.html index.htm index.php index.cgi index.shtml
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
↓
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access_log combined
↓
CustomLog logs/access_log combined env=!no_log
SetEnvIf Request_URI "default\.ida" no_log
SetEnvIf Request_URI "cmd\.exe" no_log
SetEnvIf Request_URI "root\.exe" no_log
SetEnvIf Request_URI "Admin\.dll" no_log
SetEnvIf Request_URI "NULL\.IDA" no_log
SetEnvIf Request_URI "xmlrpc\.php" no_log
SetEnvIf Request_URI "zero_vote" no_log
SetEnvIf Request_URI "sumthin" no_log
SetEnvIf Request_URI "~akirin" no_log
SetEnvIf Request_URI "\.(gif)|(jpg)|(png)|(css)$" no_log
#LANのネットワークアドレスを指定
SetEnvIf Remote_Addr 192.168. no_log
ServerSignature On
↓
ServerSignature Off
<Directory "/var/www/icons">
Options Indexes MultiViews
↓
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
↓
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl
コンテンツの圧縮転送
コンテンツを転送するときに、サーバ側で圧縮して転送する"mod_deflate"というモジュールもがあります。
以下のように入力をすることで、設定された形式のファイルに対し圧縮転送を行うことが出来ます。
[root@rl8 ~]# vi /etc/httpd/conf.d/deflate.conf
<Location /> # Insert filter SetOutputFilter DEFLATE # Netscape 4.x has some problems... BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.06-4.08 have some more problems BrowserMatch ^Mozilla/4\.0[678] no-gzip # MSIE masquerades as Netscape, but it is fine # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48 # the above regex won't work. You can use the following # workaround to get the desired effect: BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \\.(?:gif|jpe?g|png|ico|z|taz|t?gz|t?bz2?|zip|lzh|sit|rar|pdf|mp3|ogg|wma|rm|wmv| mov|mpe?g)$ \no-gzip dont-vary # Make sure proxies don't deliver the wrong content Header append Vary User-Agent env=!dont-vary </Location>
Perlへのシンボリックリンクの作成
CGIによって実行場所が/usr/bin/perlだったり/usr/local/bin/perlだったりするので、それに対応するため、シンボリックリンクを張ります。
[root@rl8 ~]# ln -s /usr/bin/perl /usr/local/bin/perl
[root@rl8 ~]# whereis perl
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
次は通信を暗号化しましょう。
参考にしたサイト様
今回新しく登場したコマンド
- ln
- whereis
[広告]

トップページ
Rocky Linux 8
○インストール準備
○仮想化準備(VMware)
○仮想化準備(Hyper-V)
○導入
○基本操作
○セキュリティ対策
○Dynamic DNS
○NTPサーバ
○データベース
○WEBサーバ
○その他
CentOS 7
Scientific Linux 6
CentOS 5
ブログ
[広告]