ubuntu下配置django+apache+mysql+mod_python+Python
2015-09-17 17:53
337 查看
网上有N种安装方法,我都试过,没有一个最后能成功,浪费了一下午的时间,终于搞定,
1.install Python
最新的Ubuntu操作系统是含有Python的,可以通过 Python --version 查看的:
lab@lab:~$ python version
Python 2.7.1+
2.install MySQL
使用最简单的方法:sudo apt-get install mysql-server mysql-client
3.install Apache
继续使用命令:sudo apt-get install apache2
4.install MySQLdb
sudo apt-get install python-mysqldb
5.install mod_python
sudo apt-get install libapache2-mod-python
6.install Django
到网站上下载: www.djangoproject.org Django-x.x.x.tar.gz
解压:tar xzvf Django-1.2.1.tar.gz
安装:sudo python install setup.py
7.测试Django 和 MySQLdb是否成功
在命令行:python
>>>import django
>>>import MySQLdb
如果没有错误提示,则安装成功!
>>>exit()
8.运行一个简单程序不是用apache
lab@lab:~$ cd /var/www
lab@lab:~$sudo python /usr/local/bin/django-admin.py startproject server
lab@lab:~$ cd s*
lab@lab:~$ ls
可以看到在server 中多了几个文件,不管他
lab@lab:~$ python manage.py runserver
出现如下提示:
0 errors foundDjango
version 1.4 pre-alpha, using settings 'server.settings'Development
server is running at http://127.0.0.1:8000/Quit the server with
CONTROL-C.
证明一切OK!
打开浏览器:http://127.0.0.1:8000/server 出现如下画面:
9.配置apache2
command:cd /etc/apache2
command:sudo chmod 777 httpd.conf
command:gedit httpd.conf
添加:
LoadModule python_module
/usr/local/lib/apache2/modules/mod_python.so<Location
"/server/"> SetHandler python-program
//这一句必须有,mod_python.so 在安装mod_python时生成的,
PythonPath "['/var/www'] + sys.path" //这里不必添加server 目录
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE server.settings //工程名server
PythonOption django.root /server
PythonDebug On
</Location>
重启apache2 ,网上有很多种方法,直接重新开机是最实惠的。
10.打开浏览器:http://127.0.0.1:8000
出现:
转自:http://www.cnblogs.com/changefuture/archive/2011/12/25/2300864.html
1.install Python
最新的Ubuntu操作系统是含有Python的,可以通过 Python --version 查看的:
lab@lab:~$ python version
Python 2.7.1+
2.install MySQL
使用最简单的方法:sudo apt-get install mysql-server mysql-client
3.install Apache
继续使用命令:sudo apt-get install apache2
4.install MySQLdb
sudo apt-get install python-mysqldb
5.install mod_python
sudo apt-get install libapache2-mod-python
6.install Django
到网站上下载: www.djangoproject.org Django-x.x.x.tar.gz
解压:tar xzvf Django-1.2.1.tar.gz
安装:sudo python install setup.py
7.测试Django 和 MySQLdb是否成功
在命令行:python
>>>import django
>>>import MySQLdb
如果没有错误提示,则安装成功!
>>>exit()
8.运行一个简单程序不是用apache
lab@lab:~$ cd /var/www
lab@lab:~$sudo python /usr/local/bin/django-admin.py startproject server
lab@lab:~$ cd s*
lab@lab:~$ ls
可以看到在server 中多了几个文件,不管他
lab@lab:~$ python manage.py runserver
出现如下提示:
0 errors foundDjango
version 1.4 pre-alpha, using settings 'server.settings'Development
server is running at http://127.0.0.1:8000/Quit the server with
CONTROL-C.
证明一切OK!
打开浏览器:http://127.0.0.1:8000/server 出现如下画面:
It worked!
Congratulations on your first Django-powered page.
django是个小的服务器,现在换没有运行在apache2上了9.配置apache2
command:cd /etc/apache2
command:sudo chmod 777 httpd.conf
command:gedit httpd.conf
添加:
LoadModule python_module
/usr/local/lib/apache2/modules/mod_python.so<Location
"/server/"> SetHandler python-program
//这一句必须有,mod_python.so 在安装mod_python时生成的,
PythonPath "['/var/www'] + sys.path" //这里不必添加server 目录
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE server.settings //工程名server
PythonOption django.root /server
PythonDebug On
</Location>
重启apache2 ,网上有很多种方法,直接重新开机是最实惠的。
10.打开浏览器:http://127.0.0.1:8000
出现:
It worked!
Congratulations on your first Django-powered page.
证明apache以配置完成转自:http://www.cnblogs.com/changefuture/archive/2011/12/25/2300864.html
相关文章推荐
- Apache Camel读取配置文件
- SpringMVC + Apache POI 实现WEB中Excel下载功能
- SpringMVC + Apache POI 实现WEB中Excel下载功能
- org.apache.log4j.Logger详解
- Apache JMeter2.8的源码集成到Eclipse开发环境中
- sort-based shuffle的核心:org.apache.spark.util.collection.ExternalSorter
- 【apache2.5】重启的注意事项
- 【Window下apache服务设置最大连接数】
- mac10.10Apache配置笔记
- Apache Commons Digester 初步
- 在Mac OS X中配置Apache + PHP + MySQL + Wordpress
- 手动安装Apache+PHP+MYSQL及环境配置
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property
- 阿里云主机 CentOS6.5 安装Mysql php Apache
- org.apache.log4j.Logger详解
- Apache的apxs详解
- org.apache.subversion.javahl.ClientException: ÓÉÓÚl½ӷ½ÔÚһ¶Îʱ¼äºóûÓÐÕýȷ´ð¸´»òl½ӵÄÖ÷»úûÓз´Ӧ£¬l½ӳ¢ÊÔʧ°ܡ
- org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.ap解决方案
- Type mismatch in key from map: expected org.apache.hadoop.io.LongWritable, received org.apache.hadoo
- ubuntu彻底清除Apache+Mysql+PHP