CentOS 上的 Django
我希望在运行未知版本 CentOS 的共享主机上使用 Django。 我的主要问题是尝试与数据库交互。 服务器安装了MySQL,但没有安装MySQL-python。 我最初想到建议运行“yum install MySQL-python”,但显然 CentOS 默认存储库中的 MySQL-python 版本是 1.2.1,而 Django 需要 1.2.1p2。
这个要求首先从 Django 0.96 开始。 在发行说明中,添加了一个已弃用的名为 mysql_old 的接口,以兼容旧版本的 MySQL-python。 去年 7 月,这个已弃用的接口被毫不客气地删除。 此更改的公告除了旧版本外,没有表明其他原因。
是否有可能在 Django 1.1 中复活这个旧界面? 从那时起,数据库接口有任何变化吗? 强制 Django 跳过版本检查并使用 1.2.1 会有什么危险? 是否可以在另一台机器上编译更高版本并将文件复制到主机上? 为了做到这一点我需要知道什么?
我还研究了 SQLite,但 CentOS 附带了 Python 2.4.3,因此需要 pysqlite2 扩展,而该扩展(据我所知)在存储库中不存在。
一切都可以通过简单地从源代码安装来解决,但这相当混乱,而且我说服公司这样做的机会比让他们从存储库安装某些东西的机会要小得多。 我意识到我似乎应该换一个主机,但你必须相信我,我有理由尝试让这项工作成功。
注意:我没有任何使用 CentOS 或 yum 的经验,所以我所说的关于它们的一切都是有根据的猜测。 如果我需要做的只是指定一些设置或更改存储库来获取这些包的更新版本,请告诉我。 谢谢。
I'm looking to use Django on a shared host that's running an unknown version of CentOS. My main problem is trying to interface with a database. The server has MySQL installed, but not MySQL-python. I initially thought of suggesting running "yum install MySQL-python", but apparently the version of MySQL-python that's in the default repositories for CentOS is 1.2.1, and Django requires 1.2.1p2.
This requirement first started with Django 0.96. In the release notes, a deprecated interface called mysql_old was added for compatibility with older versions of MySQL-python. Last July this deprecated interface was unceremoniously dropped. The announcement of this change does not indicate a reason other than that it was old.
Is it possible to resurrect this old interface in Django 1.1? Have there been any changes to the database interface since then? What would be the danger in forcing Django to skip the version check and using 1.2.1? Is it possible to compile a later version on another machine and copy the files over to the host? What would I need to know in order to do that?
I also looked into SQLite, but CentOS ships with Python 2.4.3, and therefore would require the pysqlite2 extension, which (afaict) doesn't exist in the repository.
Everything could be solved by simply installing from source, but that's rather messy and I have a much smaller chance of convincing the company to do that than getting them to install something from the repository. I realize that it seems like I should just get a different host, but you'll have to trust me that I have my reasons to try to make this work.
note: I don't have any experience using CentOS or yum, so everything I've said about them is an informed guess. Please let me know if all I need to do is specify some settings or change repositories to get the updated versions of these packages. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您无法从 centos 存储库获取最新的软件包,您实际上可以手动安装 mysql-python 适配器,而无需编译任何内容。 只需下载 mysql-python tarball(从 sourceforge 站点)。 tar 包中包含各种安装脚本、自述文件等。您可以运行 ez_setup 文件、安装文件,或者将 MySQLdb 目录复制到 pythonpath 中的某个位置。 我认为在 centos 上, /usr/lib/python2.4/site-packages/ 可以工作。
祝你好运!
You can actually manually install the mysql-python adapters without compiling anything, if you can't get a recent package from the centos repos. Just download the mysql-python tarball (from the sourceforge site). In the tar ball are all kinds of setup scripts, readme's, etc. You can either run the ez_setup file, the setup file, or, just copy the MySQLdb directory to somewhere in your pythonpath. I think on centos, /usr/lib/python2.4/site-packages/ works.
Good luck!
你可以安装centos的包
python-setuptools
,然后使用easy-install
,你可以像这样安装最新版本的mysql-python
You can install centos' package
python-setuptools
and then usingeasy-install
in it you can install the latest version ofmysql-python
like this