uetennis’s diary

プログラミングについて学んだ事やライフハックについてかきます

SSLで嵌り倒している事を解決させる事に挑戦したい

SSLで嵌り倒している事を解決させる事に挑戦したい

目標・やりたい事は何か?何に興味あるか?

[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
 failed!

の問題を解決させたい - こちらの日報で’systemctl status nginx.service”と "journalctl -xe" を調べる事ができるみたいだ。 - $ sudo systemcl status nginx.service$ sudo journalctl -xeを開く

  1. キー(認証と証明書,csr,crt)をホームディレクトリにあるから移動させるか消して作り直す。

  2. オレオレ証明書作りたい

  3. Let’s EncryptSSL証明書取得したい
  4. Rubymineを試したい。vscodeとどっちにしようかなと思う。
  5. エディターの事を調べるのは結構楽しい

日常メモ・ちょっとした事・何を感じたか?

  • 夜に日記や日報を書こうとすると順調な時は書けるけど、何かで嵌り倒すと後回しにしがちだから朝に書く事を試す。
  • Dashのスニペット機能はすごく便利

勉強メモ 復習

nginx で VirtualHost を使って複数のドメインのサイトを立ち上げ

#  locateコマンドはファイルのパスを調べるのに便利
~$ sudo apt install locate
#nslookupのコマンドインストール
root# apt-get install dnsutils
#DNSが設定されているか調べる
~$ nslookup nginxnohimitu.work
Server: 210.188.224.10
Address: 210.188.224.10#5
~$ nslookup nekonohimitu.work
Server: 210.188.224.10
Address: 210.188.224.10#5
# /srv/以下に提供するコンテンツを置く  srvの代わりにpublicでも他の名前でもいい
:~$ sudo mkdir -p /srv/nekonohimitu.work/{public,private,log,backup}
 # index.htmlを作成しhtmlを記述
:~$ sudo vim /srv/nekonohimitu.work/public/index.html
<!DOCTYPE html>
<html lang="ja"
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>yoshihiro-VirtualHost</title>
</head>
<h1>yoshihiro-VirtualHost</h1
<body>
  <h1>yoshihiro-VirtualHost</h1>
  <p>VirtualHost-test</p>
  <p>VirtualHost-test</p>
  <p>VirtualHost-test</p>
  <p>VirtualHost-test</p>
  <p>VirtualHost-test</p>
</body>
</html>
# wwwの/srv/以下に提供するコンテンツを置く
sudo mkdir -p /srv/www.nekonohimitu.work/{public,private,log,backup}
#2つめの index.htmlを作成しhtmlを記述
:~$ sudo vim /srv/www.nekonohimitu.work/public/index.html
<!DOCTYPE html>
<html lang="ja"
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>nginxnohimitu</title>
</head>
<h1>nginxnohimitu</h1
<body>
  <h1>nginxnohimitu</h1>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
  <p>VirtualHostですーーー</p>
</body>
</html>
sudo mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled #設定ファイル置き場(available)と設定ファイルを作成(enabled
~$ sudo vim /etc/nginx/sites-available/nekonohimitu.work #設定ファイルを記
server {
  listen 80;
  server_name nekonohimitu.work;
  access_log /srv/nekonohimitu.work/log/access.log;
  error_log /srv/nekonohimitu.work/log/error.log;
  location / {
    root /srv/nekonohimitu.work/public/;
    index index.html;
  }
}
server {
  listen 80;
  server_name www.nekonohimitu.work;
  access_log /srv/www.nekonohimitu.work/log/access.log;
  error_log /srv/www.nekonohimitu.work/log/error.log;
  location / {
    root /srv/www.nekonohimitu.work/public/;
    index index.html;
  }
}

#シンボリックリンクを作成
:~$ sudo ln -s /etc/nginx/sites-available/nekonohimitu.work /etc/nginx/sites-enabled/nekonohimitu.work
サイトを無効化するときにsites-enabled のリンクを消すだけでいい。シンボリックリンクのもう一つの使い方(sites-availavleの設定ファイ
ルは残る)→読み込みはsites-enabledでリンクを読み込んでいる
# /etc/nginx/nginx.confの設定ファイルをコピ-
:~$ sudo cp -p /etc/nginx/nginx.conf /etc/nginx/nginx.conf.org
:~$ sudo vim /etc/nginx/nginx.conf
##
# Virtual Host Configs
#
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
include /etc/nginx/sites-enabled/*.work; #追記 最初記述した時は[;]がなくて構文エラー

:~$ sudo /etc/init.d/nginx start #起動せず
[....] Starting nginx (via systemctl): nginx.serviceJob for nginx.service failed because the control process exited
with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
failed
:~$ sudo nginx -t #構文チェック
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:64
nginx: configuration file /etc/nginx/nginx.conf test faile
include /etc/nginx/sites-enabled/*.work ; #[;]がなかっ
# ネイキッドドメイン(wwwがない)は読み込んでるけど、wwwのドメインは読み込まれない
~$ nslookup www.nekonohimitu.work
Server: 210.188.224.10
Address: 210.188.224.10#5
** server cant find www.nekonohimitu.work: NXDOMAIN #wwwはみつかってないよ
# 原因はお名前ドットコムでDNSの設定していな
nslookup www.nekonohimitu.work #DNSの設定したらOK
Server: 210.188.224.10
Address: 210.188.224.10#5
:~$ sudo nginx -t
nginx: [warn] conflicting server name "nekonohimitu.work" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.nekonohimitu.work" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfu
#再起動
~$ sudo /etc/init.d/nginx stop
~$ sudo /etc/init.d/nginx start