免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2143 | 回复: 0
打印 上一主题 下一主题

Setting up Apache2, mod_python, MySQL, and Django [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-04-05 20:01 |只看该作者 |倒序浏览

Both Debian and Ubuntu make it really simple to get a server up and running. I was trying a few different Machine Images on Amazon and I found myself repeating a lot of things so I wanted to put them here for reference for those who might find it useful.
With a fresh image, the first thing to do is update apt-get.
apt-get update && apt-get upgrade -y
Then grab all of the software to use.
apt-get install -y xfsprogs mysql-server  apache2  libapache2-mod-python  python-mysqldb  python-imaging  python-django  subversion php5  phpmyadmin
xfsprogs is for formatting an Elastic Block Store volume and may not be needed in all cases.
I like to check out the latest version of Django from their repository, it makes it easier to update it later. This also starts a project named myproject (this name is used later).
cd /usr/lib/python2.5/site-packages
svn co http://code.djangoproject.com/svn/django/trunk/django django
ln -s /usr/lib/python2.5/site-packages/django/bin/django-admin.py /usr/local/bin
cd /var/www
django-admin.py startproject myproject
Now to edit the apache config to tell it about our project.
cd /etc/apache2
nano httpd.conf
Add the following to set up python to run the django files and php to run the phpmyadmin files. There is also an example of serving static files. Change where it says myproject if you used a different name.
"/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE myproject.settings
    PythonOption django.root /myproject
    PythonDebug On
    PythonPath "['/var/www'] + sys.path"
>


Alias /adm_media/ /usr/lib/python2.5/site-packages/django/contrib/admin/media/
"/adm_media/">
    SetHandler None
>

Alias /files/ /var/www/myproject/files/
"/files/">
    SetHandler None
>

Alias /phpmyadmin/ /usr/share/phpmyadmin/
"/phpmyadmin/">
    SetHandler None
>
Restart apache for it to use the new configuration.
/etc/init.d/apache2 restart
The only thing left to do is set up the database. If Ubuntu had you set up a root password already, add -p to the end of the following command to use it.
mysql
There are some users in mysql without username, it is best to remove those.
drop user ''@'localhost';
Do that for each host that has a blank username. Use the following to see all users.
SELECT user, host FROM mysql.user;
Create a database and add a user.
CREATE DATABASE db_name;
GRANT ALL ON db_name.* to user_name WITH GRANT OPTION;
SET PASSWORD FOR user_name = password('psswdhere');
If root doesn’t have a password yet, use the above commant with root as the username.
Amazon has a page about
how to use EBS with MySQL
, but
there are reported issues with using Debian Lenny and EBS
.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/78/showart_1890699.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP