<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apache | ばすにっきTips</title>
	<atom:link href="https://takabus.com/tips/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>https://takabus.com/tips</link>
	<description>プログラミングやサーバー、日々のTipsをメモしています。</description>
	<lastBuildDate>Tue, 08 Nov 2022 09:32:41 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.3</generator>

<image>
	<url>https://takabus.com/tips/wp-content/uploads/2022/12/cropped-tips-1-32x32.png</url>
	<title>Apache | ばすにっきTips</title>
	<link>https://takabus.com/tips</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Apacheで使用するPHPのバージョンを切り替えるには？a2enmodコマンドを使うとかんたん！</title>
		<link>https://takabus.com/tips/859/</link>
					<comments>https://takabus.com/tips/859/#respond</comments>
		
		<dc:creator><![CDATA[ばすにっきTips]]></dc:creator>
		<pubDate>Sat, 15 Jan 2022 06:37:45 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[Apache]]></category>
		<guid isPermaLink="false">https://takabus.com/tips/?p=859</guid>

					<description><![CDATA[Apache2.4で使用するPHPのバージョンを切り替える方法をメモしておきます。a2enmodコマンドを使うとかんたんです。]]></description>
										<content:encoded><![CDATA[
<p>Apache2.4で使用するPHPのバージョンを切り替える方法をメモしておきます。</p>



<p>ここでは現在php7.2を使用しているものとし、使用するphpのバージョンをphp7.3に変更してみます。なお、php7.3はあからじめインストールされているものとします。</p>



<h2 class="wp-block-heading">a2enmodコマンドを使うとかんたん！</h2>



<p>Apacheで使用するPHPのバージョンは、読み込まれているphpのモジュールにより決定されます。<span class="marker-under"><strong>モジュールを切り替えることにより、ほかのバージョンのphpに切り替えることが可能です。</strong></span></p>



<p>Apache2.4がインストールされている環境では、多くの場合a2コマンドが利用できます。a2enmodおよびa2dismodコマンドを使い、php7.3モジュールを読み込むようにすれば、php7.3を使用するようになります。</p>



<h2 class="wp-block-heading">PHPのバージョンを切り替える</h2>



<p>まず、<strong><span class="red">a2dismodコマンド</span></strong>により現在使用されているバージョンのPHPモジュールを無効にします。</p>



<pre class="wp-block-code"><code>$sudo a2dismod
Your choices are: access_compat alias auth_basic auth_digest authn_core authn_file authz_core authz_host authz_user autoindex deflate dir env filter headers http2 include mime mpm_prefork negotiation php7.2 proxy proxy_http reqtimeout rewrite setenvif slotmem_shm socache_shmcb ssl status userdir xml2enc
<strong>Which module(s) do you want to disable (wildcards ok)?</strong>
<strong><span class="red">php7.2</span></strong>
Module php7.2 disabled.
To activate the new configuration, you need to run:
  systemctl restart apache2</code></pre>



<p><strong><span class="red">a2dismodコマンド</span></strong>を実行すると有効なモジュールがリストアップされ、php7.2が読み込まれていることが分かります。php7.2を指定し、無効にします。</p>



<p>つづけて、<strong><span class="red">a2enmodコマンド</span></strong>により変更したいバージョンのphpモジュール（ここではphp7.3）を有効にします。</p>



<pre class="wp-block-code"><code>$sudo a2enmod
Your choices are: access_compat actions alias allowmethods asis auth_basic auth_digest auth_form authn_anon authn_core authn_dbd authn_dbm authn_file authn_socache authnz_fcgi authnz_ldap authz_core authz_dbd authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex brotli buffer cache cache_disk cache_socache cern_meta cgi cgid charset_lite data dav dav_fs dav_lock dbd deflate dialup dir dump_io echo env expires ext_filter file_cache filter headers heartbeat heartmonitor http2 ident imagemap include info lbmethod_bybusyness lbmethod_byrequests lbmethod_bytraffic lbmethod_heartbeat ldap log_debug log_forensic lua macro md mime mime_magic mpm_event mpm_prefork mpm_worker negotiation php7.2 <strong>php7.3</strong> proxy proxy_ajp proxy_balancer proxy_connect proxy_express proxy_fcgi proxy_fdpass proxy_ftp proxy_hcheck proxy_html proxy_http proxy_http2 proxy_scgi proxy_uwsgi proxy_wstunnel ratelimit reflector remoteip reqtimeout request rewrite sed session session_cookie session_crypto session_dbd setenvif slotmem_plain slotmem_shm socache_dbm socache_memcache socache_shmcb speling ssl status substitute suexec unique_id userdir usertrack vhost_alias xml2enc
<strong>Which module(s) do you want to enable (wildcards ok)?
<span class="bold-red">php7.3</span></strong>
Considering dependency mpm_prefork for php7.3:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.3:
Enabling module php7.3.
To activate the new configuration, you need to run:
  systemctl restart apache2</code></pre>



<p><span class="marker-under"><strong>最後にApacheをリスタートし、設定を適用します。</strong></span></p>



<pre class="wp-block-code"><code>$sudo systemctl restart apache2</code></pre>



<p>試しにphpを使用したサイトにアクセスしてみます。きちんと動作することを確認しましょう。</p>



<p>なお、PHPで使用されるモジュールはPHPのバージョンごとにインストールされています。PHPの設定ファイル（php.ini）もバージョンごとに異なるため、使用するPHPを変更することでモジュールや設定に起因するエラーが発生することがあります。</p>



<p><strong><span class="marker-under-red">PHPが正常に動作していないと、PHPで書かれたサイトのソースコードなどがそのまま表示されてしまうこともあるので、バージョン変更後は入念に動作チェックするようにしましょう。</span></strong></p>



<h2 class="wp-block-heading">まとめ</h2>



<p>Apacheで動作させるPHPのバージョンを変更する方法を紹介しました。</p>



<p>a2コマンドを活用すると、モジュールファイルを手動で配置するよりもかんたんかつ確実に操作できますので、ぜひ使ってみてください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://takabus.com/tips/859/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Apache】リバースプロキシにアクセス制限をかける方法</title>
		<link>https://takabus.com/tips/656/</link>
					<comments>https://takabus.com/tips/656/#respond</comments>
		
		<dc:creator><![CDATA[ばすにっきTips]]></dc:creator>
		<pubDate>Sun, 28 Nov 2021 07:14:21 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[Apache]]></category>
		<guid isPermaLink="false">https://takabus.com/tips/?p=656</guid>

					<description><![CDATA[Apacheで構築したリバースプロキシにIPアドレスなどのアクセス制限をかける方法を紹介します。]]></description>
										<content:encoded><![CDATA[
<p>Apacheで構築したリバースプロキシにIPアドレスやBASIC認証などのアクセス制限をかける方法を紹介します。</p>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a href="https://takabus.com/tips/647/" title="Apacheでリバースプロキシを構築してみよう！nginxよりかんたんかも！？" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img decoding="async" width="160" height="90" src="https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-160x90.png 160w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-120x68.png 120w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-320x180.png 320w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-374x210.png 374w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">Apacheでリバースプロキシを構築してみよう！nginxよりかんたんかも！？</div><div class="blogcard-snippet internal-blogcard-snippet">Apache2.4にリバースプロキシを導入する方法を紹介していきます。すでにApacheでWebサーバーを運用している場合は、サクッとリバースプロキシを導入することができます。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://takabus.com/tips" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">takabus.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2021.11.28</div></div></div></div></a>
</div>



<h2 class="wp-block-heading" id="proxyディレクティブは動作しない">Proxyディレクティブは動作しない！</h2>



<p>Apacheの公式ドキュメントを見ると、Proxyディレクティブを使うように記載されています。<span class="marker-under">しかし、実際にやってみると、Proxyディレクティブではアクセス制限がかかりませんでした。</span></p>




<a rel="noopener" href="http://httpd.apache.org/docs/2.4/ja/mod/mod_proxy.html" title="mod_proxy - Apache HTTP &#12469;&#12540;&#12496; &#12496;&#12540;&#12472;&#12519;&#12531; 2.4" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Fhttpd.apache.org%2Fdocs%2F2.4%2Fja%2Fmod%2Fmod_proxy.html?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">mod_proxy - Apache HTTP &#12469;&#12540;&#12496; &#12496;&#12540;&#12472;&#12519;&#12531; 2.4</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://httpd.apache.org/docs/2.4/ja/mod/mod_proxy.html" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">httpd.apache.org</div></div></div></div></a>



<h2 class="wp-block-heading" id="設定方法">設定方法</h2>



<p><strong><span class="marker-under"><span class="bold-red">Locationタグ</span>を使って、リバースプロキシにアクセス制限をかけることができます。</span></strong></p>



<p>たとえば、</p>



<ul><li><strong>/fuwaへのアクセスをhttp://192.168.1.1:1337にプロキシ</strong></li><li><strong>/fuwaへのアクセスはすべて許可</strong></li><li><strong>/fuwa/chanへのアクセスは192.168から始まるIPアドレスに制限</strong></li></ul>



<p>としたいときなら、以下のようになります。なお、Apacheのバージョンは2.4です。</p>



<pre class="wp-block-code"><code>&lt;VirtualHost *>
    ProxyRequests Off
    ProxyPass /fuwa http://192.168.1.1:1337
    ProxyPassReverse /fuwa http://192.168.1.1:1337
    &lt;Location "/fuwa">
            Require all granted
    &lt;/Location>
    &lt;Location "/fuwa/chan">
            Require ip 192.168.1
    &lt;/Location>
&lt;/VirtualHost></code></pre>



<p>Locationディレクティブを使うことで、リバースプロキシでもアクセス制限をかけることができます。もちろん、BASIC認証やDigest認証といったことも対応できます。</p>



<h2 class="wp-block-heading" id="まとめ">まとめ</h2>



<p>Locationディレクティブを使用すれば、リバースプロキシについてもアクセス制限をかけることができます。もちろんBASIC認証など、ほかの方式のアクセス制限も使用できます。</p>



<p>ぜひお試しください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://takabus.com/tips/656/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Apacheでリバースプロキシを構築してみよう！nginxよりかんたんかも！？</title>
		<link>https://takabus.com/tips/647/</link>
					<comments>https://takabus.com/tips/647/#respond</comments>
		
		<dc:creator><![CDATA[ばすにっきTips]]></dc:creator>
		<pubDate>Sun, 28 Nov 2021 07:03:09 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[Apache]]></category>
		<guid isPermaLink="false">https://takabus.com/tips/?p=647</guid>

					<description><![CDATA[Apache2.4にリバースプロキシを導入する方法を紹介していきます。すでにApacheでWebサーバーを運用している場合は、サクッとリバースプロキシを導入することができます。]]></description>
										<content:encoded><![CDATA[
<p>Strapiなどのバックエンドをインターネット上から利用できるようにするには、<span class="red">リバースプロキシ</span>と呼ばれるサーバーを構築する必要があります。</p>



<p>最近ではnginxで構築されることが多いようですが、<span class="red">Apacheでもモジュールを使うことでかんたんに構築することができます。</span></p>



<p><span class="marker-under"><strong>特にすでにApacheでWebサーバーを運用している場合は、<span class="red">サクッ</span>とリバースプロキシを導入することができますので、<span class="red">nginxよりもおすすめ</span>です。</strong></span></p>



<p>当記事では、Debian（ラズパイ）に構築したApache2.4にリバースプロキシを導入する方法を紹介していきます。もちろんラズパイのみならず、通常のPCサーバーであっても同様にセットアップできますので、ご安心ください。</p>



<h2 class="wp-block-heading" id="モジュールの有効化">モジュールの有効化</h2>



<p>Apacheでリバースプロキシを構築するには、<span class="red"><strong>proxyモジュール</strong></span>と<span class="red"><strong>proxy_httpモジュール</strong></span>を有効にする必要があります。</p>



<p>シンボリックリンクを使用して追加する方法もありますが、ほとんどの環境では、<span class="red"><strong>a2enmodコマンド</strong></span>により対話的にモジュールを有効化できます。</p>



<p>コマンドを使ったほうがかんたんですので、ここでは<strong>a2enmodコマンド</strong>を使ってモジュールを有効にしてみます。</p>



<pre class="wp-block-code"><code>$ sudo a2enmod
Your choices are: access_compat actions alias allowmethods asis auth_basic auth_digest auth_form authn_anon authn_core authn_dbd authn_dbm authn_file authn_socache authnz_fcgi authnz_ldap authz_core authz_dbd authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex brotli buffer cache cache_disk cache_socache cern_meta cgi cgid charset_lite data dav dav_fs dav_lock dbd deflate dialup dir dump_io echo env expires ext_filter file_cache filter headers heartbeat heartmonitor http2 ident imagemap include info lbmethod_bybusyness lbmethod_byrequests lbmethod_bytraffic lbmethod_heartbeat ldap log_debug log_forensic lua macro md mime mime_magic mpm_event mpm_prefork mpm_worker negotiation php7.2 php7.3 proxy proxy_ajp proxy_balancer proxy_connect proxy_express proxy_fcgi proxy_fdpass proxy_ftp proxy_hcheck proxy_html proxy_http proxy_http2 proxy_scgi proxy_uwsgi proxy_wstunnel ratelimit reflector remoteip reqtimeout request rewrite sed session session_cookie session_crypto session_dbd setenvif slotmem_plain slotmem_shm socache_dbm socache_memcache socache_shmcb speling ssl status substitute suexec unique_id userdir usertrack vhost_alias xml2enc
<strong>Which module(s) do you want to enable (wildcards ok)?</strong></code></pre>



<p>a2enmodコマンドを実行すると、利用できるモジュールの一覧が表示されます。<strong><span class="marker-under">proxyとproxy_http</span></strong>があることを確認し、有効にします。</p>



<pre class="wp-block-code"><code>Which module(s) do you want to enable (wildcards ok)?
<strong>proxy</strong> <strong>proxy_http</strong>
Enabling module proxy.
Enabling module proxy_http.
To activate the new configuration, you need to run:
  systemctl restart apache2</code></pre>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-1 sbs-stn sbp-l sbis-cb cf block-box"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://takabus.com/tips/wp-content/uploads/2021/09/man-150x150.png" alt="" class="speech-icon-image"/></figure><div class="speech-name"></div></div><div class="speech-balloon">
<p><span class="red">proxyモジュールは単独では動作しません。</span>プロトコルごとに対応するモジュールが必要となります。</p>



<p>例えば、HTTP通信（HTTPS通信）をリバースプロキシするには、proxy_httpモジュールも必要です。FTPもリバースプロキシしたい場合は、proxy_ftpも必要となります。</p>
</div></div>



<p>モジュールを有効にするため、Apacheの再起動を推奨されますが、ここでは再起動せずに、設定まで済ませてから再起動することにします。</p>



<h2 class="wp-block-heading" id="リバースプロキシの設定">リバースプロキシの設定</h2>



<p>モジュールの有効化を行ったら、リバースプロキシの設定を行います。</p>



<p>ここでは例として、<span class="marker-under"><span class="blue"><strong>/api</strong></span>へのアクセスを<span class="red"><strong>http://test.lc:1337</strong></span>に転送</span>するようにしてみます。</p>



<p>Apacheの設定ファイルを開き、リバースプロキシを適用したいバーチャルホストまで移動しましょう。そして以下のように設定を追加します。</p>



<pre class="wp-block-code"><code>&lt;VirtualHost *:443&gt;
  ServerName hoge.com
  DocumentRoot /var/www/html
  &lt;Directory "/var/www/html"&gt;
    中略
  &lt;/Directory&gt;
<strong>  # リバースプロキシの設定
<span class="bold-red">  ProxyRequests Off</span>
  <span class="red">ProxyPass /api http://test.lc:1337
  ProxyPassReverse /api http://test.lc:1337</span></strong>
&lt;/VirtualHost&gt;</code></pre>



<div class="wp-block-cocoon-blocks-micro-balloon-2 micro-balloon micro-top mc-circle micro-copy has-background has-orange-background-color"><span class="micro-balloon-content micro-content"><span class="micro-balloon-icon micro-icon fab-pencil"></span>解説</span></div>



<p>設定内容について解説します。</p>



<ul><li>ProxyRequestsは、フォワードプロキシを使用するかどうかを示すものです。リバースプロキシではOffにしておきます。<span class="red"><span class="marker-under"><strong>不用意にONにすると、外部から踏み台にされる可能性があり、危険です。</strong></span></span>注意しましょう。</li><li>ProxyPassとProxyPassReverseにプロキシしたいパスとプロキシ先のアドレスを指定しておきます。基本的にはどちらも同じ内容を設定しておけばOKです。</li><li>ProxyPassReverseを指定することにより、ヘッダーの情報も自動的に変換してくれるので、リダイレクトなどが発生したときでもエラーとなることを防いでくれます。</li></ul>



<p>基本的に上記3行を追加するだけで、リバースプロキシを構築することができます。とてもかんたんです。</p>



<p>最後にApacheを再起動しましょう。</p>



<pre class="wp-block-code"><code>$sudo systemctl restart apache2</code></pre>



<p>実際にアクセスできるか確認してみてください。</p>



<h2 class="wp-block-heading" id="まとめ">まとめ</h2>



<p>いかがでしたか？意外とかんたんに設定できましたよね。</p>



<p>最近はDockerなどでサービスごとにWebサーバー（ポート）を立てるという方式が流行っており、リバースプロキシもなくてはならない存在となっています。</p>



<p>多くの場合はnginxで構築されるリバースプロキシですが、すでにApacheを使っている環境であれば、モジュールを追加することで、かんたんにリバースプロキシを導入することができます。</p>



<p>ぜひお試しください。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box has-border-color has-amber-border-color"><div class="label-box-label block-box-label box-label fab-thumbs-up"><span class="label-box-label-text block-box-label-text box-label-text">あわせて読みたい！</span></div><div class="label-box-content block-box-content box-content">
<p>Apacheで構築したリバースプロキシにIPアドレスやBASIC認証による<span class="red">アクセス制限</span>をかける方法については、こちらの記事をご覧ください。</p>



<figure class="wp-block-embed is-type-wp-embed is-provider-ばすにっきtips wp-block-embed-ばすにっきtips"><div class="wp-block-embed__wrapper">

<a href="https://takabus.com/tips/656/" title="【Apache】リバースプロキシにアクセス制限をかける方法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-160x90.png 160w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-120x68.png 120w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-320x180.png 320w, https://takabus.com/tips/wp-content/uploads/2021/10/apacheロゴ-374x210.png 374w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Apache】リバースプロキシにアクセス制限をかける方法</div><div class="blogcard-snippet internal-blogcard-snippet">Apacheで構築したリバースプロキシにIPアドレスなどのアクセス制限をかける方法を紹介します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://takabus.com/tips" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">takabus.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2021.11.28</div></div></div></div></a>
</div></figure>
</div></div>
]]></content:encoded>
					
					<wfw:commentRss>https://takabus.com/tips/647/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Apacheのインデックスページをレスポンシブ対応させる方法</title>
		<link>https://takabus.com/tips/357/</link>
					<comments>https://takabus.com/tips/357/#respond</comments>
		
		<dc:creator><![CDATA[ばすにっきTips]]></dc:creator>
		<pubDate>Thu, 07 Oct 2021 03:14:17 +0000</pubDate>
				<category><![CDATA[サーバー]]></category>
		<category><![CDATA[Apache]]></category>
		<guid isPermaLink="false">https://takabus.com/tips/?p=357</guid>

					<description><![CDATA[ApacheのIndexesをレスポンシブ対応させる方法を紹介します。]]></description>
										<content:encoded><![CDATA[
<p>ApacheのIndexesをレスポンシブ対応させる方法を紹介します。</p>



<p>Apacheには、index.htmlがないときにファイル一覧を表示させる機能があります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="719" height="393" src="https://takabus.com/tips/wp-content/uploads/2021/10/image-20.png" alt="" class="wp-image-358" srcset="https://takabus.com/tips/wp-content/uploads/2021/10/image-20.png 719w, https://takabus.com/tips/wp-content/uploads/2021/10/image-20-300x164.png 300w" sizes="(max-width: 719px) 100vw, 719px" /></figure>



<p><strong>mod_autoindex</strong>モジュールの<strong><span class="red">「Indexes」</span></strong>という機能ですが、<span class="marker-under"><strong>デフォルトではレスポンシブ対応がされておらず、スマホで見ると文字が小さくなってしまいます。</strong></span></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://takabus.com/tips/wp-content/uploads/2021/10/image-21.png" alt="" class="wp-image-359" width="261" height="419" srcset="https://takabus.com/tips/wp-content/uploads/2021/10/image-21.png 381w, https://takabus.com/tips/wp-content/uploads/2021/10/image-21-187x300.png 187w" sizes="(max-width: 261px) 100vw, 261px" /><figcaption>文字が小さくなってしまい、大変使いづらい</figcaption></figure>



<p>当記事ではこのインデックスページをレスポンシブ対応させ、スマホでも見やすくする方法を紹介します。</p>



<h2 class="wp-block-heading">設定</h2>



<p><strong><span class="marker-under">.htaccessを作成し、以下の設定を記述します。</span></strong></p>



<pre class="wp-block-code"><code>&lt;IfModule mod_autoindex.c>
    IndexHeadInsert '&lt;meta charset="UTF-8">&lt;meta name="viewport" content="width=device-width, initial-scale=1.0">&lt;meta http-equiv="X-UA-Compatible" content="ie=edge">&lt;style>body{font-family: sans-serif;}&lt;/style>'
&lt;/IfModule></code></pre>



<p><span class="bold-red">IndexHeadInsert</span>オプションを設定すると、headタグ内に任意の文字列を追加することができます。</p>



<p>ここでレスポンシブ対応のタグを挿入することにより、スマホでみたときにもサイズが最適化されるようになります。</p>



<h2 class="wp-block-heading">結果</h2>



<p>対処後は以下のようになりました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="379" height="607" src="https://takabus.com/tips/wp-content/uploads/2021/10/image-22.png" alt="" class="wp-image-360" srcset="https://takabus.com/tips/wp-content/uploads/2021/10/image-22.png 379w, https://takabus.com/tips/wp-content/uploads/2021/10/image-22-187x300.png 187w" sizes="(max-width: 379px) 100vw, 379px" /></figure>



<p>ちゃんとスクリーンに最適化されて表示されています。これならつかいやすい！</p>
]]></content:encoded>
					
					<wfw:commentRss>https://takabus.com/tips/357/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
