- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-01-22T15:28:48+09:00","default:kouzouken","kouzouken")
#author("2020-02-07T12:42:01+09:00","default:kouzouken","kouzouken")
#contents
*サーバ版 [#f43a92c8]
**インストール [#r358128c]
-http://studio-bey.chicappa.jp/dougubako/ubuntu_server/382
--apache2を入れるときはLAMP serverを選択
-http://www.server-world.info/query?os=Ubuntu_10.04&p=x
**Ubuntu18.04.3サーバー版 [#s0b59f5e]
-https://www.yokoweb.net/2018/05/04/ubuntu-18_04-lts-server-install/
-言語選択は日本語はないので、Englishを選択
-キーボードは、Japanese
-Network connectionsで、eno1 eth のところを選択してエンターを押し、Edit IPv4を選択してエンター
--IPv4 Method: Manual
--Subnet: 123.123.123.0/24
--Address: 123.123.123.123
--Gateway: 123.123.123.1
--Name server: DNSのアドレス
--Search domains: 空欄
-Configure proxy
--Proxy address: http://hoge.akita-u.ac.jp:8080/
-Filesystem setup
--Use An Entire Disk を選択
--Choose the disk to install to: 選択されたハードディスクを選択
--Are you sure you want to continue?: Continue
-Profile setup
--ここで入れたユーザー名が管理者になるので、ウェブ公開など、一般ユーザーで使いたいユーザー名とは別にしておく
-SSH Setup
--[X] Install OpenSSH server
--Import SSH identity: No
-Featured Server Snaps 特に選択するものはないような
-Installation comlete! まだ始まってないんでは...?
--View full logを選択してエンターするとlogが表示されるだけ
--Rebootしてみるか(いつのまにインストールしてたの?)
-ディスクが出てきたのを取り出してエンターすると再起動
--(
[ OK ] Reached target Cloud-init target.
--)
みたいなところで止まってるなあと思って、エンターを押してみたら、
login:カーソルが出てくるので、ログインする。
一般ユーザーなので、sudo suでrootになる。
プロキシの設定とか、しなくて大丈夫かわからないが、まずは、MATEが入るかどうかやってみる。
--(
# apt -y install ubuntu-mate-desktop
--)
-Menu->AllのLanguage SupportのInstall/Remove LanguagesからJapaneseをインストールすると、Language for menus and windows:欄のEnglishの下に日本語が現れるので、日本語をマウスでドラッグして、Englishの上に持っていく(ちょっとコツがいる)
**rootログイン禁止、管理者ログインも禁止 [#g79e9fa2]
-/etc/ssh/の中のsshd_configをsshd_config.orgにバックアップを取ってから、
#PermitRootLogin prohibit-password
の行を(1行コピーしてコメントはずして)
PermitRootLogin no
DenyUsers admin
に変更。
# sshd -t
で構文チェックし、何もエラーが表示されなければ、以下でsshdをリスタート。
# /etc/init.d/ssh restart
**visudoエディターの変更(不採用) [#b3a45834]
# update-alternatives --config editor
sudoersを修正して、管理者アカウントからのsshログインを禁止しようと思ったのだけど、
admin ALL=(ALL:ALL) ALL, !/usr/bin/ssh
みたいにやっても、adminでsshログインできてしまう。上記のsshd_configで禁止する方がよい。
**タイムゾーンの変更 [#b9afbcb9]
timedatectl set-timezone Asia/Tokyo
確認は、timedatectl
**サービス管理 [#fd12bb22]
***サービス一覧 [#t469a74b]
---(
# systemctl list-unit-files -t service
---)
Vine Linuxだとサービス管理がGUIで行えて便利だったのだけど、systemctlのGUIフロントエンドとかないものか。ちょっと検索した感じだとなさそうな...
**crontab [#q490079e]
00 00 * * * updatedb
00 01 * * * apt-get update && apt-get -y upgrade >/media/admin/hdd/apt.log
00 02 * * * rsync -auv /var/www/cgi-bin /media/admin/hdd/ > /media/admin/hdd/cgi.log
00 03 * * * rsync -auv /var/www/html /media/admin/hdd/ > /media/admin/hdd/html.log
**FTPサーバー [#p2ea476d]
FTPサーバーはftpdではなく、vsftpdをインストール。
ftpdも使えるが、systemctl list-unit-files -t serviceをやってもサービス一覧に現れないので、サービス管理の方法が不明。vsftpdなら、サービス一覧に現れる。
***gftpでアップロードできるようにする [#x7cad5df]
vsftpdはデフォールトでは書き込み禁止になっているので、/etc/vsftpd.conf の以下のコメントを外して有効にする
write_enable=YES
そして、service vsftpd restart
*apache2 [#qf8acacc]
--/etc/apache2/mods-available/cgi.load を/etc/apache2/mods-enabled/ に以下でシンボリックリンクを作成(下記のhttpsの設定を先にやるなら不要かも)
ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
--/etc/apache2/apache2.confに以下を追加
DirectoryIndex index.html index.html.var index.cgi index.php
ServerTokens Prod
KeepAlive On
--.htaccessを使うなら以下を修正
AllowOverride None
を
AllowOverride ALL
に。
-古い.htaccessのgroupfileの項は削除
--/etc/apache2/conf-available/serve-cgi-bin.confの以下の箇所を修正
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
を
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">
に。
--.htaccessを使うなら以下を修正
AllowOverride None
を
AllowOverride ALL
に。
--pukiwikiがcgi-binディレクトリ内のスタイルシートや画像を参照できるように以下も追加
AddHandler skin/css css
AddHandler image/png png
-各ユーザーのpublic_htmlが使えるようにする
a2enmod
と打つと、
Which module(s) do you want to enable (wildcards ok)?
と聞かれるので、
userdir
と打ち、
service apache2 restart
-apache2の再起動
service apache2 restart
**https [#a19fcab5]
-SSLモジュールとバーチャルホストの有効化
# a2enmod ssl
# a2ensite default-ssl
# service apache2 restart
これを実行することでmods-availableへのシンボリックリンクがmods-enabledに置かれ、
sites-availableへのシンボリックリンクがsites-enabledに置かれることになるようなので、上記のapache2の手動でリンクを貼る作業は不要かも。
-&link(Let's Encryptの無料SSL/TLSサーバ証明書,https://chee-s.net/ubuntu%E3%81%A7lets-encrypt%E3%81%AE%E7%84%A1%E6%96%99ssl-tls%E3%82%B5%E3%83%BC%E3%83%90%E8%A8%BC%E6%98%8E%E6%9B%B8%E3%82%92%E5%8F%96%E5%BE%97%E3%81%99%E3%82%8B)
そもそもk2とか外部に公開されてないサーバーでサーバー証明書を取れないのかもしれないが、
まずは、/var/www/html/.well-known/acme-challenge のディレクトリを作成してから、
# certbot certonly --webroot -w /var/www/html -d k2.hoge.jp
を実行。すると、以下のエラー
Failed authorization procedure. k2.hoge.jp (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://k2.hoge.jp/.well-known/acme-challenge/dE9RRQ6FNEVCiUiKUWGPJhnI3KEoAScLREcWBUBwGQk: Timeout during connect (likely firewall problem)
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: k2.hoge.jp
Type: connection
Detail: Fetching
http://k2.hoge.jp/.well-known/acme-challenge/dE9RRQ6FNEVCiUiKUWGPJhnI3KEoAScLREcWBUBwGQk:
Timeout during connect (likely firewall problem)
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address. Additionally, please check that
your computer has a publicly routable IP address and that no
firewalls are preventing the server from communicating with the
client. If you're using the webroot plugin, you should also verify
that you are serving files from the webroot path you provided.
うまくいった場合は、
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/hogehoge.jp/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/hogehoge.jp/privkey.pem
Your cert will expire on 2020-04-18. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- 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
みたいに出る。
このログをコピペして、encrypt.logとかに保存しておく。
/etc/apache2/sites-availableに移動し、default-ssl.confの中の
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
の部分を、encrypt.logを参照しながら、
SSLCertificateFile /etc/letsencrypt/live/hogehoge.jp/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hogehoge.jp/privkey.pem
みたいに書き換えて、service apache2 restart
これで、/var/www/html の中も/var/www/cgi-bin の中も /home/hoge/public_html の中もhttps://でアクセスできるよう。
-https://www.str.ce.akita-u.ac.jp/kouzou/
-https://www.str.ce.akita-u.ac.jp/~gotou/
-有効期間が30日未満の証明書の更新
# certbot renew
毎月1日の0時0分に実行するなら、crontabに以下のように書いておく
00 00 1 * * certbot renew
**pukiwiki [#x1639f4a]
まず、synapticからphpをインストールすると、最新バージョンのphp7.2がインストールされる
-https://pukiwiki.osdn.jp/
/var/www/cgi-bin/pukiwiki/に展開するだけでいい
左のメニューを上寄せで表示にするには、
/var/www/cgi-bin/pukiwiki/skin/pukiwiki.skin.phpの160行目辺りの
<td class="menubar">
を
<td class="menubar" valign="top">
に変更。
-mathjax.inc.phpのインストール
-https://dev.abicky.net/pukiwiki/plugins/index.php?mathjax.inc.php#rd5e4380
-mathjax.inc.phpを/var/www/cgi-bin/pukiwiki/plugin/にコピー
-convert_html.php.patchとmake_link.php.patchを/var/www/cgi-bin/pukiwiki/lib/にコピー(下記をパス付きで実行するならコピー不要)
-patch<convert_html.php.patchとpatch<make_link.php.patchを実行
-httpsで使うには、mathjax.inc.phpの中の以下のアドレスをhttpからhttpsに変更
define('MATHJAX_URL', 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML');
この修正をしないと、httpからは数式表示できるが、httpsからは数式表示できなくなる。
この修正をすると、httpからでもhttpsからでも数式表示できる(ブラウザーにもよるかもしれないが)
***編集制限 [#vcacd9ec]
-編集ユーザーをhoge, そのパスワードをhogehogeとすると、以下でmd5のハッシュ値を取得
$ echo -n "hogehoge" |md5sum
-pukiwiki.ini.phpを編集
$edit_auth = 1;
$auth_users = array(
// Username => password
'hoge' => '{x-php-md5}329435e5e66be809a656af105f42401e',
);
$edit_auth_pages = array(
// Regex Username
'##' => 'hoge',
);
***adminパスワード [#v41b8dd4]
凍結解除やadminしか編集できないページを編集するパスワードは、pukiwiki.ini.phpの
$adminpass = '{x-php-md5}!';
を
$adminpass = 'kanrisyanopasuwaado';
みたいに書き換える。
***スタイルや画像バナーが読み込まれない [#ufc92e60]
上記のapache2の設定のとこを参照して、/etc/apache2/conf-available/serve-cgi-bin.confを書き換える。
***検索すると文字化け [#w7a58b7c]
根本解決ではないのだが、対処療法ということであれば、
libの中のhtml.phpの以下の箇所に//をつけてコメントアウトする。
//$body = preg_replace_callback($whole_pattern, '_decorate_Nth_word', $body);
根本解決のためには、php.iniを編集してmbstringを有効にするとからしいのだけど、どうも、この方法がうまくいかないので。
**enq.cgi [#c36ec931]
結城さんのアンケートcgiのenq.cgiを使う場合は、
enq.cgi内のjcode.plのパスの箇所を以下のように絶対パスに修正。
require "$jcodelib";
を
require "/var/www/cgi-bin/hoge/jcode.pl";
みたいに。
[[この辺:https://piano2nd.smb.net/PukiWiki/index.php?jcode.pl]]
から新しいjcode.plを持ってきて置き換える。
**IPアドレスの変更 [#b92e8bdf]
-/etc/netplan/50-cloud-init.yaml を編集
-netplan applyで反映
-ip addr で確認