「Xserver VPSでDebianサーバ構築/Webサーバ設定」の版間の差分
ナビゲーションに移動
検索に移動
(ページの作成:「= 概要 = Webサーバを設定する。使用するものは、次の表のとおりである。 {| class="wikitable" |Webサーバ |Apache |- |証明書 |Let's Encry…」) |
|||
(同じ利用者による、間の34版が非表示) | |||
1行目: | 1行目: | ||
= 概要 = |
= 概要 = |
||
次の表のとおりである。 |
|||
{| class="wikitable" |
{| class="wikitable" |
||
10行目: | 10行目: | ||
|Let's Encrypt |
|Let's Encrypt |
||
|} |
|} |
||
= 設定 = |
|||
以下の順に行う。 |
|||
== Apache設定 == |
|||
次のコマンドは、次項のcertbotコマンドにより有効化されるので、実行は不要である。 |
|||
<nowiki> |
|||
$ sudo a2enmod ssl |
|||
$ sudo a2enmod rewrite |
|||
$ sudo systemctl restart apache2 |
|||
</nowiki> |
|||
== Let's Encrypt設定 == |
|||
次のコマンドを実行する。 |
|||
<nowiki> |
|||
$ sudo apt install python3-certbot-apache |
|||
$ sudo certbot --apache |
|||
</nowiki> |
|||
== favicon.ico == |
|||
<nowiki> |
|||
/var/www/html/favicon.ico |
|||
</nowiki> |
|||
=== analog === |
|||
* /etc/analog.cfg |
|||
<nowiki> |
|||
OUTFILE Report.html |
|||
</nowiki> |
|||
<nowiki> |
|||
$ analog /var/log/apache2/access.log* |
|||
$ nkf --url-input Report.html > Report._dec.html |
|||
</nowiki> |
|||
= その他 = |
|||
== Google Search Console == |
|||
ドメインで登録する場合、TXTレコードをDNSサーバに設定する。 |
|||
=== sitemap生成 === |
|||
* https://www.mediawiki.org/wiki/Manual:Sitemap/ja |
|||
* https://www.mediawiki.org/wiki/Manual:GenerateSitemap.php/ja |
|||
MediaWiki バージョン: 1.32 – 1.39 |
|||
<nowiki> |
|||
$ php /usr/share/mediawiki/maintenance/generateSitemap.php --memory-limit=50M --fspath=/path/to/examplecom/sitemap/ --identifier=example.com --urlpath=/sitemap/ --server=https://www.example.com --compress=yes --skip-redirects |
|||
</nowiki> |
|||
=== systemd timerで自動更新 === |
|||
systemdディレクトリ |
|||
/etc/systemd/system |
|||
<nowiki> |
|||
$ sudo systemctl edit --force --full sitemap.service |
|||
</nowiki> |
|||
<nowiki> |
|||
[Unit] |
|||
Description=sitemap |
|||
[Service] |
|||
Type=oneshot |
|||
ExecStart=/usr/bin/php /usr/share/mediawiki/maintenance/generateSitemap.php --memory-limit=50M --fspath=/var/www/html/sitemap/ --identifier=medeshima.com --urlpath=/sitemap/ --server=https://www.medeshima.com --compress=yes --skip-redirects |
|||
</nowiki> |
|||
<nowiki> |
|||
$ sudo systemctl edit --force --full sitemap.timer |
|||
</nowiki> |
|||
<nowiki> |
|||
[Unit] |
|||
Description=sitemap |
|||
[Timer] |
|||
OnCalendar=daily |
|||
AccuracySec=1h |
|||
Persistent=true |
|||
[Install] |
|||
WantedBy=timers.target |
|||
</nowiki> |
|||
<nowiki> |
|||
$ sudo systemctl enable sitemap.timer |
|||
$ sudo systemctl start sitemap.timer |
|||
</nowiki> |
|||
== グローバルIP取得 == |
|||
=== Webサーバ === |
|||
* /var/www/html/ip/index.php |
|||
<nowiki> |
|||
<?php |
|||
header("Content-Type: text/plain;charset=UTF-8"); |
|||
echo $_SERVER['REMOTE_ADDR']; |
|||
?> |
|||
</nowiki> |
|||
=== クライアント === |
|||
<nowiki> |
|||
$ curl https://SERVER/ip/ |
|||
</nowiki> |
|||
==== systemd timer ==== |
|||
~/bin/ip-addr.sh |
|||
<nowiki> |
|||
#!/bin/sh |
|||
/usr/bin/curl -s https://SERVER/ip/ | /usr/bin/mail -s "IP address" MAIL |
|||
</nowiki> |
|||
<nowiki> |
|||
$ chmod +x ~/bin/ip-addr.sh |
|||
</nowiki> |
|||
ユーザ用systemdディレクトリ |
|||
~/.config/systemd/user |
|||
<nowiki> |
|||
systemctl --user edit --force --full ip-addr.service |
|||
</nowiki> |
|||
<nowiki> |
|||
[Unit] |
|||
Description=IP address |
|||
[Service] |
|||
Type=oneshot |
|||
ExecStart=/home/USER/bin/ip-addr.sh |
|||
</nowiki> |
|||
<nowiki> |
|||
systemctl --user edit --force --full ip-addr.timer |
|||
</nowiki> |
|||
<nowiki> |
|||
[Unit] |
|||
Description=IP address |
|||
[Timer] |
|||
#OnCalendar=daily |
|||
OnCalendar=*-*-* 06:00:00 |
|||
AccuracySec=1h |
|||
Persistent=true |
|||
[Install] |
|||
WantedBy=timers.target |
|||
</nowiki> |
|||
<nowiki> |
|||
$ systemctl --user enable ip-addr.timer |
|||
$ systemctl --user start ip-addr.timer |
|||
</nowiki> |
|||
==== cronの場合 ==== |
|||
<nowiki> |
|||
$ crontab -e |
|||
0 6 * * * /usr/bin/curl -s https://SERVER/ip/ | /usr/bin/mail -s "IP" MAIL |
|||
</nowiki> |
2024年5月31日 (金) 14:58時点における最新版
概要
次の表のとおりである。
Webサーバ | Apache |
証明書 | Let's Encrypt |
設定
以下の順に行う。
Apache設定
次のコマンドは、次項のcertbotコマンドにより有効化されるので、実行は不要である。
$ sudo a2enmod ssl $ sudo a2enmod rewrite $ sudo systemctl restart apache2
Let's Encrypt設定
次のコマンドを実行する。
$ sudo apt install python3-certbot-apache $ sudo certbot --apache
favicon.ico
/var/www/html/favicon.ico
analog
- /etc/analog.cfg
OUTFILE Report.html
$ analog /var/log/apache2/access.log* $ nkf --url-input Report.html > Report._dec.html
その他
Google Search Console
ドメインで登録する場合、TXTレコードをDNSサーバに設定する。
sitemap生成
- https://www.mediawiki.org/wiki/Manual:Sitemap/ja
- https://www.mediawiki.org/wiki/Manual:GenerateSitemap.php/ja
MediaWiki バージョン: 1.32 – 1.39
$ php /usr/share/mediawiki/maintenance/generateSitemap.php --memory-limit=50M --fspath=/path/to/examplecom/sitemap/ --identifier=example.com --urlpath=/sitemap/ --server=https://www.example.com --compress=yes --skip-redirects
systemd timerで自動更新
systemdディレクトリ
/etc/systemd/system
$ sudo systemctl edit --force --full sitemap.service
[Unit] Description=sitemap [Service] Type=oneshot ExecStart=/usr/bin/php /usr/share/mediawiki/maintenance/generateSitemap.php --memory-limit=50M --fspath=/var/www/html/sitemap/ --identifier=medeshima.com --urlpath=/sitemap/ --server=https://www.medeshima.com --compress=yes --skip-redirects
$ sudo systemctl edit --force --full sitemap.timer
[Unit] Description=sitemap [Timer] OnCalendar=daily AccuracySec=1h Persistent=true [Install] WantedBy=timers.target
$ sudo systemctl enable sitemap.timer $ sudo systemctl start sitemap.timer
グローバルIP取得
Webサーバ
- /var/www/html/ip/index.php
<?php header("Content-Type: text/plain;charset=UTF-8"); echo $_SERVER['REMOTE_ADDR']; ?>
クライアント
$ curl https://SERVER/ip/
systemd timer
~/bin/ip-addr.sh
#!/bin/sh /usr/bin/curl -s https://SERVER/ip/ | /usr/bin/mail -s "IP address" MAIL
$ chmod +x ~/bin/ip-addr.sh
ユーザ用systemdディレクトリ
~/.config/systemd/user
systemctl --user edit --force --full ip-addr.service
[Unit] Description=IP address [Service] Type=oneshot ExecStart=/home/USER/bin/ip-addr.sh
systemctl --user edit --force --full ip-addr.timer
[Unit] Description=IP address [Timer] #OnCalendar=daily OnCalendar=*-*-* 06:00:00 AccuracySec=1h Persistent=true [Install] WantedBy=timers.target
$ systemctl --user enable ip-addr.timer $ systemctl --user start ip-addr.timer
cronの場合
$ crontab -e 0 6 * * * /usr/bin/curl -s https://SERVER/ip/ | /usr/bin/mail -s "IP" MAIL