Open7
create mkdocs server on AWS Amazon Linux 2023 EC2
-
参考ブログ : MkDocsによるドキュメント作成
-
OS:Amazon Linux 2023
- サービス:EC2
- インスタンス
- セキュリティ
- インバウンドルール:以下を追加
- セキュリティ
- インスタンス
- サービス:EC2
-
インバウンドルール
ポート範囲 | プロトコル | 送信先 | セキュリティグループ |
---|---|---|---|
8000 | すべて | 0.0.0.0/0 | launch-wizard-2 |
- セキュリティグループ:aunch-wizard-2
IPバージョン | タイプ | プロトコル | ポート範囲 | ソース |
---|---|---|---|---|
IPv4 | カスタム TCP | TCP | 8000 | 0.0.0.0/0 |
- (base) macpro:aws sharland$
ssh -i "protoTeruroom.pem" ec2-user@パブリック IPv4 DNS
ssh -i "protoTeruroom.pem" ec2-user@パブリック IPv4 アドレス
- [ec2-user@ip-172-31-44-51 ~]$
sudo yum update
実行結果
Last metadata expiration check: 0:39:41 ago on Sun Jun 11 02:04:48 2023.
Dependencies resolved.
Nothing to do.
Complete!
- [ec2-user@ip-172-31-44-51 ~]$
python3 --version
Python 3.9.16
- [ec2-user@ip-172-31-44-51 ~]$
yum info python3
実行結果
Amazon Linux 2023 repository [=== ] --- B/s | 0 B Amazon Linux 2023 repository 38% [===================== ] 18 MB/s | 5.4 MB Amazon Linux 2023 repository 32 MB/s | 14 MB 00:00
Amazon Linux 2023 Kernel Livepatch repository [=== ] --- B/s | 0 B Amazon Linux 2023 Kernel Livepatch repository 759 kB/s | 156 kB 00:00
Installed Packages
History database cannot be created, using in-memory database instead: SQLite error on "/var/lib/dnf/history.sqlite": Open failed: unable to open database file
Name : python3
Version : 3.9.16
Release : 1.amzn2023.0.3
Architecture : x86_64
Size : 33 k
Source : python3.9-3.9.16-1.amzn2023.0.3.src.rpm
Repository : @System
Summary : Python 3.9 interpreter
URL : https://www.python.org/
License : Python
Description : Python 3.9 is an accessible, high-level, dynamically typed, interpreted
: programming language, designed with an emphasis on code readability.
: It includes an extensive standard library, and has a vast ecosystem of
: third-party libraries.
:
: The python3 package provides the "python3" executable: the reference
: interpreter for the Python language, version 3.
: The majority of its standard library is provided in the python3-libs package,
: which should be installed automatically along with python3.
: The remaining parts of the Python standard library are broken out into the
: python3-tkinter and python3-test packages, which may need to be installed
: separately.
:
: Documentation for Python is provided in the python3-docs package.
:
: Packages containing additional libraries for Python are generally named with
: the "python3-" prefix.
- [ec2-user@ip-172-31-44-51 ~]$
sudo yum install pip
実行結果
Last metadata expiration check: 0:41:32 ago on Sun Jun 11 02:04:48 2023.
Dependencies resolved.
======================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================
Installing:
python3-pip noarch 21.3.1-2.amzn2023.0.5 amazonlinux 1.8 M
Installing weak dependencies:
libxcrypt-compat x86_64 4.4.33-7.amzn2023 amazonlinux 92 k
・・・・
Installed:
libxcrypt-compat-4.4.33-7.amzn2023.x86_64 python3-pip-21.3.1-2.amzn2023.0.5.noarch
Complete!
- [ec2-user@ip-172-31-44-51 ~]$
pip --version
実行結果
pip 21.3.1 from /usr/lib/python3.9/site-packages/pip (python 3.9)
- [ec2-user@ip-172-31-44-51 mkdocs]$
pip install --upgrade pip
実行結果
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /usr/lib/python3.9/site-packages (21.3.1)
Collecting pip
Downloading pip-23.1.2-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 6.0 MB/s
Installing collected packages: pip
Successfully installed pip-23.1.2
- [ec2-user@ip-172-31-44-51 mkdocs]$
sudo yum install tree
実行結果
Last metadata expiration check: 1:12:44 ago on Sun Jun 11 02:04:48 2023.
Dependencies resolved.
======================================================================================================================================================
Package Architecture Version Repository Size
======================================================================================================================================================
Installing:
tree x86_64 1.8.0-6.amzn2023.0.2 amazonlinux 56 k
Transaction Summary
======================================================================================================================================================
Install 1 Package
Total download size: 56 k
Installed size: 113 k
Is this ok [y/N]: y
Downloading Packages:
[=== ] --- B/s | 0 B tree-1.8.0-6.amzn2023.0.2.x86_64.rpm 0% [ ] --- B/s | 0 B tree-1.8.0-6.amzn2023.0.2.x86_64.rpm 548 kB/s | 56 kB 00:00
------------------------------------------------------------------------------------------------------------------------------------------------------
Total 330 kB/s | 56 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [ Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [======================== Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [================================================= Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [================================================================= Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [================================================================== Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [================================================================================ Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [=================================================================================== Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 [=================================================================================== Installing : tree-1.8.0-6.amzn2023.0.2.x86_64 1/1
Running scriptlet: tree-1.8.0-6.amzn2023.0.2.x86_64 1/1
Verifying : tree-1.8.0-6.amzn2023.0.2.x86_64 1/1
Installed:
tree-1.8.0-6.amzn2023.0.2.x86_64
Complete!
- [ec2-user@ip-172-31-44-51 ~]$
mkdir mkdocs && cd mkdocs
- [ec2-user@ip-172-31-44-51 mkdocs]$
python3 -m venv ./venv
- [ec2-user@ip-172-31-44-51 mkdocs]$
. venv/bin/activate
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
pip install --upgrade pip
実行結果
Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (21.3.1)
Collecting pip
Using cached pip-23.1.2-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
Successfully installed pip-23.1.2
- [ec2-user@ip-172-31-44-51 mkdocs]$
pip install mkdocs
実行結果
Collecting mkdocs
Using cached mkdocs-1.4.3-py3-none-any.whl (3.7 MB)
Collecting click>=7.0 (from mkdocs)
Using cached click-8.1.3-py3-none-any.whl (96 kB)
Collecting ghp-import>=1.0 (from mkdocs)
Using cached ghp_import-2.1.0-py3-none-any.whl (11 kB)
Collecting importlib-metadata>=4.3 (from mkdocs)
Using cached importlib_metadata-6.6.0-py3-none-any.whl (22 kB)
Collecting jinja2>=2.11.1 (from mkdocs)
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 6.5 MB/s eta 0:00:00
Collecting markdown<3.4,>=3.2.1 (from mkdocs)
Using cached Markdown-3.3.7-py3-none-any.whl (97 kB)
Collecting mergedeep>=1.3.4 (from mkdocs)
Using cached mergedeep-1.3.4-py3-none-any.whl (6.4 kB)
Collecting packaging>=20.5 (from mkdocs)
Using cached packaging-23.1-py3-none-any.whl (48 kB)
Collecting pyyaml-env-tag>=0.1 (from mkdocs)
Using cached pyyaml_env_tag-0.1-py3-none-any.whl (3.9 kB)
Collecting pyyaml>=5.1 (from mkdocs)
Downloading PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (661 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 661.8/661.8 kB 22.5 MB/s eta 0:00:00
Collecting watchdog>=2.0 (from mkdocs)
Using cached watchdog-3.0.0-py3-none-manylinux2014_x86_64.whl (82 kB)
Collecting python-dateutil>=2.8.1 (from ghp-import>=1.0->mkdocs)
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 247.7/247.7 kB 24.8 MB/s eta 0:00:00
Collecting zipp>=0.5 (from importlib-metadata>=4.3->mkdocs)
Using cached zipp-3.15.0-py3-none-any.whl (6.8 kB)
Collecting MarkupSafe>=2.0 (from jinja2>=2.11.1->mkdocs)
Downloading MarkupSafe-2.1.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting six>=1.5 (from python-dateutil>=2.8.1->ghp-import>=1.0->mkdocs)
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: zipp, watchdog, six, pyyaml, packaging, mergedeep, MarkupSafe, click, pyyaml-env-tag, python-dateutil, jinja2, importlib-metadata, markdown, ghp-import, mkdocs
Successfully installed MarkupSafe-2.1.3 click-8.1.3 ghp-import-2.1.0 importlib-metadata-6.6.0 jinja2-3.1.2 markdown-3.3.7 mergedeep-1.3.4 mkdocs-1.4.3 packaging-23.1 python-dateutil-2.8.2 pyyaml-6.0 pyyaml-env-tag-0.1 six-1.16.0 watchdog-3.0.0 zipp-3.15.0
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
mkdocs --version
実行結果
mkdocs, version 1.4.3 from /home/ec2-user/mkdocs/venv/lib64/python3.9/site-packages/mkdocs (Python 3.9)
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
pip install click-man
実行結果
Collecting click-man
Downloading click_man-0.4.1-py3-none-any.whl (9.1 kB)
Requirement already satisfied: click in ./venv/lib/python3.9/site-packages (from click-man) (8.1.3)
Installing collected packages: click-man
Successfully installed click-man-0.4.1
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
mkdir man && click-man --target ./man mkdocs
実行結果
Load entry point mkdocs
Generate man pages for mkdocs in /home/ec2-user/mkdocs/man
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
ls man
実行結果
mkdocs-build.1 mkdocs-gh-deploy.1 mkdocs-new.1 mkdocs-serve.1 mkdocs.1
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
mkdocs new proto-proj
実行結果
INFO - Creating project directory: proto-proj
INFO - Writing config file: proto-proj/mkdocs.yml
INFO - Writing initial docs: proto-proj/docs/index.md
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
cd proto-proj/ && tree
実行結果
.
├── docs
│ └── index.md
└── mkdocs.yml
1 directory, 2 files
- (venv) [ec2-user@ip-172-31-44-51 proto-proj]$
mkdocs serve -a 0.0.0.0:8000
実行結果
IWARNING - Config value 'dev_addr': The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the
MkDocs server. However, the MkDocs' server is intended for local development purposes only. Please use a third party production-ready
server instead.
INFO - Building documentation...
INFO - Cleaning site directory
INFO - Documentation built in 0.07 seconds
INFO - [03:51:42] Watching paths for changes: 'docs', 'mkdocs.yml'
INFO - [03:51:42] Serving on http://0.0.0.0:8000/
- URL:http://35.72.10.201:8000/
- パブリック IPv4 アドレス:
35.72.10.201
- パブリック IPv4 アドレス:
- [ec2-user@ip-172-31-44-51 proto-proj]$
curl 'https://jaspervdj.be/lorem-markdownum/markdown.txt' > docs/about.md
実行結果
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1772 0 1772 0 0 1219 0 --:--:-- 0:00:01 --:--:-- 1220
- [ec2-user@ip-172-31-44-51 proto-proj]$
vim mkdocs.yml
mkdocs.yml
site_name : ProtoPlan
site_url: http://35.72.10.201:8000/
theme:
name: material
nav:
- 要件定義:
- Version1: requirement/index.md
- プロトタイプ:
- コンセプト: prototype/index.md
- Home: index.md
- About: about.md
plugins:
- awesome-pages
:::
- [ec2-user@ip-172-31-44-51 mkdocs]$
touch requirements.txt && vim requirements.txt
requirements.txt
mkdocs
mkdocs-material
pymdown-extensions
mkdocs-awesome-pages-plugin
pygments
- (venv) [ec2-user@ip-172-31-44-51 mkdocs]$
pip install -r requirements.txt
実行結果
Requirement already satisfied: mkdocs in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (1.4.3)
Collecting mkdocs-material (from -r requirements.txt (line 2))
Using cached mkdocs_material-9.1.15-py3-none-any.whl (7.8 MB)
Collecting pymdown-extensions (from -r requirements.txt (line 3))
Downloading pymdown_extensions-10.0.1-py3-none-any.whl (240 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 240.1/240.1 kB 8.6 MB/s eta 0:00:00
・・・・・
Successfully installed certifi-2023.5.7 charset-normalizer-3.1.0 colorama-0.4.6 idna-3.4 mkdocs-material-9.1.15 mkdocs-material-extensions-1.1.1 pygments-2.15.1 pymdown-extensions-10.0.1 regex-2023.6.3 requests-2.31.0 urllib3-2.0.3
- [ec2-user@ip-172-31-44-51 ~]$
cd /home/ec2-user/mkdocs/proto-proj/docs
- [ec2-user@ip-172-31-44-51 docs]$
mkdir requirement && mkdir prototype
- [ec2-user@ip-172-31-44-51 docs]$
touch requirement/index.md && vim requirement/index.md
requirement/index.md
# 要件定義
## はじめに
- [ec2-user@ip-172-31-44-51 docs]$
touch prototype/index.md && vim prototype/index.md
requirement/index.md
# プロトタイプ開発
## はじめに
- [ec2-user@ip-172-31-44-51 proto-proj]$
vim mkdocs.yml
/home/ec2-user/mkdocs/proto-proj/mkdocs.yml
site_name : ProtoPlan
site_url: http://35.72.10.201:8000/
theme:
feature:
tabs: true
language: ja
name: material
palette:
accent: Blue
primary: Blue
extra_javascript:
- javascripts/extra.js
- https://cdnjs.cloudflare.com/ajax/libs/tablesort/5.2.1/tablesort.min.js
- iavascripts/tables.js
extra css:
- "https://fonts.googleapis.com/earlyaccess/notosansjp.css"
- "https://fonts.googleapis.com/css?family=Open+ Sans:600,800"
- "css/custom.css"
markdown -extensions:
- codehilite
plugins:
- awesome-pages
- URL : ç
- [ec2-user@ip-172-31-44-51 proto-proj]$
mkdocs build
- [ec2-user@ip-172-31-44-51 proto-proj]$
tree site
site
├── 404.html
├── about
│ └── index.html
├── css
│ ├── base.css
│ ├── bootstrap.min.css
│ └── font-awesome.min.css
├── fonts
│ ├── fontawesome-webfont.eot
│ ├── fontawesome-webfont.svg
│ ├── fontawesome-webfont.ttf
│ ├── fontawesome-webfont.woff
│ └── fontawesome-webfont.woff2
├── img
│ ├── favicon.ico
│ └── grid.png
├── index.html
├── js
│ ├── base.js
│ ├── bootstrap.min.js
│ └── jquery-1.10.2.min.js
├── prototype
│ └── index.html
├── requirement
│ └── index.html
├── search
│ ├── lunr.js
│ ├── main.js
│ ├── search_index.json
│ └── worker.js
├── sitemap.xml
└── sitemap.xml.gz