LoginSignup
24

More than 5 years have passed since last update.

CentOS6.4でPython2.7.3でApacheでmod_wsgiでDjango

Last updated at Posted at 2013-05-15

Pythonのインストール
Yumに影響与えないためaltinstallする

% yum -y groupinstall "Development Tools"
% yum -y install expat-devel db4-devel gdbm-devel sqlite-devel readline-devel 
zlib zlib-devel bzip2-devel openssl-devel ncurses-devel
% cd /usr/local/src
% wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
% tar xjf Python-2.7.3.tar.bz2
% cd Python-2.7.3
% ./configure --with-threads --enable-shared
% make
% make altinstall
% echo '/usr/local/lib' > /etc/ld.so.conf.d/python2.7.conf
% ldconfig

setuptoolsのインストール

% curl http://peak.telecommunity.com/dist/ez_setup.py | python2.7

pipのインストール

% curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python2.7

Apacheのインストール

% yum -y install httpd httpd-devel
% mkdir -p /var/log/httpd/www.example.com
% vi /etc/httpd/conf.d/www.example.com.conf
<VirtualHost *:80>
    ServerName www.example.com:80
    DocumentRoot /home/www/www.example.com/example
    CustomLog "/var/log/httpd/www.example.com/access_log" common
    ErrorLog  "/var/log/httpd/www.example.com/error_log"
    WSGIDaemonProcess example python-path=/home/www/www.example.com:/usr/local/lib/python2.7/site-packages
    WSGIProcessGroup example
    WSGIScriptAlias / /home/www/www.example.com/example/wsgi.py
    WSGIScriptReloading On
    <Directory /home/www/www.example.com/example>
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

mod_wsgiのインストール

% cd /usr/local/src
% wget http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz
% tar vzxf mod_wsgi-3.4.tar.gz
% cd mod_wsgi-3.4
% ./configure --with-python=/usr/local/bin/python2.7
% make
% make install
% vi /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so

Djangoのインストール

% pip-2.7 install django

Djangoプロジェクト作成

% useradd www
% su - www
% django-admin.py startproject example
% mv example www.example.com

とりあえずうごいた

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
24