0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

環境構築

Last updated at Posted at 2019-07-06

python(Django)準備

1 Apache準備

折りたたみ

1-1 python3インストール

折りたたみ
apt install puthon3

1-2 必要に応じてpythonをリンク

折りたたみ
unlinl /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python

1-3 pipからDjangoインストール

折りたたみ
pip install django

1-4 install apache2

折りたたみ
apt install apache2 apache2-dev
apt-get install mysql-server

# 必要であれば
apt install apache2-utils ssl-cert
pip install mysqlclient
apt install build-essential libssl-dev libffi-dev python-dev

1-5 mod_wsgi適用

折りたたみ
pip install mod-wsgi
## 必要に応じて
sudo apt-get install libapache2-mod-wsgi
sudo apt-get install libapache2-mod-wsgi-py3

1-6 wsgi設定、動作確認

折りたたみ
### テスト用ファイル用意
def application(environ,start_response):
    status = '200 OK'
    html = '<html>\n' \
           '<body>\n' \
           ' Hooray, mod_wsgi is working\n' \
           '</body>\n' \
           '</html>\n'
    response_header = [('Content-type','text/html')]
    start_response(status,response_header)
    return [html]

wsgi関連の設定

apache設定を追加

python3 -c "import sys; print(sys.path)"
mod_wsgi-express module-config
# 上の情報を参考に
LoadModule wsgi_module [wsgiまでのpath]/mod_wsgi-py36.cpython-36m-x86_64-linux-gnu.so
WSGIScriptAlias /neko /var/www/html/neko.py

2 Django準備

折りたたみ
> ## 2-1 プロジェクト構築
折りたたみ
アプリケーションディレクトリをつくって、startproject、startapp。
mkdir project/
cd project/
django-admin.py startproject config .
python manage.py startapp web

2-2 Django起動確認

折りたたみ
Apache設定変更
WSGIScriptAlias / [アプリまでのpath]/config/wsgi.py

NotFoundError: No module named 'config'が出たらとりあえず。

wsgi.py
import sys
sys.path.append('[アプリまでのpath]')

2-3 Web表示設定

折りたたみ
適宜修正 - config/urls.py - web/urls.py - web/viwe.py
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?