简体   繁体   English

在Openshift中部署Django应用程序

[英]Deploying a Django application in Openshift

I have a working Django application in my local machine. 我的本地计算机上有一个运行中的Django应用程序。 I tried hosting this application in Openshift, after following the Openshift official tutorial didn't get any results. 在遵循Openshift官方教程未获得任何结果之后,我尝试在Openshift中托管此应用程序。 Is there any proper resource to deploy local Django applications to openshift 是否有适当的资源将本地Django应用程序部署到openshift

On Openshift you can deploy Django applications using either the Django cartridge or the Python cartridge. 在Openshift上,您可以使用Django墨盒或Python墨盒部署Django应用程序。 Using the Python cartridge is often preferred as it enables you to easily install the latest version of Django using pip. 通常首选使用Python盒式磁带,因为它使您可以使用pip轻松安装最新版本的Django。

Are you using the Django or Python cartridge? 您使用的是Django还是Python墨盒?

To use the Python cartridge you can follow this tutorial: https://developers.openshift.com/en/python-getting-started.html 要使用Python墨盒,您可以按照以下教程进行操作: https : //developers.openshift.com/en/python-getting-started.html

You mention that you already have a django application on your local machine. 您提到本地计算机上已经有一个django应用程序。 It can be a bit tricky to push an existing project to openshift. 将现有项目推向openshift可能有点棘手。

If you create the application using the Python cartridge it will create a git repository for you that you then clone onto your computer. 如果使用Python墨盒创建应用程序,它将为您创建一个git存储库,然后将其克隆到计算机上。 Using the website find the URI for your application repository. 使用该网站找到您的应用程序存储库的URI。 You should clone this onto your computer into a separate directory from your existing django project. 您应该将此复制到计算机上与现有django项目不同的目录中。 Look into this new repository and copy the files from that repository into your existing repository. 查看该新存储库,然后将文件从该存储库复制到现有存储库中。 Then you can look at the remote location used in this new repository and set it as a remote in your existing django repository. 然后,您可以查看此新存储库中使用的远程位置,并将其设置为现有django存储库中的远程位置。 Then from your existing repository push to the openshift remote using the --force flag. 然后使用--force标志从现有存储库中推送到openshift远程服务器。

$ cd /home/user    
$ git clone ssh://<user_id_string>@python-yourdomain.rhcloud.com/~/git/python.git/
$ cd python
$ tree .   # look at the files in the repository (wsgi.py, etc.)
$ <copy the needed files to your django dir>
$ cd ../<existing_django_dir>
$ git remote add openshift ssh://<user_id_string>@python-yourdomain.rhcloud.com/~/git/python.git/
$ git push -f openshift master

Directions on force push: Force "git push" to overwrite remote files 强制推送的方向: 强制“ git push”覆盖远程文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM