Last active
May 4, 2019 12:18
-
-
Save peace098beat/ab449b68a2621e5b657f to your computer and use it in GitHub Desktop.
[サクラレンタルサーバー] (初心者向け) PythonとpyenvとFlaskの環境構築方法。| cshの場合 ref: https://qiita.com/peace098beat/items/de9fdadfc4128e99bca6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /home/<username>/ | |
$ cd $HOME | |
$ cd ~/ | |
$ cd /home/fififactory/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ which python | |
/usr/local/bin/python | |
$ python -V | |
2.7.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pyenv local 2.7.9 # ローカルpythonを構築 | |
$ pyenv local # 設定がされているか確認 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ whitch python | |
/home/fififactory/.pyenv/shims/python | |
$ python -V | |
2.7.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv | |
$ pyenv virtualenv 3.4.2 3.4.2-flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pyenv local 3.4.2-flask | |
$ pip install Flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir ~/www/flask-cgi-test | |
mkdir ~/www/flask-cgi-test/hello | |
cd ~/www/flask-cgi-test/hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteEngine On | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ /flask-cgi-test/hello/index.cgi/$1 [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
return "Hello!" | |
if __name__ == '__main__': | |
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/fififactory/.pyenv/versions/3.4.2-flask/bin/python | |
import cgitb | |
cgitb.enable() | |
from wsgiref.handlers import CGIHandler | |
from appFlask import app | |
CGIHandler().run(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo $SHELL | |
csh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ファイル名: pyenv-download.sh | |
#!/bin/csh <- cshellで動作させる事を明示します。 | |
git clone https://github.com/yyuu/pyenv.git ~/.pyenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 実行権限を付加しておきます。 | |
$ chmod 755 pyenv-download.sh | |
# シェルスクリプトの実行 | |
$ ~/pyenv-download.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $FreeBSD: src/share/skel/dot.cshrc,v 1.14.6.1 2008/11/25 02:59:29 kensmith Exp $ | |
# | |
# .cshrc - csh resource script, read at beginning of execution by each shell | |
# | |
# see also csh(1), environ(7). | |
# | |
..... | |
(末尾に入力) | |
# Setting for pyenv | |
# ***************** | |
if ( -e $HOME/.pyenv/bin/pyenv ) then | |
echo '>> Exist pyenv' | |
# pyenvのルートパスを設定 | |
setenv PYENV_ROOT $HOME/.pyenv | |
# pyenvのディレクトリをPATHに追加 | |
setenv PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH | |
# デフォルトテンポラリディレクトリを~/tmpに変更 | |
setenv TMPDIR $HOME/tmp | |
# pyenvの再起動 | |
pyenv rehash | |
else | |
echo '>> NO INSTALL pyenv' | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ source $HOME/.cshrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pyenv install --list # インストールリストの確認 | |
$ pyenv install 2.7.9 # python2.7.9をインストール |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 仮想環境用のディレクトリを作成(場所は任意) | |
$ mkdir $HOME/tmp/python | |
$ cd $HOME/tmp/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ which python # 現状のpythonを確認 | |
/usr/local/bin/python | |
$ pyton -V | |
2.7.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment