<?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 | じじぃの引出し</title>
	<atom:link href="https://www.kazuban.com/blog/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.kazuban.com/blog</link>
	<description>なにかしら、皆さんの参考になれば幸いです！</description>
	<lastBuildDate>Mon, 22 Dec 2025 23:11:08 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.kazuban.com/blog/wp-content/uploads/2020/05/cropped-ICON-1-32x32.png</url>
	<title>apache | じじぃの引出し</title>
	<link>https://www.kazuban.com/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ubuntu24.04LTSでWorsPressを動作させる。Apache2のインストールと設定</title>
		<link>https://www.kazuban.com/blog/ubuntu24-04lts-apache2/</link>
		
		<dc:creator><![CDATA[kazuban]]></dc:creator>
		<pubDate>Sat, 29 Jun 2024 01:48:19 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux (CentOS、Rocky、Ubuntu)]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ubuntu24]]></category>
		<guid isPermaLink="false">https://www.kazuban.com/blog/?p=8778</guid>

					<description><![CDATA[「centos」と「ubuntu」は「RedHat系」と「Debian系」で派生元のディストリビューションが違うため同じLinuxの一種であっても、相違点は多いです。特に、操作してみて「Apache」の動作コマンドや設定 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>「centos」と「ubuntu」は「RedHat系」と「Debian系」で派生元のディストリビューションが違うため同じLinuxの一種であっても、相違点は多いです。<br>特に、操作してみて「Apache」の動作コマンドや設定ファイルの場所やファイル構成もかなり違っています。</p>



<p>「ubuntu」のapache は「apache2」パッケージで提供されているようですが、名前の違いだけではなく、設定作法が「centos」はかなり違っています。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Apache2インストール</a></li><li><a href="#toc2" tabindex="0">firewalld に許可</a></li><li><a href="#toc3" tabindex="0">apache2 設定作法</a></li><li><a href="#toc4" tabindex="0">apache2 のディレクトリ設定変更</a></li><li><a href="#toc5" tabindex="0">apache2 が作業するユーザーとグループの変更</a></li><li><a href="#toc6" tabindex="0">ドキュメントルートディレクトリの作成</a></li><li><a href="#toc7" tabindex="0">セキュリティ対策</a><ol><li><a href="#toc8" tabindex="0">ICONページ一覧が表示されないようにする</a></li><li><a href="#toc9" tabindex="0">Apacheバージョン情報を隠す</a></li><li><a href="#toc10" tabindex="0">X-Frame-Optionsヘッダ設定</a></li><li><a href="#toc11" tabindex="0">ドキュメントルートにindex.htmlを作成</a></li><li><a href="#toc12" tabindex="0">CGIスクリプトを利用する</a></li></ol></li><li><a href="#toc13" tabindex="0">apache2設定終了</a></li><li><a href="#toc14" tabindex="0">Ubuntu24.04LTSでWordPressを構築する記事一覧</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Apache2インストール</span></h2>



<p>「RockyLinux9」へのインストールは、<a href="https://www.kazuban.com/blog/rokeylinux9-3-apache/">こちらで紹介しています</a>　ので参考にしてください。<br>「ubuntu」は「apt install apache2」でインストールします</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-c5053c460f344e51662b1bd9f52e7d61"><code>$ sudo apt update
$ sudo apt upgrade
$ sudo apt install apache2</code></pre>



<p>「ubuntu」は、「apt」でインストールすると、自動的に起動設定が終了しているようですね。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-fa543d79d8634630e066f3c6fdbde6c6"><code>$ systemctl status  apache2
<span class="bold-green">●</span> apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; <span class="bold-green">enabled</span>; preset: <span class="bold-green">enabled</span>)
     Active: active (running) since Sat 2024-06-20 11:03:54 JST; 9min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 73404 (apache2)
      Tasks: 55 (limit: 9342)
     Memory: 5.6M (peak: 6.8M)
        CPU: 108ms
     CGroup: /system.slice/apache2.service
             ├─73404 /usr/sbin/apache2 -k start
             ├─73406 /usr/sbin/apache2 -k start
             └─73407 /usr/sbin/apache2 -k start
$ systemctl is-enabled apache2
enabled</code></pre>



<h2 class="wp-block-heading"><span id="toc2">firewalld に許可</span></h2>



<p>前回、ファイヤーウォールは、「firewalld」に切り替えたので「apach2」にも、<a href="https://www.kazuban.com/blog/rokeylinux9-3-apache/#toc4">こちらを参考に</a>、http と https を許可しておきます。<br>これで、Webブラウザのアドレスバーに、IPアドレスを打ち込むとデフォルトページが表示されるはずです。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="717" height="640" src="https://www.kazuban.com/blog/wp-content/uploads/2024/05/apache2-default-page.png" alt="" class="wp-image-8785" srcset="https://www.kazuban.com/blog/wp-content/uploads/2024/05/apache2-default-page.png 717w, https://www.kazuban.com/blog/wp-content/uploads/2024/05/apache2-default-page-500x446.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2024/05/apache2-default-page-300x268.png 300w" sizes="(max-width: 717px) 100vw, 717px" /></figure>



<h2 class="wp-block-heading"><span id="toc3">apache2 設定作法</span></h2>



<p>「ubuntu」では、「ＣentOS系」とは設定作法がかなり違うようです。<br>インストール直後の「apach2設定ディレクトリ」を確認してみると</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-a16da32b670e4773ebb71f2997f38118"><code>/etc/apache2/
├── apache2.conf
├── conf-available
│&nbsp;&nbsp; ├── charset.conf
│&nbsp;&nbsp; ├── ・
├── conf-enabled
│&nbsp;&nbsp; ├── charset.conf -&gt; ../conf-available/charset.conf
│&nbsp;&nbsp; ├── ・
├── envvars
├── magic
├── mods-available
│&nbsp;&nbsp; ├── access_compat.load
│&nbsp;&nbsp; ├── ・
├── mods-enabled
│&nbsp;&nbsp; ├── access_compat.load -&gt; ../mods-available/access_compat.load
│&nbsp;&nbsp; ├── ・
├── ports.conf
├── sites-available
│&nbsp;&nbsp; ├── 000-default.conf
│&nbsp;&nbsp; └── default-ssl.conf
└── sites-enabled
    └── 000-default.conf -&gt; ../sites-available/000-default.conf</code></pre>



<p>途中、省略していますが「/etc/apache2」直下には<br>「apache2.conf」「magic」「envvars」「ports.conf」のファイルがあり<br>さらに「conf-*」「mods-*」「sites-*」で、<br>それぞれ「<strong>available</strong>」「<strong>enabled</strong>」が付いた名前のディレクトリがあります。</p>



<div class="wp-block-cocoon-blocks-blank-box-1 blank-box block-box">
<ul class="wp-block-list">
<li>apache2.conf
<ul class="wp-block-list">
<li>httpd.conf と同じで、Apacheサーバーのメイン設定ファイル</li>



<li>他の構成ファイルや「enabled」ディレクトリ内のファイルを組み込む</li>
</ul>
</li>



<li>ports.conf
<ul class="wp-block-list">
<li>リスニングポートの設定ファイル。メイン設定ファイルに組み込まれる</li>
</ul>
</li>



<li>envvars
<ul class="wp-block-list">
<li>環境変数の設定ファイル</li>
</ul>
</li>



<li>magic
<ul class="wp-block-list">
<li>MIME タイプ</li>
</ul>
</li>



<li>conf-*
<ul class="wp-block-list">
<li>バーチャルホストに属さない、利用可能な設定ファイルが保存される。</li>



<li>RedHat系の/etc/httpd/conf.d 内のファイルはここへ保存する。</li>
</ul>
</li>



<li>mods-*
<ul class="wp-block-list">
<li>モジュール構成ファイルが保存される。</li>
</ul>
</li>



<li>sites-*
<ul class="wp-block-list">
<li>バーチャルホストの設定ファイルが保存される</li>
</ul>
</li>
</ul>
</div>



<p>独特なのは、「<strong>*-available</strong>」と「<strong>*-enabled</strong>」のディレクトリです。<br>基本的には、<span class="marker-under-red">「<strong>*-enabled</strong>」内のファイルだけが組み込まれます</span>が、「<strong>*-enabled</strong>」内のファイルは、<span class="marker-under">「<strong>*-available</strong>」内のファイルのシンボリックリンク</span>になっています。<br>作法としては、「<strong>*-available</strong>」内に、設定ファイルを保存し、必要なファイルのみ「<strong>*-enabled</strong>」にシンボリックリンクを作成する方法です。<br>シンボリックリンク作成と削除は、専用コマンドが用意されています。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>「<strong>conf-*</strong>」用は「<strong>a2enconf</strong>」で作成。「<strong>a2disconf</strong>」で削除<br>「<strong>mods-*</strong>」用は「<strong>a2enmod</strong>」で作成。「<strong>a2dismod</strong>」で削除<br>「<strong>sites-*</strong>」用は、「<strong>a2ensite</strong>」で作成。「<strong>a2dissite</strong>」で削除</p>
</blockquote>



<h2 class="wp-block-heading"><span id="toc4">apache2 のディレクトリ設定変更</span></h2>



<p>筆者は、<a href="https://www.kazuban.com/blog/rokeylinux9-3-apache/#toc6">RockyLinux9 の設定</a>と同様の設定にします。<br>まずは、「<strong>apache2.conf</strong>」の、&lt;Directory&gt;のデフォルト設定はコメントとし<br>Rockyと同様にしました。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-b6c6ad31348a65094abe4e71e0f04d64"><code>・
・
&lt;Directory /&gt;
    AllowOverride none
    Require all denied
&lt;/Directory&gt;

&lt;Directory "<strong>/home/www</strong>"&gt;
    AllowOverride None
    # Allow open access:
    Require all granted
&lt;/Directory&gt;

&lt;Directory "<strong>/home/www/htm</strong>l"&gt;
    Options FollowSymLinks
    AllowOverride None
    Require all granted
&lt;/Directory&gt;
・
・</code></pre>



<p><br><strong>ホスト名関連</strong>は、「<strong>sites-enabled</strong>」内の「<strong>000-default.conf</strong>」で設定します。<br>上述したように、<span class="marker-under">「<strong>*-enables</strong>」は「<strong>*-available</strong>」のシンボリックリンク</span>が入っているので<span class="marker-under">どちらのファイルを編集しても同じ</span>です<br><span style="font-size: revert; font-family: var(--cocoon-default-font);">ただし、</span><span class="marker-under-red"><span style="font-size: revert; font-family: var(--cocoon-default-font);">バックアップを残す場合には</span>「<strong>*-available</strong>」のファイルをバックアップ</span>します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-494667b308831ca96041163acf20b8e1"><code>$ cd /etc/apache2/sites-<span class="bold">available/</span>
$ sudo cp -p 000-default.conf 000-default.conf.org
$ cd /etc/apache2/sites-available/
$ sudo vi ./000-default.conf
・
・
#ServerName www.example.com
　　　↓
ServerName www.hogehoge.com
・
・
ServerAdmin webmaster@localhost
　　　↓
ServerAdmin root@hogehoge.com
・
・
DocumentRoot /var/www/html
　　　↓
DocumentRoot /home/www/html
・</code></pre>



<h2 class="wp-block-heading"><span id="toc5">apache2 が作業するユーザーとグループの変更</span></h2>



<p>apache2が処理を要求する時のユーザーとグループを設定します<br>まずは、メインの設定ファイル、「/etc/apache2/apache2.conf」を覗いてみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-78da7915f5b166ffc3796d23799d6f7b"><code>$ vi /etc/apache2/apache2.conf
・
・
# These need to be set in /etc/apache2/envvars
<strong>User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}</strong>
・
・</code></pre>



