Powered By Blogger
ラベル CentOS の投稿を表示しています。 すべての投稿を表示
ラベル CentOS の投稿を表示しています。 すべての投稿を表示

2013年9月18日水曜日

CentOS6.4にmod_wsgiをインストール

Pythonは/usr/local/bin/python2.7にインストールされていることとします。

ここを参考にインストールしてください。 

また、Apacheは/home/hoge/apache/にインストールされていることとします。 


  • mod_wsgiのダウンロードとインストール
    • wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
      tar xvzf mod_wsgi-3.4.tar.gz
      cd mod_wsgi-3.4
      ./configure --with-apxs=/home/hoge/apache/bin/apxs --with-python=/usr/local/bin/python2.7
      make
      make install
      
  • Apacheの設定
    • /home/hoge/apache/conf/httpd.confに以下を追加します。
    • LoadModule wsgi_module modules/mod_wsgi.so
      WSGIPythonPath /home/hoge/app
      WSGIPythonEggs /home/jpge/.python-eggs
      
  • mod_wsgiから呼び出すためのアダプターを設定
    • /home/hoge/apache/conf/extra/httpd-vhosts.confに以下を追加します。
    • <virtualhost *:80>
          ServerName www.example.com:80
          DocumentRoot /home/hoge/app
          WSGIDaemonProcess hogegroup user=hoge group=hoge processes=2 threads=15
          WSGIScriptAlias /hoge /home/hoge/app/adapter.wsgi
          <Directory /home/hoge/app>
              Order allow,deny
              Allow from all
          </directory>
      </virtualhost>
      

2013年9月9日月曜日

centos6.4のpython2.7.5にパッケージを入れる(2)~モジュール編~

■easy_install
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.1.1.tar.gz
cd setuptools-1.1.1
python2.7 setup.py install

確認
which easy_install-2.7
/usr/local/bin/easy_install-2.7

■pip
easy_install-2.7 pip

確認
which pip2.7
/usr/local/bin/pip2.7

■PyCrypto
easy_install-2.7 PyCrypto

■PyYAML
pip2.7 install PyYAML

■cuisine
pip2.7 install cuisine

■bottle
pip2.7 install bottle

■Fabric
pip2.7 install fabric

centos6.4にPython2.7.5をインストールする

参考サイト:http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
まずは参考サイトの通り下記コマンドを実行します。
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

Pythonをインストールします。
wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tgz
tar -zxvf Python-2.7.5.tgz
cd Python-2.7.5
./configure --prefix=/usr/local --with-threads --enable-shared
make && make altinstall

確認
which python2.7
/usr/local/bin/python2.7
下記エラーが出た場合の対処
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
シンボリックリンクを貼ります。
cd /usr/local/bin
ln -s /usr/local/lib/libpython2.7.so.1.0 /lib64/