apache,mod_python配置(ubuntu)

如果系统没有安装mod_python,则先安装之。
sudo apt-get install mod-python或libapache2-mod-python都可以



我的配置:
/var/www目录下,有bugfree,phpmyadmin,及我的项目zhanghui

进入/etc/apache2中,找开httpd.conf。

LoadModule python_module /usr/lib/apache2/modules/mod_python.so

#NameVirtualHost *:80

#<VirtualHost *:80>
#ServerAdmin [email protected]
DocumentRoot /var/www/zhanghui
#ServerName 192.168.0.114
#Rewriteengine On
#RewriteRule ^/sitemedia/(.*)$ /media/$1 [R]

<Location "/">
SetHandler python-program
PythonPath "['/var/www']+sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE zhanghui.settings
PythonAutoReload Off
#PythonDebug On
PythonDebug off
</Location>
  #下面这个Location主要是为网站拥有大量的媒体时,分离出媒体服务器时使用。
<Location "/media">
SetHandler None
</location>
<Location "/bugfree">
SetHandler None
</Location>
<Location "/phpmyadmin">
SetHandler None
</Location>
#下面这段如果不打上'#',在网页中将不显示CSS文件及这些图片文件。
#<LocationMatch "\.(jpg|gif|png|css)$">
#SetHandler None
#</LocationMatch>
#</VirtualHost>

#<Directory "/var/www/zhanghui">
#AllowOverride None
#Options FollowSymLinks
#AllowOverride None
#Order deny,allow
#allow from all
#</Directory>

 

/etc/init.d/apache2 restart

 

 

 

==  update 2014 10 22 ==

#LoadModule python_module /usr/lib/apache2/modules/mod_python.so

#

#DocumentRoot /var/www/resource-platform

#

#<Location "/">

#       SetHandler python-program

#       PythonPath "['/var/www']+sys.path"

#       PythonHandler django.core.handlers.modpython

#       SetEnv DJANGO_SETTINGS_MODULE ResourcePlatform.settings

#       PythonAutoReload off

#       PythonDebug on

#</Location>

 

 

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

 

DocumentRoot /var/www/resource-platform

 

WSGIScriptAlias / "/var/www/resource-platform/ResourcePlatform/wsgi.py"

WSGIPythonPath /var/www/resource-platform

 

<Directory "/var/www/resource-platform">

        Order Deny,Allow

        Allow from all

</Directory>

 

Alias /public/admin/ "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin/"

<Directory "/public/admin/">

        Order allow,deny

        Options Indexes

        Allow from all

        IndexOptions FancyIndexing

</Directory>

 

Alias /public/ "/var/www/resource-platform/ResourcePlatform/public/"

<Directory "/public/">

        Order allow,deny

        Options Indexes

        Allow from all

        IndexOptions FancyIndexing

</Directory>

 

你可能感兴趣的:(apache,python,django,css,ubuntu)