<p>設定ファイルにあるように、<br><strong>${APACHE_RUN_USER}</strong><br><strong>${APACHE_RUN_GROUP}</strong><br>この二つの環境変数で設定されていて、この環境変数は、変数上記のコメントにあるように「<strong>/etc/apache2/envvars</strong>」で設定されています。<br>「ubintu」はデフォルトでは「<strong>www-data</strong>」になっていますが、私は「centos」にあわせて「<strong>apache</strong>」に変更しようと思います。<br>バックアップを取り、変更します。<br>続けて、<span class="marker-under-red">「apache」ユーザーを作成し、ホームディレクトリを「/home/www」とします。</span></p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-184d625e5eb5dc1df4b54ef67f783fd3"><code># Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
　　↓
export APACHE_RUN_USER=<strong>apache</strong>
export APACHE_RUN_GROUP=<strong>apache</strong>
　　・
　　・

$ sudo useradd -d /home/www -s /sbin/nologin apache
</code></pre>



<h2 class="wp-block-heading"><span id="toc6">ドキュメントルートディレクトリの作成</span></h2>



<p>Webに公開するコンテンツ格納ディレクトリを設定変更したので、<br>実際にそのディレクトリを作成します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-5a38e7301a807a48887faacadf019e91"><code># mkdir /home/www
# mkdir /home/www/html
# chown apache:apache /home/www/html/
# ls -la /home/www

# systemctl restart apache2</code></pre>



<h2 class="wp-block-heading"><span id="toc7">セキュリティ対策</span></h2>



<h3 class="wp-block-heading"><span id="toc8">ICONページ一覧が表示されないようにする</span></h3>



<p>ICONページ一覧の設定は、<strong>/etc/apache2/mods-enabled/alias.conf</strong>で行います。<br>設定ファイルを開いてみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-2d8931a3b3ab83f35969313fe0c15364"><code>$ vi /etc/apache2/mods-enabled/alias.conf
　　・
　　・
# We include the /icons/ alias for FancyIndexed directory listings.  If
# you do not use FancyIndexing, you may comment this out.

Alias /icons/ "/usr/share/apache2/icons/"

&lt;Directory "/usr/share/apache2/icons"&gt;
        Options FollowSymlinks
        AllowOverride None
        Require all granted
&lt;/Directory&gt;</code></pre>



<p>「ubuntu」では、「<strong>/etc/apache2/conf-enabled</strong>」のファイルをメイン設定として読み込みます。<br>ただし「<strong>conf-enabled</strong>」内のファイルは、「<strong>conf-available</strong>」内のファイルの<span class="marker-under">シンボリックリンク</span>になっているので、ファイルの<span class="marker-under-red">バックアップを取る場合には<br>「<strong>/etc/apache2/conf-available/</strong>」内のファイルをバックアップをとり編集します。</span></p>



<p>「icons」ディレクトリの設定では「Options Indexes」がないので、一覧が表示される事はないと思いますが、その下のファイルをWebブラウザで指定すると表示されます。<br>特に必要ないので全てコメントにしようと思います。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-ef851a91dca7348444d5da6ca6440a22"><code>$ cd /etc/apache2/mods-available
$ sudo cp -p alias.conf alias.conf.org
$ sudo vi alias.conf
　・
#Alias /icons/ "/usr/share/apache2/icons/"

#&lt;Directory "/usr/share/apache2/icons"&gt;
#        Options FollowSymlinks
#        AllowOverride None
#        Require all granted
#&lt;/Directory&gt;
　・
$ sudo systemctl restart apache2</code></pre>



<h3 class="wp-block-heading"><span id="toc9">Apacheバージョン情報を隠す</span></h3>



<p><a href="https://www.kazuban.com/blog/rokeylinux9-3-apache/#toc11">こちらと同様に</a>、バージョン情報とOSの情報を隠します。<br>「telnet」で確認します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-cd774acf7726253b5af9d0798a6dae56"><code>$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1</strong>        &lt;-------入力
<strong>host:localhost </strong>           &lt;-------入力
                          &lt;-------「Ebter」キー
HTTP/1.1 200 OK
Date: Sun, 23 Jun 2024 09:16:28 GMT
Server:<strong> Apache/2.4.58 (Ubuntu)</strong> &lt;---- Apacheバージョン情報
Allow: GET,POST,OPTIONS,HEAD
Content-Length: 0
Content-Type: text/html

Connection closed by foreign host.</code></pre>



<p>「/etc/apache2/conf-<strong>enabled</strong>」の「security.conf」で行いますが、上記と同様に<br>「/etc/apache2/conf-<strong>available</strong>/security.conf」のバックアップをとり編集します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-06de9bddb5f5f9ff8c94abc8d006c69a"><code>$ cd /etc/apache2/conf-available
$ sudo cp -p security.conf security.conf.org
$ sudo vi ./security.conf

#ServerTokens Minimal
ServerTokens OS
#ServerTokens Full
　　↓
#ServerTokens Minimal
<strong>#</strong>ServerTokens OS
#ServerTokens Full
ServerTokens <strong>ProductOnly</strong>

<strong>#</strong>ServerSignature Off
ServerSignature <strong>On</strong>
　　↓
ServerSignature <strong>Off</strong>
<strong>#</strong>ServerSignature On

$ sudo systemctl restart apache2 
</code></pre>



<p>telnetで再確認</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-bb63c7528fea204145b8dd87b411a8b5"><code>$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1</strong>        &lt;-------入力
<strong>host:localhost</strong>            &lt;-------入力
                          &lt;-------「Ebter」キー
HTTP/1.1 200 OK
Date: Sun, 23 Jun 2024 09:18:18 GMT
Server: <strong>Apache</strong> 　　&lt;---- Apacheバージョン情報は消えた
Allow: GET,POST,OPTIONS,HEAD
Content-Length: 0
Content-Type: text/html

Connection closed by foreign host.</code></pre>



<h3 class="wp-block-heading"><span id="toc10">X-Frame-Optionsヘッダ設定</span></h3>



<p><a href="https://licensecounter.jp/symantec/blog/detail28/#cnt3">クリックジャッキングを防ぐための対策に有効</a>だと言う事なので、<br>X-Frame-Optionsヘッダ設定をしておこうと思います。<br>「mod_headers」機能が有効になっているかの確認をします。<br>有効なモジュール構成は、「<strong>/etc/apache2/mods-enabled</strong>」に登録されているはずですが、なさそうです。<br>「<strong>*-enabled</strong>」はシンボリックが登録されているだけなので、「<strong>*-available</strong>」内を調べてみます。<br>「<strong>/etc/apache2/mods-available</strong>」に「<strong>headers.load</strong>」が保存されていたので、有効にすることで使用できるようになりますが、設定ファイルも必要です。<br><span class="marker-under-red">X-FRAME-OPTIONSオプションを追加する設定ファイル「<strong>headers.conf</strong>」を作成します。</span><br>次にこのファイルのシンボリックリンクを「*-enabled」に作成しますが、作成するには、「<strong>a2enmod</strong>」コマンドでおこないます。<br>リンクが作成できたら、「telnet」で確認してみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-aa5618a3600cfd785620b34278341bb3"><code>$ cd /etc/apache2/mods-available
$ sudo vi headers.conf
　　・
#--- 2024.06.23 hogehoge
Header append X-FRAME-OPTIONS "SAMEORIGIN"
　　・

$ sudo <strong>a2enmod</strong> headers
Enabling module headers.
To activate the new configuration, you need to run:
  systemctl restart apache2

$ sudo systemctl restart apache2
$ telnet localhost 80　　　&lt;---- telnetで確認
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1</strong>        &lt;-------入力
<strong>host:localhost</strong>            &lt;-------入力
                          &lt;-------「Ebter」キー
HTTP/1.1 200 OK
Date: Sun, 23 Jun 2024 09:23:57 GMT
Server: Apache
Allow: GET,POST,OPTIONS,HEAD
<strong>X-FRAME-OPTIONS: SAMEORIGIN</strong>    &lt;---- 有効確認
Content-Length: 0
Content-Type: text/html

Connection closed by foreign host.
</code></pre>



<h3 class="wp-block-heading"><span id="toc11">ドキュメントルートにindex.htmlを作成</span></h3>



<p>デフォルトのトップページ「index.html」を作成しておきます。<br>保存後、ファイルの所有者を「Apache」のユーザー「apache」に変更し再起動しておきます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-b78413d79599a5fdfbd04c6f5ae8c632"><code>$ cd /home/www/html/
# vi ./index.html 
・
&lt;html&gt;
  &lt;body&gt;
    &lt;h1&gt;This website is currently under maintenance.&lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;
・
# chown -R apache:apache /home/www/html/
# systemctl restart apache2</code></pre>



<h3 class="wp-block-heading"><span id="toc12">CGIスクリプトを利用する</span></h3>



<p>もし必要であえば、CGIスクリプトを利用できるようにしておきます<br>「a2enmod cgid」で、「cgid」モジュールを有効にし「serve-cgi-bin.conf」に動作させたいCGIスクリプトを登録するディレクトリの設定を行い、そのディレクトリがなければ作成します。<br>「AddHandler cgi-script .cgi」では、「.cgi」拡張子のみCGIスクリプトとして使用できます</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-ac34e58e7c184851dbd6d40451a3629c"><code>$ sudo a2enmod cgid
Enabling module cgid.
To activate the new configuration, you need to run:
  systemctl restart apache2

$ cd conf-available/
$ sudo cp -p serve-cgi-bin.conf serve-cgi-bin.conf.org
$ sudo vi ./serve-cgi-bin.conf

&lt;IfModule mod_alias.c&gt;
        &lt;IfModule mod_cgi.c&gt;
                Define ENABLE_USR_LIB_CGI_BIN
        &lt;/IfModule&gt;

        &lt;IfModule mod_cgid.c&gt;
                Define ENABLE_USR_LIB_CGI_BIN
        &lt;/IfModule&gt;

        &lt;IfDefine ENABLE_USR_LIB_CGI_BIN&gt;
                #AddHandler cgi-script .cgi
                &lt;Directory /home/www/html/script&gt;
                        AllowOverride None
                        Options ExecCGI FollowSymLinks
                        Order allow,deny
                        Allow from all
                        AddHandler cgi-script .cgi
                &lt;/Directory&gt;
        &lt;/IfDefine&gt;
&lt;/IfModule&gt;

$ sudo mkdir /home/www/html/script
$ sudo systemctl restart apache2

</code></pre>



<h2 class="wp-block-heading"><span id="toc13">apache2設定終了</span></h2>



