centos 6.5 + appache + django

来源:互联网 发布:win10系统网络设置 编辑:程序博客网 时间:2024/05/16 13:53

首先安装 Python 2.7以上
1. 安装python2.7
2. ./config –enable-shared
3. make && make install
4. 将原先的python2.6 ln换成 新的python 因为yum默认的是使用python2.4,为了使yum命令能正确执行,需要修改
[root@CNC-BJ-5-3N1 bin]# vi yum
#!/usr/bin/python 改为 #!/usr/bin/python2.4

 当出现 libpython2.7.so.1.0的错误时:```[root@CNC-BJ-5-3N1 bin]# ./python./python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory```执行:```    /sbin/ldconfig    /sbin/ldconfig –v```

5 测试python 正常进入
6 安装Pip pip install django
7 下载并安装 mod_wsgi-4.4.21.tar.gz

./configure --with-apxs=/opt/lampp/bin/apxs \                       --with-python=/usr/local/bin/python2.7 \                       --with-mutex-dir=/var/run/mod_wsgi \                       --enable-sharedmake && make install

8 配置httpd.conf
参考[https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/]

9 我的配置文件如下:

LoadModule wsgi_module modules/mod_wsgi.soListen 8000WSGIPythonPath  /opt/lampp/htdocs/sites/cw-app/cw/<VirtualHost *:8000>WSGIScriptAlias  / /opt/lampp/htdocs/sites/cw-app/cw/cw/wsgi.py        ServerName 192.168.1.128        DocumentRoot "/opt/lampp/htdocs/sites/cw-app/cw/"        <Directory  "/opt/lampp/htdocs/sites/cw-app/cw/">            Options Indexes FollowSymLinks            AllowOverride All            Order allow,deny            Allow from all            <Files wsgi.py>                Require all granted            </Files>        </Directory></VirtualHost>

10 启动appache 服务 成功看到django首页

0 0
原创粉丝点击