ubuntu下配置django+apache+mysql+mod_python+Python
2011-12-25 10:09
801 查看
网上有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
出现:
现在这个工程没有任何程序
继续work。
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以配置完成现在这个工程没有任何程序
继续work。
相关文章推荐
- ubuntu下配置django+apache+mysql+mod_python+Python
- linux下 Apache mysql python mod_python Django 配置安装说明,绝对可以安装上的说明
- ubuntu 安装、配置django mod_python apache2 mysql
- Python3.5 Django1.8 apache2.4 Ubuntu 配置mod_wsgi模块
- ubuntu10.04 python django apache mysql mod_python python_mysql
- winxp+Apache+Mysql+Python+Django安装配置
- 通过mod_python配置运行在Apache上的Django框架
- 在Ubuntu 9.04下配置Apache和Mod-Python
- Ubuntu下LAMP_服务器安装配置(Linux+Apache+Mysql+Perl/PHP/Python)
- Django在使用mod_python+apache中配置VirtualHost的问题总结
- mysql+apache+python+mod_python+MySQLdb+django环境安装(转)
- 通过mod_python配置运行在Apache上的Django框架
- Ubuntu14.04 Server amd64 配置 Apache+MySQL+Django
- Ubuntu14.04-Python2.7-Virtualenv-Django1.9-MySQL完整环境配置
- windows下配置apache2.2+python2.5+mod_python=Django环境
- Win下python+Pydev+Django+apache+mod_wsgi开发部署配置记录
- ubuntu python3.5 django1.8.5 apache2.4 wsgi mysql部署django项目
- Linux+apache+mysql+python+mod_python+Django
- 【转】ubuntu下配置apache的mod_python解决firefox下不能解析文档而变成直接下载
- apache+mysql+mod_python+Django