<p>「apache」の設定は、「RHEL系」とはかなり違っていて、結構時間がかかりました。</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading"><span id="toc14">Ubuntu24.04LTSでWordPressを構築する記事一覧</span></h2>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><img decoding="async" width="1024" height="773" src="https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop.png" alt="" class="wp-image-8987" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop.png 1024w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop-500x377.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop-800x604.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop-300x226.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/Desktop-768x580.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/ubuntu24-04lts-install">インストール・SSH・ファイヤーウォール</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-green-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:4px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><img decoding="async" width="948" height="600" src="https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2.png" alt="" class="wp-image-8990" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2.png 948w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2-500x316.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2-800x506.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2-300x190.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/apache2-768x486.png 768w" sizes="(max-width: 948px) 100vw, 948px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p>Apache2のインストールと設定</p>
</div>
</div>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="750" height="564" src="https://www.kazuban.com/blog/wp-content/uploads/2024/06/php-mariadb-ssl.png" alt="" class="wp-image-8995" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2024/06/php-mariadb-ssl.png 750w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/php-mariadb-ssl-500x376.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/php-mariadb-ssl-300x226.png 300w" sizes="(max-width: 750px) 100vw, 750px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/ssl-php-mariadb">SSL、PHP、MariaDB、Let’s Encrypt証明書でhttps化</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-green-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:4px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="684" height="430" src="https://www.kazuban.com/blog/wp-content/uploads/2024/06/wordpress.png" alt="" class="wp-image-8999" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2024/06/wordpress.png 684w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/wordpress-500x314.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2024/06/wordpress-300x189.png 300w" sizes="(max-width: 684px) 100vw, 684px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/wordpewss-ubuntu">WordPress インストール、バックアップと復元</a></p>
</div>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>RockyLinux9.３で自宅サーバーを再構築V04・LAMPの「A」、Apache編</title>
		<link>https://www.kazuban.com/blog/rokeylinux9-3-apache/</link>
		
		<dc:creator><![CDATA[kazuban]]></dc:creator>
		<pubDate>Sat, 06 Jan 2024 07:28:06 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux (CentOS、Rocky、Ubuntu)]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[RockyLinux9.3]]></category>
		<category><![CDATA[自宅サーバー]]></category>
		<guid isPermaLink="false">https://www.kazuban.com/blog/?p=8444</guid>

					<description><![CDATA[LAMP とは、Linux、Apache HTTP Server、MySQL、PHP（またはPerl、Python）の頭文字を取った略称です。WordPressなど自分Web サイトの構築に適した環境です。ここまでで、あ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><strong>LAMP</strong> とは、<strong>L</strong>inux、<strong>A</strong>pache HTTP Server、<strong>M</strong>ySQL、<strong>P</strong>HP（または<strong>P</strong>erl、<strong>P</strong>ython）の頭文字を取った略称です。<br>WordPressなど自分Web サイトの構築に適した環境です。<br>ここまでで、ある程度セキュリティ対策を施したRokeyLinux9の初期設定が終わっているので<br>LAMPの「L」は終了しています。<br>今回は、LAMPの「A」のApache環境を構築していきます。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-4" checked><label class="toc-title" for="toc-checkbox-4">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Ｒemi リポジトリのインポート</a></li><li><a href="#toc2" tabindex="0">Apache（httpd）</a><ol><li><a href="#toc3" tabindex="0">httpdのインストール</a></li><li><a href="#toc4" tabindex="0">Firewalld に許可</a></li><li><a href="#toc5" tabindex="0">Apacheの動作確認</a></li><li><a href="#toc6" tabindex="0">Apache設定ファイル・httpd.conf、変更</a></li><li><a href="#toc7" tabindex="0">ドキュメントルートディレクトリの作成</a></li><li><a href="#toc8" tabindex="0">セキュリティ対策追加</a><ol><li><a href="#toc9" tabindex="0">テストページが表示されないようにする</a></li><li><a href="#toc10" tabindex="0">telnet インストール</a></li><li><a href="#toc11" tabindex="0">Apacheバージョン情報とＴRACEメソッドOFF</a></li><li><a href="#toc12" tabindex="0">X-Frame-Optionsヘッダ設定</a></li><li><a href="#toc13" tabindex="0">ドキュメントルートにindex.htmlを作成</a></li></ol></li></ol></li><li><a href="#toc14" tabindex="0">Let&#8217;s Encrypt証明書でhttps化</a><ol><li><a href="#toc15" tabindex="0">ファイヤーウォール設定の確認</a></li><li><a href="#toc16" tabindex="0">sslモジュールの確認</a></li><li><a href="#toc17" tabindex="0">Certbot クライアントのインストール</a></li><li><a href="#toc18" tabindex="0">certbot で証明書発行</a></li><li><a href="#toc19" tabindex="0">SSLサーバ証明書の設定</a></li><li><a href="#toc20" tabindex="0">https:// でのアクセス確認</a></li></ol></li><li><a href="#toc21" tabindex="0">ApacheでHTTP/2を利用する</a><ol><li><a href="#toc22" tabindex="0">eventMPMモジュールとhttp2モジュールの確認</a></li><li><a href="#toc23" tabindex="0">http2を有効にする</a></li></ol></li><li><a href="#toc24" tabindex="0">RockyLinux9.3で自宅サーバーを再構築・記事一覧</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Ｒemi リポジトリのインポート</span></h2>



<p>ApacheやPHPの最新バージョンを使用したい場合、Remi リポジトリのインストールが必要なようです。<br><a href="https://www.linuxcapable.com/how-to-install-php-on-rocky-linux/">https://www.linuxcapable.com/how-to-install-php-on-rocky-linux/</a><br>ここを参考にインストールしてみようと思いますが、Remi の前に、「crb」を有効にし「epel」のインストールが必要なようです。<br>その後、「remi」をインストールします。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-c00e88e50bdd3c615b77a64ebf4633a8"><code># dnf config-manager --set-enabled crb
# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
# dnf install https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm
# dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm
# dnf repolist 
repo id                           repo の名前
appstream                         Rocky Linux 9 - AppStream
baseos                            Rocky Linux 9 - BaseOS
crb                               Rocky Linux 9 - CRB
epel                              Extra Packages for Enterprise Linux 9 - x86_64
epel-cisco-openh264               Extra Packages for Enterprise Linux 9 openh264 (From Cisco) - x86_64
epel-next                         Extra Packages for Enterprise Linux 9 - Next - x86_64
extras                            Rocky Linux 9 - Extras
remi-modular                      Remi's Modular repository for Enterprise Linux 9 - x86_64
remi-safe                         Safe Remi's RPM repository for Enterprise Linux 9 - x86_64</code></pre>



<h2 class="wp-block-heading"><span id="toc2">Apache（httpd）</span></h2>



<p>このサイトでも、下記でcentOS7 にインストールしました。</p>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">

<a href="https://www.kazuban.com/blog/apache-install" title="WWWサーバーのインストール" 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="50" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache_pb-e1562415084274.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache_pb-e1562415084274.png 460w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache_pb-e1562415084274-300x93.png 300w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">WWWサーバーのインストール</div><div class="blogcard-snippet internal-blogcard-snippet">前回でリモートアクセスが可能になりましたこれで作業がだいぶ楽になりました次はいよいよ、wwwサーバを動作させ外部に発信できるようにしますApacheの導入wwwサーバは、現在は一番メジャーなApacheにします。インストールは 「yum」で 簡単にインストールできますApache関連パッケージの確認...</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://www.kazuban.com/blog" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">www.kazuban.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2019.07.07</div></div></div></div></a>
</div></figure>



<h3 class="wp-block-heading"><span id="toc3">httpdのインストール</span></h3>



<p>前回同様に「httpd」「httpd-tools」「mod_ssl」をインストールし、<br>「httpd」を起動し、サーバを再起動しても自動的に起動するように設定します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-00b4a39045be1a0af9d9f20f28f66af7"><code># dnf install httpd httpd-tools mod_ssl
# systemctl start httpd
# systemctl status httpd
<span class="green">●</span> httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
     Active: <span class="green">active (running)</span> since Tue 2024-01-02 12:47:29 JST; 16s ago
       Docs: man:httpd.service(8)
・
・
# systemctl enable httpd
# systemctl is-enabled httpd
enabled</code></pre>



<h3 class="wp-block-heading"><span id="toc4">Firewalld に許可</span></h3>



<p>前回、「ssh」接続用に管理ゾーンを新規作成しました。<br>ウェブサーバーは、全体に公開するため、ネットワークアダプタで許可している「public」ゾーンだけに「http」サービスの許可すればいいように思っていいましたが、管理ゾーンの「admin」のアドレスでも確認するので、両方に追加が必要でした。<br>さらに、後で「https」の設定を行う予定なので、こちらも許可しておきます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-4cdd1af37f9d6ba4af06a81d8aebdaff"><code># firewall-cmd --add-service=http --zone=public --permanent
# firewall-cmd --add-service=https --zone=public --permanent
# firewall-cmd --add-service=http --zone=admin --permanent
# firewall-cmd --add-service=https --zone=admin --permanent
success
# firewall-cmd --reload
# firewall-cmd --list-all --zone=public
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eno1
  sources: 
  services: dhcpv6-client<strong> http https</strong>
  ports: 
  ・
　・
# firewall-cmd --list-all --zone=admin
admin (active)
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 192.168.0.100 192.168.0.101
  services: cockpit<strong> </strong>dhcpv6-client　<strong>http https</strong> ssh
  ports: 
  ・
　・</code></pre>



<h3 class="wp-block-heading"><span id="toc5">Apacheの動作確認</span></h3>



<p>これで、Apacheのインストールと、Firewalldは終了しています。<br>自宅LAN内の他のPCのアドレスバーにサーバのIPアドレスを入力すれば、<br>テストページが表示されるはずです。<br>例えば、アドレスバーに、http://192.168.1.101（サーバアドレス）と入力して<br>テストページが表示されれば正常に動作しています</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="800" height="581" src="https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page-800x581.png" alt="" class="wp-image-8445" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page-800x581.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page-500x363.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page-300x218.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page-768x558.png 768w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/test-page.png 953w" sizes="(max-width: 800px) 100vw, 800px" /></figure>



<p>自宅から外部からのアクセスを確認するには、スマホなどのwifi設定を一旦解除し、<br><span class="marker-under">LTE接続</span>にしてブラウザのアドレスバーに自宅の<span class="marker-under">グローバルIPアドレス</span>入力で確認できます。<br>ただし、事前にゲートウェイの<span class="marker-under-red">ルータで、８０番ポートを、このサーバーのＩＰアドレスへ転送</span>するように設定しておく必要があります。<br>自宅のグローバルアドレスを知る方法はネット上に沢山あります。<br>例えば、下記サイトでも知る事ができます。<br>https://www.cman.jp/network/support/go_access.cgi<br><span class="marker-red"><strong>確認がすんだら、ルータ設定は、すぐに戻しましょう。</strong></span></p>



<h3 class="wp-block-heading"><span id="toc6">Apache設定ファイル・httpd.conf、変更</span></h3>



<ul class="wp-block-list">
<li>設定ファイルのバックアップ</li>



<li>Webサーバー管理者メールアドレスの変更</li>



<li>ホスト名の変更</li>



<li>Webサーバーが公開するファイルを格納するディレクトリ<br>容量が大きくなる事を想定し、「/home」へ変更する</li>



<li>公開ディレクトリのファイル一覧を制御させない</li>



<li>必要であれば、Webサーバがプログラムを実行するCGIの設定<br>デフォルト以外のディレクトリを使用する場合には、そのディレクトリを追加し<br>「Options」ディレクティブに「ExecCGI」機能を追加。<br>また、「AddHandler」で実行させたいスクリプトの拡張子を定義します。</li>
</ul>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-470b06807a994b4042dbf31f5dbbfcab"><code># cd /etc/httpd/conf/
# cp -p httpd.conf httpd.conf.org
# vi ./httpd.conf
・
・
ServerAdmin root@localhost
↓
ServerAdmin root@hogehoge.com
・
・
# ServerName www.example.com:80
↓
ServerName www.hogehoge.com.com:80
・
・
DocumentRoot "/var/www/html"
↓
DocumentRoot "/home/www/html"
・
・
&lt;Directory "/var/www/html"&gt;
↓
&lt;Directory "/home/www/html"&gt;
・
・
Options Indexes FollowSymLinks
↓
Options  FollowSymLinks
・
・
#----- 2024.01.04 kazu      &lt;----- CGIをデフォルト以外で使用する例
AddHandler cgi-script .cgi
&lt;Directory /home/www/html/script&gt;
  AllowOverride None
  Options ExecCGI FollowSymLinks
  Order allow,deny
  Allow from all
&lt;/Directory&gt;
・
・
</code></pre>



<h3 class="wp-block-heading"><span id="toc7">ドキュメントルートディレクトリの作成</span></h3>



<p>Webに公開するコンテンツ格納ディレクトリを設定変更したので、<br>そのディレクトリを作成します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-845f8644bf37344dd5c885bea0634d96"><code># mkdir /home/www
# mkdir /home/www/html
# mkdir /home/www/cgi-bin
# chown apache.apache /home/www/html/
# chown apache.apache /home/www/cgi-bin/
# ls -la /home/www

# httpd -t
Syntax OK</code></pre>



<h3 class="wp-block-heading"><span id="toc8">セキュリティ対策追加</span></h3>



<p>ちょっと、OSバージョンの違いもありますが、こちらを参考に設定してみました。<br><a href="https://www.rem-system.com/apache-security01/">https://www.rem-system.com/apache-security01/</a></p>



<h4 class="wp-block-heading"><span id="toc9">テストページが表示されないようにする</span></h4>



<p>テストページは、「/etc/httpd/conf.d/welcome.conf」が表示させてるみたいで<br>コメントを読むと、表示させたくないなら、「#」を付けてコメントアウトしろとあります。<br>さらに、削除しても、アップグレードで復活するとあるので、バックアップしてコメントアウトしました。<br>さらに、http://ドメイン名/icons/　でも「icon」一覧が表示されたりするので<br>こちらも、コメントアウトにしました。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-e2bdbe2845168071ba059f2351e7626b"><code># cd /etc/httpd/conf.d
# cp -p welcome.conf welcome.conf.org
# cp -p  autoindex.conf  autoindex.conf.org
# vi ./welcome.conf
・
・
#&lt;LocationMatch "^/+$"&gt;
#    Options -Indexes
#    ErrorDocument 403 /.noindex.html
#&lt;/LocationMatch&gt;

#&lt;Directory /usr/share/httpd/noindex&gt;
#    AllowOverride None
#    Require all granted
#&lt;/Directory&gt;
・
・
・
# vi autoindex.conf
・
・
#Alias /icons/ "/usr/share/httpd/icons/"
#&lt;Directory "/usr/share/httpd/icons"&gt;
#    Options Indexes MultiViews FollowSymlinks
#    AllowOverride None
#    Require all granted
#&lt;/Directory&gt;
・
・
・
# systemctl restart httpd</code></pre>



<p>httpd を再起動すると、表示されなくなりました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="474" height="120" src="https://www.kazuban.com/blog/wp-content/uploads/2023/11/forbidden_icons-e1701407255680.png" alt="" class="wp-image-8446" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/11/forbidden_icons-e1701407255680.png 474w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/forbidden_icons-e1701407255680-300x76.png 300w" sizes="(max-width: 474px) 100vw, 474px" /></figure>



<h4 class="wp-block-heading"><span id="toc10">telnet インストール</span></h4>



<p>「telnet」は、ネットワークを介して通信を行うソフトウェアです。<br>「telnet」を利用する事で、いろいろなポートへのアクセス確認ができます。<br>これから、HTTPの状況を確認するのに使用するので、まずはインストールします。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-e14adfa746c331d5b3be41ee9c72b5a8"><code># dnf install telnet</code></pre>



<h4 class="wp-block-heading"><span id="toc11">Apacheバージョン情報とＴRACEメソッドOFF</span></h4>



<p>現在の状態を調べてみます。</p>



<pre class="wp-block-code nohighlight has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-33fbe0c8b3c48eed56c68def1221603a"><code>$ telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1</strong>        &lt;-------入力
<strong>host:localhost </strong>           &lt;-------入力
                            &lt;-------「Ebter」キー
HTTP/1.1 200 OK
Date: Wed, 02 Jan 2024 11:30:54 GMT
Server: <strong>Apache/2.4.57 (Rocky Linux) OpenSSL/3.0.7</strong> &lt;---- Apacheバージョン情報
Allow: OPTIONS,HEAD,GET,POST,<strong>TRACE</strong>
Content-Length: 0
Content-Type: httpd/unix-directory

Connection closed by foreign host.</code></pre>



<p>「 Escape character is &#8216;^]&#8217;. 」の入力待ち後に、<br><span class="marker-under-blue">「OPTIONS / HTTP/1.1」「host:localhost」「enter」を入力する必要があります</span>。<br>「Apache情報」と「TRACE」が有効になっているのがわかります。<br>セキュリティ的に「無効」にしたほうがいいとの事なので、無効にします。<br>「/etc/httpd/conf/httpd.conf」の最後に<br>「ServerTokens ProductOnly」<br>「ServerSignature off」<br>「TraceEnable off」を追加。<br>Apacheを再起動後、再度確認します</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-1846d7e72d7864cd5747264f035cc558"><code># vi /etc/httpd/conf/httpd.conf　&lt;------ 編集開始
・
・
##--- Hogehoge added. 2024/01/03  &lt;------ コメントで日付など残しておくと便利
ServerTokens ProductOnly      &lt;------ Apache情報設定 追加
ServerSignature off
TraceEnable off               &lt;------ TRACE無効 追加
                              &lt;------ 保存
・
# httpd -t
Syntax OK
# systemctl restart httpd    &lt;--- 再起動
# telnet localhost 80        &lt;--- telnet
Trying ::1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1  </strong>&lt;----- 入力<strong>
host:localhost</strong>       &lt;-----　入力
                       &lt;---「Enter」キー
HTTP/1.1 200 OK
Date: Wed, 03 Jan 2024 11:38:54 GMT
Server: <strong>Apache</strong>                   &lt;----- バージョン情報なし
Allow:<strong> OPTIONS,HEAD,GET,POST</strong>   &lt;--------- TRACE が消えている
Content-Length: 0
Content-Type: httpd/unix-directory

Connection closed by foreign host.</code></pre>



<h4 class="wp-block-heading"><span id="toc12">X-Frame-Optionsヘッダ設定</span></h4>



<p>「mod_headers」機能が有効になっているかの確認をします。<br>「/etc/httpd/conf.modules.d/00-base.conf」で記載があるか？有効か？の確認をします。<br>記載があり、コメントになっていなければ、有効になっています。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-59dab55367dbca6dcfd71707df092c52"><code># cat /etc/httpd/conf.modules.d/00-base.conf | grep mod_headers.so
<strong>LoadModule headers_module modules/mod_headers.so</strong></code></pre>



<p>「/etc/httpd/conf/httpd.conf」の最後に<br>「 Header append X-FRAME-OPTIONS &#8220;SAMEORIGIN&#8221;  」<br>を追加し、Apacheを再起動し、telnetで確認します</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-9e8439220ec8aec60d0ba24e68410ff7"><code># vi /etc/httpd/conf/httpd.conf　&lt;------ 編集開始
・
・
##--- Hogehoge added. 2024/01/03  &lt;----- 情報としてコメントを付けおく
ServerTokens ProductOnly
ServerSignature off
TraceEnable off
<strong>Header append X-FRAME-OPTIONS "SAMEORIGIN"</strong>　&lt;----- 追加
                                                 &lt;----- 保存
・
# systemctl restart httpd    &lt;---- 再起動
# telnet localhost 80        &lt;---- telnet
Trying ::1...
Connected to localhost.
Escape character is '^]'.
<strong>OPTIONS / HTTP/1.1</strong>  &lt;-----入力<strong>
host:localhost</strong>      &lt;-----入力
                     &lt;「Enter」キー
HTTP/1.1 200 OK
Date: Sat, 03 Dec 2024 12:03:26 GMT
Server: Apache
Allow: GET,POST,OPTIONS,HEAD
<strong>X-FRAME-OPTIONS: SAMEORIGIN</strong>    &lt;---- 有効
Content-Length: 0
Content-Type: httpd/unix-directory

Connection closed by foreign host.</code></pre>



<h4 class="wp-block-heading"><span id="toc13">ドキュメントルートにindex.htmlを作成</span></h4>



<p>上記でドキュメントルートを変更し、新しく作成したので、<br>デフォルトのトップページ「index.html」を作成しておきます。<br>保存後、ファイルの所有者を「Apache」のユーザー「apache」に変更し再起動しておきます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-9138216c6b9727dc58916ac9f6de2e14"><code>$ cd /home/www/html/
# vi ./index.html 
・
&lt;html&gt;
  &lt;body&gt;
    &lt;h1&gt;This website is currently under maintenance.&lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;
・
    &lt;-----------保存
# chown -R apache.apache /home/www/html/
# httpd -t
Syntax OK
# systemctl restart httpd</code></pre>



<p>自宅LAN内から、ブラウザのアドレスバーに、このサーバーのIPアドレスを入力するとこのページが表示されます。</p>



<figure class="wp-block-image size-full has-custom-border"><img loading="lazy" decoding="async" width="779" height="134" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/index-html.png" alt="" class="wp-image-8448" style="border-width:1px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/index-html.png 779w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/index-html-500x86.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/index-html-300x52.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/index-html-768x132.png 768w" sizes="(max-width: 779px) 100vw, 779px" /></figure>



<h2 class="wp-block-heading"><span id="toc14">Let&#8217;s Encrypt証明書でhttps化</span></h2>



<p>上の画像でも確認できますが、最近は「http://」では「保護されていない通信」警告が表示されてしまいます。<br>「https化」は必須ですね。<br>ただし、https://はホスト名でのアクセスが必要になります、自宅のサーバーを公開するには、独自ドメインとDNSサーバーが必要になります。<br>このサイトのドメインは<a href="https://muumuu-domain.com/">こちら</a>で取得しました<br>独自ドメインの取得と管理は若干のコストがかかりますが、<a href="https://www.mydns.jp/">DNS管理は無料のサービス</a>もあります。<br>ドメイン取得と「https化」の記事は、下記でも紹介しています。</p>



<figure class="wp-block-embed is-type-wp-embed"><div class="wp-block-embed__wrapper">

<a href="https://www.kazuban.com/blog/to-https" title="HTTPS化" 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="121" height="90" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/HTTPS.jpg" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/HTTPS.jpg 886w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/HTTPS-300x223.jpg 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/HTTPS-768x572.jpg 768w" sizes="(max-width: 121px) 100vw, 121px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">HTTPS化</div><div class="blogcard-snippet internal-blogcard-snippet">今回の自宅サーバーの再構築は、自宅サイトの「https」化ですやっとここまでたどりつきましたまたしても、こちらのサイトを参考にさせていただきました今回も流れはこのサイトに則って作業しますが、自分の環境に合わせて覚書きとして書き残しておきたいと思いますホスト名でのアクセスが必要http の場合は、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://www.kazuban.com/blog" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">www.kazuban.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2019.07.19</div></div></div></div></a>
</div></figure>



<h3 class="wp-block-heading"><span id="toc15">ファイヤーウォール設定の確認</span></h3>



<p>Firewallサービスで「https」を許可している必要があります。<br>上記ですでに設定済みですが、再度確認してみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-ab745b4fe3087fd14f3bf586d0e1b733"><code># firewall-cmd --get-active-zones
<strong>admin</strong>
  sources: 192.168.0.100 192.168.0.101
<strong>public</strong>
  interfaces: eno1
# firewall-cmd --list-all --zone=<strong>public</strong> | grep services
  services: dhcpv6-client http <strong>https</strong>
# firewall-cmd --list-all --zone=<strong>admin</strong> | grep services
  services: cockpit dhcpv6-client http <strong>https</strong> ssh
</code></pre>



<p>「adminゾーン」と「publicゾーン」へ許可されています。</p>



<h3 class="wp-block-heading"><span id="toc16">sslモジュールの確認</span></h3>



<p>こちらも、「httpdのインストール」時に、追加インストールしましたが、確認してみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-1ab824db36f50c7d1f1311aae55e7002"><code>#  dnf list installed | grep mod_ssl
mod_ssl.x86_64  1:2.4.57-5.el9 @appstream   
# httpd -M | grep ssl
ssl_module (shared)</code></pre>



<p>登録されていました。</p>



<h3 class="wp-block-heading"><span id="toc17">Certbot クライアントのインストール</span></h3>



<p><a rel="noopener" href="https://free-ssl.jp/" data-type="link" data-id="https://free-ssl.jp/" target="_blank">Let&#8217;s Encrypt </a>は、クライアントソフトウェア「Certbot」を使用することで、SSL/TLS サーバ証明書の取得・更新作業を自動化できる仕組みになっています。<br>まずは、パッケージが用意されているか確認してみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-14b2f051c4b75d0ca58522824a63fdcb"><code># dnf list --all | grep certbot
certbot.noarch  2.6.0-1.el9  epel 
・
・     </code></pre>



<p>EPELリポジトリに含まれていました。<br>Let&#8217;s Encrypt総合サイト情報を参考にインストールします。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-7ffa1810e0f6b7953808382085ce9c16"><code># dnf install certbot
# dnf install python-certbot-apache
・
# dnf list installed | grep certbot      &lt;----------- インストール確認
certbot.noarch                2.6.0-1.el9   @epel        
python3-certbot.noarch        2.6.0-1.el9   @epel        
python3-certbot-apache.noarch 2.6.0-1.el9   @epel
・
# which certbot         &lt;---------- インストール場所の確認
/usr/bin/certbot</code></pre>



<p>インストールは完了しました。</p>



<h3 class="wp-block-heading"><span id="toc18">certbot で証明書発行</span></h3>



<p>certbotには、いくつかのプラグインがありますが、すでにWebサーバーが動作している場合には「webroot プラグイン」が使えます。<br>これは、Webサーバーの動作を変更する必要はないですが、外部からサーバーの８０番ポートにアクセスできる必要があります。<br>Webサーバーが動作していない場合には、「Standaloneプラグイン」が使えます。<br>ただし、もし動作している場合には、停止しておく必要があります。<br>今回は、「webroot プラグイン」でやってみます。<br>追加するオプションは、「certonly」「&#8211;webroot」に「-w」オプションで、証明書ファイルを保存するディレクトリ、「-d」で証明書を適応するホスト名を指定します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-61e90c85d7ce4c5bb7f419dbd3b08d27"><code># certbot certonly --webroot -w /home/www/html/ -d www.hogehoge.com -d hogehoge.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 　　　　　<em>&lt;------自分のEメールアドレスを入力</em>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
 https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: <strong>y</strong>　<em>&lt;----- 利用規約を読んでください</em>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: <strong>y </strong> <em>&lt;--------- 電子フロンティア財団からEメールが届いてもいいか？</em>
Account registered.
Requesting a certificate for www.hogehoge.com and hogehoge.com

<strong>Successfully</strong> received certificate.
Certificate is saved at: /etc/letsencrypt/live/www.hogehoge.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/www.hogehoge.com/privkey.pem
This certificate expires on 2024-01-03.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</code></pre>



<p>無事に証明書をGETできました！<br>証明書は３か月で更新になります。<br>更新は、「certbot」の「renew」で行いますが、「–dry-run」をつける事で確認できます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-10ff5072054ffb5696a4f942ccb7dfbb"><code># certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/www.hogehoge.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Simulating renewal of an existing certificate for www.hogehoge.com and hogehoge.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<strong>Congratulations,</strong> all simulated renewals succeeded: 
  /etc/letsencrypt/live/www.hogehoge.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</code></pre>



<p>「Congratulations」で、更新可能の確認ができました。</p>



<h3 class="wp-block-heading"><span id="toc19">SSLサーバ証明書の設定</span></h3>



<p>発行してもらった証明書を、設定ファイルに反映させます<br>「/etc/httpd/conf.d」内の「ssl.conf」を編集します</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-10d25ce1ed72af49dbf7d0c180b2c19e"><code>$ cd /etc/httpd/conf.d
$ sudo cp -p ssl.conf ssl.conf.20240103  &lt;---- バックアップしておく
$ sudo vi ./ssl.conf
・

#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/letsencrypt/live/www.hogehoge.com/fullchain.pem
・
・
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile /etc/letsencrypt/live/www.hogehoge.com/privkey.pem
・
・
・                 &lt;--- 保存
$ sudo httpd -t 
Syntax OK

$ sudo systemctl restart httpd
$ sudo systemctl status httpd</code></pre>



<h3 class="wp-block-heading"><span id="toc20">https:// でのアクセス確認</span></h3>



<p>https://ドメイン名　でアクセスできるかの確認をします。<br>外部からの確認は、ルータの４４３ポートを通しておくと確認できますが、<br>同じLAN内でのPCでは、「hosts」ファイルを編集する事で可能になります<br>WindowsPCであれば、「C:\Windows\System32\drivers\etc\hosts」<br>linux であれば、「/etc/hosts」を編集します</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-a2c0947c87e3b9889a6af4f378788e4f"><code>192.168.1.101 www.hogehoge.com</code></pre>



<p>これで、ローカル内であっても、「https://ドメイン名」でアクセス可能になります。</p>



<h2 class="wp-block-heading"><span id="toc21">ApacheでHTTP/2を利用する</span></h2>



<p>HTTP/2 を利用するには、次の環境が必要になります<br>参考：<a href="https://www.value-domain.com/media/http2/">https://www.value-domain.com/media/http2/</a></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>・通信の暗号化が必須で、SSLサーバー証明書が必要です。 <br>・マルチスレッド機能であるeventMPMが有効である事</p>
</blockquote>



<h3 class="wp-block-heading"><span id="toc22">eventMPMモジュールとhttp2モジュールの確認</span></h3>



<p>eventMPMとhttp2モジュールは、RockyLinux9ではデフォルトで有効になっているようです。<br>確認してみます。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-58afb57c938b5b21d499f404fb607055"><code># httpd -M | grep mpm
 <strong>mpm_event_module (shared)</strong>
# httpd -M | grep http2
 <strong>http2_module (shared)</strong>
 proxy_http2_module (shared)</code></pre>



<p>有効になっていました。</p>



<h3 class="wp-block-heading"><span id="toc23">http2を有効にする</span></h3>



<p>参考：<a href="https://access.redhat.com/documentation/ja-jp/red_hat_jboss_core_services/2.4.57/html/apache_http_server_installation_guide/enable_http2">Red Hat Customer Portal</a><br>まず、現状を確認してみます。<br>筆者は、Google Chrome で確認してみました。<br>Chromeを起動後、「F12」を押すと、表示されたWebページの横に<br>開発ツールのページが表示されます。<br>ここで、確認したい「https://www.hogehoge.com」のページを表示すると<br>「Network」タブの「Protocol」で確認できます。<br>「https://」でのアクセスになるので、IPアドレスではなくドメインになります。<br>ここでもし、「Name・・・Protocol」の表が出ていない場合には、「Ctrl」+「R」で<br>再読み込みすると、出てきます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="721" height="387" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/http1.png" alt="" class="wp-image-8460" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/http1.png 721w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/http1-500x268.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/http1-300x161.png 300w" sizes="(max-width: 721px) 100vw, 721px" /></figure>



<p>私の環境では、「http/1.1」で通信しているのが分かります。<br>ここで、<a href="https://access.redhat.com/documentation/ja-jp/red_hat_jboss_core_services/2.4.57/html/apache_http_server_installation_guide/enable_http2">参考ページ</a>を参考に、設定しようと思います。<br>仮想ホスト　ごとに、設定する場合、&lt;VirtualHost&gt;ディレクティブの下の行で設定するようですが、全てのサーバーで有効にするには、メインの設定ファイル「httpd.conf」に追加するようです。<br>特に今回の私の環境は、仮想ホスト設定にはしていないので、メインで設定します。</p>



<pre class="wp-block-code has-ex-a-color has-black-background-color has-text-color has-background has-link-color wp-elements-91a2f232f757af9469376cd6e66e9af6"><code># vi /etc/httpd/conf/httpd.conf
・
・
##----- added. 2024/01/03
&lt;IfModule http2_module&gt;
    Protocols h2 http/1.1
    ProtocolsHonorOrder on
&lt;/IfModule&gt;
・
# systemctl restart httpd</code></pre>



<p>最終行に、追加しまし、再起動しました。<br>再度、Chromeで確認してみます。<br>「http/1.1」から変化がない場合には、<br>Chromeの場合では、「Ctrl」+「Shift」+「Delete」で閲覧履歴データを削除し<br>ブラウザでページを表して「F12」で確認します。<br>「Protocol」が表示されていない場合には、「CTRL」+「R」やキャッシュ削除してみてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="730" height="384" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/http2.png" alt="" class="wp-image-8461" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/http2.png 730w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/http2-500x263.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/http2-300x158.png 300w" sizes="(max-width: 730px) 100vw, 730px" /></figure>



<p>「h2」となっている事から、http2 で通信されている事が確認できます。</p>



<h2 class="wp-block-heading has-indigo-background-color has-background is-style-bottom-margin-1em has-bottom-margin"><span id="toc24">RockyLinux9.3で自宅サーバーを再構築・記事一覧</span></h2>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rockylinux9-3-install"><img loading="lazy" decoding="async" width="524" height="354" src="https://www.kazuban.com/blog/wp-content/uploads/2023/11/rockylinux9.png" alt="" class="wp-image-8330" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/11/rockylinux9.png 524w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/rockylinux9-500x338.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/rockylinux9-300x203.png 300w" sizes="(max-width: 524px) 100vw, 524px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rockylinux9-3-install">インストール</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-green-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:4px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rockylinux9-3-ssh"><img loading="lazy" decoding="async" width="416" height="343" src="https://www.kazuban.com/blog/wp-content/uploads/2023/11/rlogin.png" alt="" class="wp-image-8440" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/11/rlogin.png 416w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/rlogin-300x247.png 300w" sizes="(max-width: 416px) 100vw, 416px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rockylinux9-3-ssh">SSHでリモート管理</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rockylinux9-3-firewalld"><img loading="lazy" decoding="async" width="615" height="613" src="https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall.png" alt="" class="wp-image-8443" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall.png 615w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall-500x498.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall-300x299.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall-100x100.png 100w, https://www.kazuban.com/blog/wp-content/uploads/2023/11/Firewall-150x150.png 150w" sizes="(max-width: 615px) 100vw, 615px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rockylinux9-3-firewalld">firewalldでアクセス制御</a></p>
</div>
</div>



<div class="wp-block-columns has-luminous-vivid-amber-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:4px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized wp-duotone-unset-1"><a href="https://www.kazuban.com/blog/rokeylinux9-3-apache"><img loading="lazy" decoding="async" width="1024" height="390" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache.png" alt="" class="wp-image-8477" style="object-fit:contain;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache.png 1024w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache-500x190.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache-800x305.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache-300x114.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/Apache-768x293.png 768w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rokeylinux9-3-apache">Apache編</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rokeylinux9-3-php82-maria105"><img loading="lazy" decoding="async" width="1785" height="1321" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb.png" alt="" class="wp-image-8478" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb.png 1785w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb-500x370.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb-800x592.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb-300x222.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb-768x568.png 768w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/php-mariadb-1536x1137.png 1536w" sizes="(max-width: 1785px) 100vw, 1785px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rokeylinux9-3-php82-maria105">PHP8.2とMariaDB10.5編</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-green-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:4px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rokeylinux9-3-wordpress-install"><img loading="lazy" decoding="async" width="2000" height="1080" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative.png" alt="" class="wp-image-8479" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative.png 2000w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative-500x270.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative-800x432.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative-300x162.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative-768x415.png 768w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/WordPress-logotype-alternative-1536x829.png 1536w" sizes="(max-width: 2000px) 100vw, 2000px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rokeylinux9-3-wordpress-install">WordPress インストール</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-red-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rokeylinux9-3-wordpress-backup"><img loading="lazy" decoding="async" width="1024" height="1024" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore.png" alt="" class="wp-image-8480" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore.png 1024w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-500x500.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-800x800.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-300x300.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-768x768.png 768w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-100x100.png 100w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/wordpress-backup-restore-150x150.png 150w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rokeylinux9-3-wordpress-backup">WordPress のバックアップとリストア</a></p>
</div>
</div>



<div class="wp-block-columns has-watery-green-background-color has-background is-style-bottom-margin-1em has-bottom-margin is-layout-flex wp-container-core-columns-is-layout-c6809a2b wp-block-columns-is-layout-flex" style="border-style:none;border-width:0px;border-radius:0px">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:15%">
<figure class="wp-block-image size-full is-resized"><a href="https://www.kazuban.com/blog/rockylinux9-3-postfix"><img loading="lazy" decoding="async" width="900" height="568" src="https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix.png" alt="" class="wp-image-8483" style="object-fit:cover;width:100px;height:70px" srcset="https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix.png 900w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix-500x316.png 500w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix-800x505.png 800w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix-300x189.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2023/12/postfix-768x485.png 768w" sizes="(max-width: 900px) 100vw, 900px" /></a></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p><a href="https://www.kazuban.com/blog/rockylinux9-3-postfix">postfix で送信専用メールサーバー構築</a></p>
</div>
</div>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>HTTPS化</title>
		<link>https://www.kazuban.com/blog/to-https/</link>
		
		<dc:creator><![CDATA[kazuban]]></dc:creator>
		<pubDate>Fri, 19 Jul 2019 02:24:12 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux (CentOS、Rocky、Ubuntu)]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[覚書]]></category>
		<guid isPermaLink="false">https://www.kazuban.com/blog/?p=971</guid>

					<description><![CDATA[今回の自宅サーバーの再構築は、自宅サイトの「https」化ですやっとここまでたどりつきました またしても、こちらのサイトを参考にさせていただきました今回も流れはこのサイトに則って作業しますが、自分の環境に合わせて覚書きと [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>今回の自宅サーバーの再構築は、自宅サイトの「https」化です<br>やっとここまでたどりつきました</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><a href="https://www.rem-system.com/cent-httpd-ssl/">またしても、こちらのサイトを参考にさせていただきました</a><br>今回も流れはこのサイトに則って作業しますが、自分の環境に合わせて覚書きとして書き残しておきたいと思います</p></blockquote>



<div id="host">

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-6" checked><label class="toc-title" for="toc-checkbox-6">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">ホスト名でのアクセスが必要</a><ol><li><a href="#toc2" tabindex="0">ホスト名でのアクセスを可能にする</a></li></ol></li><li><a href="#toc3" tabindex="0">ファイアウォールの設定とSSLモジュールの確認</a><ol><li><a href="#toc4" tabindex="0">ファイアウォールの確認と設定</a></li><li><a href="#toc5" tabindex="0">SSLモジュールの確認・インストール</a></li></ol></li><li><a href="#toc6" tabindex="0">Let&#8217;s Encrypt で証明書をGET！</a><ol><li><a href="#toc7" tabindex="0">certbot のインストール</a></li></ol></li><li><a href="#toc8" tabindex="0">証明書の取得</a><ol><li><a href="#toc9" tabindex="0">Standalone プラグイン</a></li><li><a href="#toc10" tabindex="0">webroot プラグイン</a></li><li><a href="#toc11" tabindex="0">certbot コマンドの実行</a></li></ol></li><li><a href="#toc12" tabindex="0"> SSLサーバ証明書の設定 </a><ol><li><a href="#toc13" tabindex="0">httpsでアクセスできるかの確認</a></li><li><a href="#toc14" tabindex="0">証明書更新の確認</a></li></ol></li><li><a href="#toc15" tabindex="0">まずは、目標のhttps化が完了</a><ol><ol><li><a href="#toc16" tabindex="0">自宅でWordPressを動かそう！</a></li></ol></li></ol></li></ol>
    </div>
  </div>

<h2><span id="toc1">ホスト名でのアクセスが必要</span></h2>
</div>



<p>http の場合は、IPアドレスでのアクセスも可能でしたが、https になると「ホスト名」でのアクセスを可能にする必要があるようです。<br>ちょっと実験してみます。<br>まずは、メジャーなサイトのIPアドレスを取り出して、そのIPアドレスでアクセスしてみます。<br>「host」コマンドでゲットできます。<br>「host」コマンドが利用できない場合には、「bind-utils」をインストールする事で使用できるようになります。</p>



<pre class="wp-block-preformatted">$ host yahoo.co.jp
 yahoo.co.jp has address 182.22.59.229
 yahoo.co.jp has address 183.79.135.206
 yahoo.co.jp mail is handled by 10 mx2.mail.yahoo.co.jp.
 yahoo.co.jp mail is handled by 10 mx1.mail.yahoo.co.jp.
 yahoo.co.jp mail is handled by 10 mx3.mail.yahoo.co.jp.
 yahoo.co.jp mail is handled by 10 mx5.mail.yahoo.co.jp.</pre>



<p class="has-background has-very-light-gray-background-color">２種類でで来ましたが、どちらでもいいと思います<br>ウェブブラウザのアドレスバーでこのアドレスでアクセスしてみます<br><a href="http://182.22.59.229">「http://182.22.59.229」</a></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="880" height="451" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-http.png" alt="" class="wp-image-975" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-http.png 880w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-http-300x154.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-http-768x394.png 768w" sizes="(max-width: 880px) 100vw, 880px" /></figure>



<p class="has-background has-very-light-gray-background-color">保護されていない通信との警告がでて、一部表示できないコンテンツがありますが、とりあえず通常どおりにアクセスできました</p>



<hr class="wp-block-separator"/>



<p class="has-background has-very-light-gray-background-color"><br>次に、「<a href="https://182.22.59.229">https://182.22.59.229</a>」でアクセスしてみます</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="893" height="642" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-1.png" alt="" class="wp-image-979" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-1.png 893w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-1-300x216.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-1-768x552.png 768w" sizes="(max-width: 893px) 100vw, 893px" /></figure>



<p class="has-background has-very-light-gray-background-color">正常に表示されません。Chromeは警告をだしました。</p>



<hr class="wp-block-separator"/>



<p class="has-background has-very-light-gray-background-color"><br>次に、ホスト名でアクセスしてみます <br>「<a href="https://yahoo.co.jp">https://yahoo.co.jp</a>」 </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="700" height="464" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-2.png" alt="" class="wp-image-982" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-2.png 700w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/yahoo-https-2-300x199.png 300w" sizes="(max-width: 700px) 100vw, 700px" /></figure>



<p class="has-background has-very-light-gray-background-color">ホスト名であれば、正常に表示されました。<br>やはり、自分のサイトを「https」化する場合には、ホスト名でアクセスできるようにしなければいけません。</p>



<h3 class="wp-block-heading"><span id="toc2">ホスト名でのアクセスを可能にする</span></h3>



<p><br>会社などの場合のように、プロバイダに固定IPで契約すれば、ホスト名でアクセスできるように設定された、DNS設定が利用できると思いますが、自宅のような個人でおこなう場合結構費用もかかるので、インターネット接続プロバイダの標準設定で運用したいです。<br>この場合一番重要なのは、プロバイダからグローバルIPが提供されているか？が問題になってきます<br>インターネットに出て行く場合には、自宅内のPCにグローバルIPを意識する必要ありませんが、インターネット側から自宅サーバへアクセスするには、グローバルIPが必須となります<br>自宅は、「auひかり」ですが、だいたいのプロバイダは、グローバルIPが提供されると思います。<br>ただし、このIPは固定でなくて、動的IPの場合が多いと思います<br>動的IPの場合突然、IPアドレスが変わってしまう事があるので、動的に対応した設定をしておかなくてはいけません。<br>ネットで調べると、この動的IPに対応したサービスをしているサイトが見つかります。その中で私は「 <a href="https://www.mydns.jp/?MENU=010">https://www.mydns.jp/</a>」を利用させていただいています。<br>無料で利用できるので、本当感謝です<br>ここの「JOIN US」のページで登録する事で利用できるようになります<br>設定がすんだら、「host」コマンドで正常にIPが表示されれば準備完了です</p>



<pre class="wp-block-preformatted">$ host www.hogehoge.com
 www.hogehoge.com has address  183.79.135.206 </pre>



<h2 class="wp-block-heading"><span id="toc3">ファイアウォールの設定とSSLモジュールの確認</span></h2>



<h3 class="wp-block-heading"><span id="toc4">ファイアウォールの確認と設定</span></h3>



<p>ファイアウォールの設定は、「firewall-cmd」を使用します。<br>「&#8211;list-all」のオプションで確認し、「&#8211;add-service=https」で追加、「&#8211;permanent」で恒久的に反映します。<br>ただし、 「&#8211;permanent」の場合には、 「firewall-cmd」 を再起動させる必要があります </p>



<pre class="wp-block-preformatted">$ sudo firewall-cmd --list-all    &lt;------ 確認
 public (active)
   target: default
   icmp-block-inversion: no
   interfaces: wlp8s0
   sources:
   services: ssh dhcpv6-client http    &lt;--------- https は許可されていない
   ports:
   protocols:
   masquerade: no
   forward-ports:
   source-ports:
   icmp-blocks:
   rich rules:
 $ sudo firewall-cmd --add-service=https --permanent  &lt;- サービスを追加
 success

 $ sudo firewall-cmd --reload   &lt;---------- 再起動
 success

 $ sudo firewall-cmd --list-all  &lt;-------- 再確認
 public (active)
   target: default
   icmp-block-inversion: no
   interfaces: wlp8s0
   sources:
   services: ssh dhcpv6-client http https   &lt;-------- 追加された
   ports:
   protocols:
   masquerade: no
   forward-ports:
   source-ports:
   icmp-blocks:
   rich rules:</pre>



<h3 class="wp-block-heading"><span id="toc5">SSLモジュールの確認・インストール</span></h3>



<p>前回の  <a href="https://www.kazuban.com/blog/apache-install/">apache のインストール</a> でmod_sslもインストールしましたが、再度確認し、もしインストールされていなければ、インストールします。<br>インストールの確認は、「yum list installed」で、<br>インストールは「yum install」で、モジュール登録の確認は「httpd -M」で行います</p>



<pre class="wp-block-preformatted">$ sudo yum -y install mod_ssl　　　&lt;----------- とりあえずインストール
 読み込んだプラグイン:fastestmirror, langpacks
 Loading mirror speeds from cached hostfile
 base: ftp.iij.ad.jp
 extras: ftp.iij.ad.jp
 updates: ftp.iij.ad.jp
 パッケージ 1:mod_ssl-2.4.6-89.el7.centos.x86_64 はインストール済みか最新バージョンです
 何もしません 　　　　&lt;---------- 私の環境ではすでにインストール済みでした

 $ yum list installed | grep mod_ssl      &lt;-------- インストール済みの確認
 mod_ssl.x86_64       1:2.4.6-89.el7.centos          @updates

 $ sudo httpd -M | grep ssl   &lt;-------- sslモジュールの登録の確認
  ssl_module (shared)

 $ sudo systemctl restart httpd  &lt;-------- httpd の再起動
 $ sudo systemctl status httpd   &lt;-------- httpd の状態の確認</pre>



<h2 class="wp-block-heading"><span id="toc6">Let&#8217;s Encrypt で証明書をGET！</span></h2>



<p>「https」でssl通信するには、自分のサイトが安全だと言う事を証明してもらわなうてはいけません。<br>証明書を発行してくれる機関は沢山ありますが、結構いいお値段です。<br>そんな中で、「Let&#8217;s Encrypt」は無料で証明書を発行してくれます。<br> 「Let&#8217;s Encrypt」 は、「certbot」というソフトウェアを利用して証明書を発行してくれるシステムなので、まずは「certbot」を動作させる必要があります。<br>以前私は、「VineLinux」でサーバーを構築していましたが、「 certbot 」に対応していませんでした。<br>ネットの情報集めて挑戦してみましたが、私のレベルでは断念しました。<br>それで、対応している、「centOS7」で再構築したのが、このサイトです</p>



<h3 class="wp-block-heading"><span id="toc7">certbot のインストール</span></h3>



<p><br>「 certbot 」のインストール方法は、「<a href="https://free-ssl.jp/usage/install-certbot.html#CentOS7">Let&#8217;s  Encrypt総合ポータル</a>」にも情報があります。<br>centOS7の場合には、 EPEL (Extra Packages for Enterprise Linux) リポジトリからインストールすることができるようです。 </p>



<pre class="wp-block-preformatted">$ sudo yum -y install epel-release
$ sudo yum -y install certbot
$ sudo yum -y install python2-certbot-apache

$ yum list installed | grep certbot        &lt;------ インストール済みの確認
 certbot.noarch                0.31.0-2.el7                   @epel
 python2-certbot.noarch        0.31.0-2.el7                   @epel
 python2-certbot-apache.noarch 0.31.0-1.el7                   @epel

$ which certbot &lt;---------- インストール場所の確認 
 /usr/bin/certbot
</pre>



<div id="stand">
<h2><span id="toc8">証明書の取得</span></h2>
</div>



<p>証明書はインストールした、「certbot」コマンドで発行しますが、発行の方法によりよく使われるプラグインが２つあります<br>「<a href="https://free-ssl.jp/docs/using.html#standalone">Standalone</a>」と「<a href="https://free-ssl.jp/docs/using.html#webroot">Webroot</a>」です</p>



<h3 class="wp-block-heading"><span id="toc9">Standalone プラグイン</span></h3>



<p>「<a href="https://free-ssl.jp/">Let&#8217;s Encrypt 総合ポータル</a>」には、下記のような説明があります<br>ようするに、Webサーバーが動いていなくても証明書の取得ができるけど、逆に考えると、<span class="markerPink"><strong>Webサーバーが動いていると取得できない</strong></span>と言う事です<br></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p> SSL/TLS サーバ証明書の取得のみを行ないます。<br>※ドメイン使用権者の認証（Let&#8217;s Encrypt のサーバから、証明書を取得するドメイン名を正引きしたIPアドレスに接続することによる認証）の際には、Certbot クライアントに内蔵されている簡易的なウェブサーバが機能が一時的に使われます。<br>※このプラグインは TCP Port 80 もしくは TCP Port 443 を使うため、当該 Port を Listen している動作中のウェブサーバを一時的に終了させる必要があります。<br>※当サイトのチュートリアル&nbsp;<a href="https://free-ssl.jp/usage/">Let&#8217;s Encrypt の使い方</a>&nbsp;では、このプラグインを使用した Let&#8217;s Encrypt 導入方法を解説しています </p></blockquote>



<h3 class="wp-block-heading"><span id="toc10">webroot プラグイン</span></h3>



<p> こちらも「<a href="https://free-ssl.jp/">Let&#8217;s Encrypt 総合ポータル</a>」に、下記のような説明があります<br>こちらは、すでにWebサーバーが動いている場合です。<br>すでに動作しているWebサーバーを停止しなくていもいいが、<span class="markerPink"><strong>外部から自宅のWebサーバー（８０番ポート）にアクセスできる必要があります</strong></span><br>したがって、サーバーの設定だけでなく、自宅サーバーへの入り口になるルータ（ゲートウェイ）の設定で、８０番ポートをオープンして、対象のWebサーバーと紐付けしておく必要があります</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p> 動作中のウェブサーバのドキュメントルートディレクトリ以下に、ドメイン使用権者の認証用のファイルを自動的に設置することにより、SSL/TLS サーバ証明書の取得を行います。<br>※動作中の httpd（TCP Port 80 や TCP Port 443 など）のサービスを停止させる必要はありません。<br>※Certbot クライアントを、証明書を取得するドメイン名を運用しているウェブサーバ（DNSの正引きしたIPアドレスのウェブサーバ）で実行する必要があります。また、httpd が動作中である必要があります。 </p></blockquote>



<h3 class="wp-block-heading"><span id="toc11">certbot コマンドの実行</span></h3>



<p> いよいよ、証明書を取得してみようと思います。<br>今の環境では、Webサーバーは動作し、外部からもアクセス可能な状態なので、<br>「webroot」プラグインを使用します。<br>また「-w」オプションで、証明書ファイルを保存するディレクトリを指定します<br>「-d」は証明書を適応するホスト名を指定します</p>



<pre class="wp-block-preformatted">$ sudo certbot certonly --webroot -w /home/www/html/ -d www.hogehoge.com -d hogehoge.com
　・
　・
              対話型で質問が表示されます
Enter email address .......   &lt;--------------- Eメールアドレスを入力
Please read the Terms of Service at ....  &lt;------- 同意するか？(A入力)
Would you be willing to share your email address with the Electronic Frontier
・
・     &lt;------------ メールアドレスを共有するか？　(Y)es　or  (N)o: </pre>



<p class="has-background has-very-light-gray-background-color">設定が終わりました。<br>これで、証明書の発行が始まるはずですが・・・・<strong>うまくいかな～い！</strong></p>



<p>どうも、ドキュメントルート「/home/www/html」に作成した「index.html」が拒否しているみたい。<br>「curl」コマンドでリクエストしてみます</p>



<pre class="wp-block-preformatted">$ curl http://localhost/
 &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
 &lt;html&gt;&lt;head&gt;
 &lt;title&lt;403 Forbidden&lt;/title＞
 &lt;/head&gt;&lt;body&gt;
 &lt;h1&gt;Forbidden&lt;/h1&gt;
 &lt;p&gt;You don't have permission to access /
 on this server.&lt;/p&gt;
 &lt;/body&gt;&lt;/html&gt;</pre>



<p>たぶん、<strong>「SELinux」</strong>で、ドキュメントルートとして作成した「/home/www/html」へのアクセスが制限されているみたいです。<br>せっかく標準で有効になっているので、どうにか使用したいと思いGUI版をインストールしてみました。</p>



<pre class="wp-block-preformatted">$ sudo yum install policycoreutils-gui</pre>



<p>GUI環境で設定できそうですが、結局よくわからない<br>無効にすることにしました。<br>無効にするには、このGUIでもできますし、「/etc/selinux/config」を編集すればよさそうです</p>



<pre class="wp-block-preformatted">$ cd /etc/selinux/<br>$ sudo vi ./config<br>---------------------------------<br>SELINUX=disabled  &lt;---------------  disabled に設定</pre>



<p>設定後は、システムの再起動が必要です<br>再起動後、再度確認してみます</p>



<pre class="wp-block-preformatted">$ curl http://localhost/
 &lt;html&gt;
   &lt;body&gt;
    home www test page
   &lt;/body&gt;
 &lt;/html&gt;

     <em>今度は出てきましたので、再度「certbot」実行</em>

$ sudo certbot certonly --webroot -w /home/www/html/ -d www.hogehoge.com -d hogehoge.com

    <em> 今度は ”<strong>Congratulations!</strong>” が出てくれました</em>!
     <em>証明書が自動保存されるディレクトリを確認してみます</em>

$ cd /etc/letsencrypt/
$ ls
accounts  archive  csr  keys  <strong>live</strong>  renewal  renewal-hooks</pre>



<p>あった、あった、「live」の中の、指定ホスト名と同じディレクトリの中に証明書が保存されています。<br> 
<span class="markerYellow">ファイルを確認するには、rootになる必要があります </span>
</p>



<h2 class="wp-block-heading"><span id="toc12"> SSLサーバ証明書の設定 </span></h2>



<p>「/etc/httpd/conf.d」内の「ssl.conf」に証明書ファイルを設定します<br>とりあえず、現在の「ssl.conf」ファイルは名前を変えて残しておきます</p>



<pre class="wp-block-preformatted">$ cd /etc/httpd/conf.d
$ sudo cp -p ssl.conf ssl.conf.20190502  &lt;---- バックアップしておく
$ sudo vi ./ssl.conf
・
#SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateFile /etc/letsencrypt/live/www.hogehoge.com/cert.pem
・
・
#SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
SSLCertificateKeyFile 
/etc/letsencrypt/live/hogehoge.com/privkey.pem
・
・
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
SSLCertificateChainFile /etc/letsencrypt/live/www.hogehoge.com/chain.pem

　　　<em>保存して確認しますが、「sudo」ではなく「su」でroot になる必要があります</em>
#httpd -t
Syntax OK

$ sudo systemctl restart httpd
$ sudo systemctl status httpd
</pre>



<h3 class="wp-block-heading"><span id="toc13">httpsでアクセスできるかの確認</span></h3>



<p>確認するには、ウェブブラウザで確認しますが、https はIPアドレスではアクセスできません。<br>ホスト名でアクセスする必要があります。<br>「https://www.hogehoge.com」<br>
<span class="markerPink">また、外部からのアクセスには、４４３ポートを開放し、サーバと紐づけしておく必要があります</span>
</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1014" height="420" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/router03.jpg" alt="" class="wp-image-1016" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/router03.jpg 1014w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/router03-300x124.jpg 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/router03-768x318.jpg 768w" sizes="(max-width: 1014px) 100vw, 1014px" /></figure>



<p>ところが、私の環境では自宅内にサーバがあり、自宅内のPCのブラウザで確認しようとしてもできません。<br>自宅の環境は、外部のDDNSを使わせていただいているからかもしれません。<br>外部からなら確認できると思うので、スマホがあれば自宅内の<span class="markerYellow"> wifi設定を無効</span>にすれば確認できました。<br>やっぱり、自宅内のWindowsPCからでも確認したい場合には、Widowsの「hosts」を編集します<br>「C:\Windows\System32\drivers\etc\hosts」</p>



<pre class="wp-block-preformatted">192.168.1.101 hogehoge.com
192.168.1.101 www.hogehoge.com</pre>



<p>これで、再度 「https://www.hogehoge.com」   を入力して表示されれば、正常にSSLで通信できています。</p>



<h3 class="wp-block-heading"><span id="toc14">証明書更新の確認</span></h3>



<p>更新は、「certbot」の「renew」で行いますが、「&#8211;dry-run」をつける事で確認のに行えるようです。</p>



<pre class="wp-block-preformatted">$ sudo certbot renew --dry-run
  <em>これで、「Congratulations, all renewals succeeded.」が表示されれば更新も正常にできるようです。</em></pre>



<p> Let’s Encrypt の証明書は、３か月で更新が必要なので、後日自動更新できるようにも設定してみようと思います</p>



<h2 class="wp-block-heading"><span id="toc15">まずは、目標のhttps化が完了</span></h2>



<p>どうには、今回の目標の一つでもある、https化が完了しました。<br>これから、メールサーバとWordPress の設定をしていきます。</p>



<h4 class="wp-block-heading"><span id="toc16">自宅でWordPressを動かそう！</span></h4>



<br>
<div class="pager">
  <a class="prev page-numbers" href="https://www.kazuban.com/blog/httpd-setting/">PREV</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/centos7-install/">1</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/ssh-teraterm/">2</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/apache-install/">3</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/apache-install/">4</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/httpd-setting/">5</a>
  <span aria-current="page" class="page-numbers current">6</span>
  <a class="page-numbers" href="https://www.kazuban.com/blog/postfix-install/">7</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/ssl-for-mail/">8</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/php7-3/">9</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/mariadb-10/">10</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/wordpress-install/">11</a>
  <a class="next page-numbers" href="https://www.kazuban.com/blog/postfix-install/">NEXT</a>
</div>
<hr>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WWWサーバーのインストール</title>
		<link>https://www.kazuban.com/blog/apache-install/</link>
		
		<dc:creator><![CDATA[kazuban]]></dc:creator>
		<pubDate>Sun, 07 Jul 2019 01:11:43 +0000</pubDate>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux (CentOS、Rocky、Ubuntu)]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[覚書]]></category>
		<guid isPermaLink="false">https://www.kazuban.com/blog/?p=908</guid>

					<description><![CDATA[前回でリモートアクセスが可能になりました これで作業がだいぶ楽になりました次はいよいよ、wwwサーバを動作させ外部に発信できるようにします 目次 Apacheの導入Apache関連パッケージの確認自動起動するように設定パ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><a href="https://www.kazuban.com/blog/ssh-security/">前回でリモートアクセスが可能になりました</a></p></blockquote>



<p>これで作業がだいぶ楽になりました<br>次はいよいよ、wwwサーバを動作させ外部に発信できるようにします</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-8" checked><label class="toc-title" for="toc-checkbox-8">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">Apacheの導入</a><ol><li><a href="#toc2" tabindex="0">Apache関連パッケージの確認</a></li><li><a href="#toc3" tabindex="0">自動起動するように設定</a></li><li><a href="#toc4" tabindex="0">パケットフィルタリングの設定</a></li><li><a href="#toc5" tabindex="0">動作の確認</a></li><li><a href="#toc6" tabindex="0">外部からのアクセス</a></li><li><a href="#toc7" tabindex="0">確認が済んだら、外部アクセスは不可にする</a><ol><li><a href="#toc8" tabindex="0">自宅でWordPressを動かそう！</a></li></ol></li></ol></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">Apacheの導入</span></h2>



<p>wwwサーバは、現在は一番メジャーなApacheにします。<br>インストールは 「yum」で 簡単にインストールできます</p>



<h3 class="wp-block-heading"><span id="toc2">Apache関連パッケージの確認</span></h3>



<p>パッケージの確認は、「yum list」で確認できますが<br>apache のパッケージは「apache」ではなく「httpd」のようです</p>



<pre class="wp-block-preformatted">$ yum list | grep httpd
     httpd.x86_64         2.4.6-89.el7.centos         updates
     httpd-devel.x86_64   2.4.6-89.el7.centos         updates
     httpd-manual.noarch  2.4.6-89.el7.centos         updates
     httpd-tools.x86_64   2.4.6-89.el7.centos         updates
     keycloak-httpd-client-install.noarch  0.6-3.el7  base
     libmicrohttpd.i686                 0.9.33-2.el7  base
     libmicrohttpd.x86_64               0.9.33-2.el7  base
     libmicrohttpd-devel.i686           0.9.33-2.el7  base
     libmicrohttpd-devel.x86_64         0.9.33-2.el7  base
     libmicrohttpd-doc.noarch           0.9.33-2.el7  base
     python2-keycloak-httpd-client-install.noarch
</pre>



<p>この中で、<strong>「httpd」「httpd-tools」</strong>をインストール<br>  さらに、「ssl」の利用を考えているので<strong>「mod_ssl」</strong>もインストール<br> インストールは「yum install  パッケージ名　パッケージ名　・・」でインストールします</p>



<pre class="wp-block-preformatted">$ sudo yum install httpd httpd-tools mod_ssl
 読み込んだプラグイン:fastestmirror, langpacks
 Loading mirror speeds from cached hostfile
 base: ftp.iij.ad.jp
 extras: ftp.iij.ad.jp
 updates: ftp.iij.ad.jp
 依存性の解決をしています
 --&gt; トランザクションの確認を実行しています。
　　・
　　・
 --&gt; 依存性解決を終了しました。 
 依存性を解決しました
======================================================
 Package&nbsp;&nbsp;&nbsp;アーキテクチャー&nbsp;&nbsp; バージョン&nbsp;&nbsp;&nbsp;リポジトリー&nbsp;&nbsp;&nbsp;&nbsp;容量
======================================================
 インストール中:
  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
  mod_ssl     x86_64    1:2.4.6-89.el7.centos  updates   112 k
 依存性関連でのインストールをします:
  apr         x86_64    1.4.8-3.el7_4.1        base      103 k
  apr-util    x86_64    1.5.2-6.el7            base      92 k
  mailcap     noarch    2.1.41-2.el7           base      31 k
 トランザクションの要約
 インストール  3 パッケージ (+3 個の依存関係のパッケージ)
 総ダウンロード容量: 3.1 M
 インストール容量: 10 M
 Is this ok [y/d/N]: y
　　・
　　・ 
完了しました!</pre>



<p>無事にインストールは完了しました<br>hddpdを起動し、確認してみます<br>サービスの動作は、「systemctl」で行います<br>再起動は「start」 、再起動は、「restart」 、確認は「status」です</p>



<pre class="wp-block-preformatted">$ sudo systemctl start httpd
$ sudo systemctl status httpd
 <strong><font color="green">● </font></strong>httpd.service - The Apache HTTP Server
    Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
    Active:<strong><font color="green">active (running)</font></strong><font color="green"> </font>since 水 2019-05-01 10:40:57 JST; 1min 13s ago
      Docs: man:httpd(8)
            man:apachectl(8)
  Main PID: 13875 (httpd)
    Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
     Tasks: 6
    CGroup: /system.slice/httpd.service
            tq13875 /usr/sbin/httpd -DFOREGROUND
            tq13887 /usr/sbin/httpd -DFOREGROUND
            tq13888 /usr/sbin/httpd -DFOREGROUND
            tq13889 /usr/sbin/httpd -DFOREGROUND
            tq13890 /usr/sbin/httpd -DFOREGROUND
            mq13891 /usr/sbin/httpd -DFOREGROUND
 5月 01 10:40:57 server.kazuban.com systemd[1]: Starting The Apache HTTP Server…
  5月 01 10:40:57 server.kazuban.com systemd[1]: Started The Apache HTTP Server.</pre>



<p> <font color="green">緑色で 「active (running)」</font>が表示されています。<br>正常に起動しています</p>



<h3 class="wp-block-heading"><span id="toc3">自動起動するように設定</span></h3>



<p> サーバを再起動しても自動的に起動するように設定します<br>自動起動の設定も、「systemctl」で行います<br>自動設定は「enable」 、無効設定は、「disable」 、有無確認は「is-enabled」です <br>まずは、確認してみます</p>



<pre class="wp-block-preformatted">$ systemctl is-enabled httpd
 disabled
　　やはり自動設定は無効になってますから、有効にします
$ sudo systemctl enable httpd
 Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
　　再度確認
$ sudo systemctl is-enabled httpd
 enabled
　　有効になっています</pre>



<h3 class="wp-block-heading"><span id="toc4">パケットフィルタリングの設定</span></h3>



<p>centOS7は標準でファイアウォールが動作しているので、httpdのポートを許可する必要があります<br>ファイヤーウォールは「firewall-cmd」コマンドで設定します<br>「&#8211;add-service」で許可するサービスを追加しますが、このオプションだけでは、一時的な設定となるためFirewalldを再起動すると設定は消えてしまうようです。<br>永続的に設定するには、二通りあるゆです<br>「&#8211;runtime-to-permanent」で一時設定を永続設定に保存する方法と、 「&#8211;add-service」 の時に、「- -permanent 」も同時に指定する事もできます<br>ただし、後者の場合には、「  firewall-cmd &#8211;reload 」でリロードする必要があります<br>それでは、「http」を追加してみます</p>



<pre class="wp-block-preformatted">$ sudo firewall-cmd --add-service=http
 success
 $ sudo firewall-cmd --runtime-to-permanent
 success

　　　<em>確認してみます</em>

$ sudo firewall-cmd --list-all
public (active)
   target: default
   icmp-block-inversion: no
   interfaces: enp9s0f0 wlp8s0
   sources:
   services: ssh dhcpv6-client <strong>http</strong>
   ports:
   protocols:
   masquerade: no
   forward-ports:
   source-ports:
   icmp-blocks:
   rich rules:

<em>「http」が追加されています</em></pre>



<h3 class="wp-block-heading"><span id="toc5">動作の確認</span></h3>



<p>この状態で、WWWサーバは動作していますから、自宅内の他のPCのウェブブラウザでサーバのIPアドレスを入力すれば、ウェルカムページが表示されます<br>例えば、アドレスバーに、http://192.168.1.101（サーバアドレス）<br>ウェルカムページが表示されれば正常に動作しています</p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1024" height="639" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache-testpage-1024x639.png" alt="" class="wp-image-907" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache-testpage-1024x639.png 1024w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache-testpage-300x187.png 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache-testpage-768x479.png 768w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/apache-testpage.png 1399w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading"><span id="toc6">外部からのアクセス</span></h3>



<p>外部からのアクセスを確認するには、ゲートウェイ（ルータ）で８０番ポートをこのサーバーを指定して開放する必要があります<br>私の環境では「ポートマッピング」という項目でした<br> サーバーのアドレスに８０番ポートを設定します<br></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1014" height="420" src="https://www.kazuban.com/blog/wp-content/uploads/2019/07/router02.jpg" alt="" class="wp-image-933" srcset="https://www.kazuban.com/blog/wp-content/uploads/2019/07/router02.jpg 1014w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/router02-300x124.jpg 300w, https://www.kazuban.com/blog/wp-content/uploads/2019/07/router02-768x318.jpg 768w" sizes="(max-width: 1014px) 100vw, 1014px" /></figure>



<p>外部からアクセスするには、自宅のグローバルIPを知る必要があります<br>方法はネットで検索するといろいろヒットします。<br>例えば、自宅内PCから下記にアクセスすると、知ることができます<br>https://www.cman.jp/network/support/go_access.cgi<br>自宅のグローバルIPが分かったら、外部のPCのアドレスバーに http://「サーバアドレス」でウェルカムページが表示されるはずです<br>自宅内から確認したい場合、スマホなどでwifiの設定を無効して、アドレスを指定すれば、同様のウェルカムページが表示されれば外部への公開が確認できます。</p>



<h3 class="wp-block-heading"><span id="toc7">確認が済んだら、外部アクセスは不可にする</span></h3>



<p>インストール後の標準の状態では、セキュリティ的には危険が一杯のようです。<br>確認が済んだら、再度ルータの設定で８０番の開放は不可にしておいたほうがいいと思います<br>https://www.rem-system.com/apache-security01/<br>公開する前には、こちらを参考に設定変更後にしたいと思います</p>



<h4 class="wp-block-heading"><span id="toc8">自宅でWordPressを動かそう！</span></h4>



<br>
<div class="pager">
  <a class="prev page-numbers" href="https://www.kazuban.com/blog/apache-install/">PREV</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/centos7-install/">1</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/ssh-teraterm/">2</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/apache-install/">3</a>
  <span aria-current="page" class="page-numbers current">4</span>
  <a class="page-numbers" href="https://www.kazuban.com/blog/httpd-setting/">5</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/to-https/">6</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/postfix-install/">7</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/ssl-for-mail/">8</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/php7-3/">9</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/mariadb-10/">10</a>
  <a class="page-numbers" href="https://www.kazuban.com/blog/wordpress-install/">11</a>
  <a class="next page-numbers" href="https://www.kazuban.com/blog/httpd-setting/">NEXT</a>
</div>
<hr>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
