しゅうせいちゅう
python3とかpython2.7とか切り替えを便利にするためにpyenvを入れる
加えて、system由来以外のpythonにはAnacondaでpythonパッケージ管理をさせる
pyenvhttps://github.com/pyenv/pyenv
Anacondahttps://www.anaconda.com/
まずはpyenvをインストール
[root@c ~]# cd src/
[root@c src]# curl -O https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
[root@c src]# xz -cd Python-3.6.2.tar.xz | tar xf -
[root@c src]# cd Python-3.6.2
[root@c Python-3.6.2]#
[root@c Python-3.6.2]# export PATH=/sbin:/bin:/usr/sbin:/usr/bin
[root@c Python-3.6.2]# unset LD_LIBRARY_PATH
[root@c Python-3.6.2]# ./configure --prefix=/usr/local/python36
[root@c Python-3.6.2]# make && make test
(test.test_dtrace.SystemTapOptimizedTestsでエラー発生)
[root@c Python-3.6.2]# make install
[root@c ~]# cd src/
[root@c src]# curl -O https://www.python.org/ftp/python/3.3.6/Python-3.3.6.tar.xz
[root@c src]# xz -cd Python-3.3.6.tar.xz | tar xf -
[root@c src]# cd Python-3.3.6
[root@c Python-3.3.6]# ./configure --prefix=/usr/local/python33
[root@c Python-3.3.6]# make && make test
(make test で test_ssl でエラーが発生)
[root@c Python-3.3.6]# make install
pip3
[root@c ~]# cd src/
[root@c src]# curl -O https://bootstrap.pypa.io/get-pip.py
[root@c src]# python3 get-pip.py
[root@c src]# which pip3
/usr/local/python33/bin/pip3
[root@c ~]# pip3 install constants
[root@c8 ~]# wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
[root@c8 ~]# bzip2 -cd Python-2.7.5.tar.bz2 | tar xf -
[root@c8 ~]# cd Python-2.7.5
[root@c8 Python-2.7.5]# ./configure
[root@c8 Python-2.7.5]# make
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 _ssl
_tkinter bsddb185 bz2
dbm dl gdbm
imageop readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
(今のままだと使えないモジュールはこんだけあるよ。っと言われる。まぁー使うかもしれないので適用にパッケージを追加してmake)
[root@c8 ~]# yum -y install \
tk-devel tcl-devel \ *_tkinterが解消される
readline-devel \ *readlineが解消される
sqlite-devel \ *_sqlite3が解消される
bzip2-devel \ *bz2が解消される
ncurses-devel \
openssl-devel \ *_sslが解消される
gdbm-devel \ *dbm,gdbmが解消される
db4-devel *_bsddbが解消される
[root@c8 Python-2.7.5]# make
Python build finished, but the necessary bits to build these modules were not found:
bsddb185 dl imageop *まぁこのくらいで
sunaudiodev
[root@c8 Python-2.7.5]# make test
[root@c8 Python-2.7.5]# make altinstall
yum install tk-devel tcl-devel readline-devel sqlite-devel bzip2-devel ncurses-devel gdbm-devel openssl-devel
./configure CFLAGS=-fPIC --enable-unicode --enable-shared --prefix=/usr/local/pyton27
make -j4
http://bugs.python.org/issue14572
vi Modules/_sqlite/connection.c
make
make test
[root@c ~]# yum -y install mod_wsgi
インストールされるファイルは
/etc/httpd/conf.modules.d/10-wsgi.conf
/usr/lib64/httpd/modules/mod_wsgi.so
/usr/share/doc/mod_wsgi-3.4
/usr/share/doc/mod_wsgi-3.4/LICENCE
/usr/share/doc/mod_wsgi-3.4/README
である。
次に設定ファイルを用意する
[root@c ~]# vi /etc/httpd/conf.d/wsgi.conf
WSGIScriptAlias /wsgi /var/www/wsgi/hello.wsgi
[root@c ~]#
次にコンテンツを用意する
[root@c ~]# mkdir -p /var/www/wsgi
[root@c ~]# vi /var/www/wsgi/hello.wsgi
class WsgiHelloWorld(object):
def __call__(self, environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return ['Hello, world!']
application = WsgiHelloWorld()
[root@c ~]#
っで、稼動させるが、config確認してから再起動する
[root@c ~]# apachectl configtest
Syntax OK
[root@c ~]# systemctl restart httpd
*wsgi.confは、1つのURLに対して1つのwsgiスクリプトとなる。。URL毎にwsgi.confを修正するのは面倒かな。.htaccessを使えばhttpdの再起動なしにwsgiスクリプトの追加は可能。もっと楽にするにはSetHandlerやらの出番のような
yum install httpd-devel
wget http://archive.apache.org/dist/httpd/modpython/mod_python-3.3.1.tgz
gtar xzvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
vi src/connobject.c 140行目あたり while ((bytes_read < len || len == 0) && - !(b == APR_BRIGADE_SENTINEL(b) || + !(b == APR_BRIGADE_SENTINEL(bb) || APR_BUCKET_IS_EOS(b) || APR_BUCKET_IS_FLUSH(b))) {
./configure --with-python=/usr/bin/python --with-apxs=/usr/sbin/apxs
make
make install
vi conf.d/mod_python.conf LoadModule python_module modules/mod_python.so