1. SSHログイン
ssh ubuntu@* -i ~/.ssh/*.pem
2. apt update
$ sudo apt update
$ sudo apt upgrade
3. mysql
$ sudo apt install mysql-client-core-8.0
$ sudo apt-get update
$ sudo apt install mysql-server
$ mysqld –version
$ sudo service mysql start
$ sudo mysql_secure_installation
$ sudo mysql -u root -p
mysql> create database hanbai;
4. Nginx install
$ sudo apt install nginx
5. 仮想環境作成
$ sudo apt install python3-venv python3-pip python3-dev
$ sudo chown ubuntu /home
$ git clone https://github.com/*/*.git
$ cd hanbai
$ ls
README.md db.sqlite3 hanbai manage.py sales
$ python3 -m venv vdjango
$ . vdjango/bin/activate
(vdjango)$ pip3 install Django==3.0.4
(vdjango)$ pip3 install uwsgi
$ sudo ufw allow 80
6. Nginx設定
$ cd /etc/nginx/conf.d
$ sudo vi project.conf
server{ listen 80; server_name ${publicIp}; location / { proxy_pass http://127.0.0.1:8000; } }
7. iniファイル
$ ls
README.md db.sqlite3 hanbai manage.py sales vdjango
$ vim django.ini
[uwsgi] module = project.wsgi:application master = true pidfile = django.uwsgi.pid enable-threads = true http = 127.0.0.1:8000 processes = 5 harakiri = 50 max-requests = 5000 vacuum = true home = vdjango daemonize = django.uwsgi.log
8. library install & migration
// 省略
9. Nginxとuwsgi起動
$ sudo service nginx start
$ sudo apt-get install -y uwsgi
$ sudo apt install uwsgi-plugin-python3
うーん、
$ sudo python3 manage.py runserver 0.0.0.0:8000 で8000ポート開けても動くんだけど、なんか違うんだよな。。