Linux のパッケージをアップデート
以下のコマンドを実行して、パッケージをアップデートします。
sudo dnf -y update
EPEL リポジトリも以下のコマンドを実行して追加します。
sudo dnf -y install epel-release
以下のコマンドを実行して、パッケージをアップデートします。
sudo dnf -y update
EPEL リポジトリも以下のコマンドを実行して追加します。
sudo dnf -y install epel-release
Python、pyenv、venv については、以下のリンク先を参考にしてください。
Python のパッケージをインストールします。
pip install flask
Waitress をインストールするには、以下のコマンドを実行します。
pip install gunicorn
Gunicorn をインストールするには、以下のコマンドを実行します。
pip install waitress
以下のコマンドを実行して、Apache をインストールします。
# インストール
sudo dnf -y install httpd
# 起動
sudo systemctl start httpd
# httpd の状態の確認
sudo systemctl status httpd
# 自動起動の有効化
sudo systemctl enable httpd
Apache のログの場所は、以下の場所です。
# エラーログ
sudo less /var/log/httpd/error_log
# アクセスログ
sudo less /var/log/httpd/access_log
設定ファイルは、以下の場所にあります。
# メインの設定ファイル
/etc/httpd/conf/httpd.conf
# 補助設定ファイル。以下のディレクトリにファイルを作成
/etc/httpd/conf.d
以下のコマンドを実行して、Apache をインストールします。
# インストール
sudo dnf -y install nginx
# 起動
sudo systemctl start nginx
# nginx の状態の確認
sudo systemctl status nginx
# 自動起動の有効化
sudo systemctl enable nginx
Nginx のログは、以下の場所です。
# エラーログ
sudo less /var/log/nginx/error.log
# アクセスログ
sudo less /var/log/nginx/access.log
設定ファイルは、以下の場所にあります。
# メインの設定ファイル
/etc/nginx/nginx.conf
# 補助設定ファイル。以下のディレクトリにファイルを作成
/etc/nginx/conf.d
ファイアウォールの設定にウェブサーバーの設定を追加します。
sudo firewall-cmd --add-service=http --zone=public --permanent
sudo firewall-cmd --add-service=https --zone=public --permanent
sudo firewall-cmd --reload
サンプルの Flask アプリは、8000番ポートを利用しています。8000番ポートを開けるには、以下のコマンドを実行します。
sudo firewall-cmd --permanent --zone=public --add-port=8000/tcp && sudo firewall-cmd --reload
サンプルアプリを使う場合は、GitHub からダウンロードしてください。
git clone https://github.com/beginnerP765/flaskapp.git