apache24 django1.8.2 mod_wsgi 集成

本文详细介绍了在Ubuntu 14.04.2 LTS环境下,通过安装mod_wsgi、配置Apache和Django,实现Web应用的部署与运行过程。包括安装依赖库、编译安装mod_wsgi、配置Apache服务、设置虚拟主机及监听端口等步骤,最终确保Web应用能够正常启动并访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、apache24的安装这里就不赘述了

参考上一篇博文http://blog.csdn.net/sccs999/article/details/49247747


2、django安装也不赘述了,用

pip install django==1.8.2

3、首先描述一下自己的环境

cat /etc/issue

Ubuntu 14.04.2 LTS

django 1.8.2

python 2.7.6

apache 2.4.17 (released 2015-10-13)

apache下载地址: http://httpd.apache.org/download.cgi

apr 1.5.2

apr-util 1.5.4

apr and apr-util下载地址: http://apr.apache.org/


pcre 8.37

pcre 下载地址:http://www.pcre.org/

mod_wsgi 4.4.19

mod_wsgi的下载地址:  https://pypi.python.org/pypi/mod_wsgi


4、安装mod_wsgi

这个是下载源码自行编译的安装方式,相较于直接apt-get更灵活一点

tar -zxvf mod_wsgi-4.4.19
sudo ./configure --with-apxs=/home/wsc/apache24/bin/apxs --with-python=/usr/bin/python
sudo make
sudo make install

出错了的话,一般是因为 python-dev的库没装好吧

apt-get install python2.7-dev

需要确认一下 apache/modules 里面是否存在 mod_wsgi.so

ls /home/wsc/apache24/modules | grep mod_wsgi.so

并且要把 mod_wsgi.so的权限更改为755

sudo chmod 755 /home/wsc/apache24/modules/mod_wsgi.so

5、修改文件  /conf/httpd.conf

确认路径是否正确

ServerRoot "/home/wsc/apache24"
ServerAdmin example@example.com
ServerName www.example.com:80

增加需要监听的端口

Listen 80
Listen 8000
Listen 8001

打开注释,引入虚拟主机的配置文件

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# Virtual hosts
Include conf/extra/httpd-vhosts.conf



注释掉

<Directory />
    AllowOverride none
    Require all denied
</Directory>

<Directory />
    AllowOverride none
    #Require all denied
</Directory>


添加mod_wsgi

LoadModule wsgi_module modules/mod_wsgi.so


6、修改/conf/extra/httpd-vhosts.conf

<VirtualHost *:8000>
 ServerAdmin 549917764@qq.com
 DocumentRoot "/home/wsc/example"
 ServerName example.com
 WSGIScriptAlias / "/home/wsc/example/example/wsgi.py"
 ErrorLog "/var/log/apache/dummy-host.example-error.log"
 CustomLog "/var/log/apache/dummy-host.example-access.log" common
 #配置主目录权限
 <Directory />
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
 </Directory>

 <Directory "/home/wsc/example">
        Order Deny,Allow
        Allow from all
        Require all granted
 </Directory>
</VirtualHost>


7、运行apache

sudo service apache2 start  或者 sudo apachectl start
访问页面 看是否成功,出错了就看 日志

停止

sudo service apache2 stop  或者  sudo apachectl stop 

重启

sudo service apache2 restart   或者  sudo apachectl restart  




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值