一尘不染

使用openshift部署本地Django应用

django

我已经使用django构建了一个webapp。为了托管它,我试图使用openshift,但是很难使任何东西正常工作。似乎缺乏循序渐进的步骤。到目前为止,我的git工作正常,该应用程序可在本地开发环境上运行,并且我已经在openshift上成功创建了一个应用程序。

一旦创建了openshift上的URL,我就会得到“欢迎使用您的Openshift应用程序”的标准页面。

我已遵循此https://developers.openshift.com/zh-CN/python-getting-started.html#step1尝试更改wsgi.py文件。将其更改为hello world,进行了推送,但仍然获得了openshift默认页面。

是否在任何地方都有良好的综合资源,可用于在Openshift上启动和运行本地Django应用程序?我在Google上可以找到的大多数只是示例应用程序,因为我已经构建了我的应用程序,所以没有那么有用。


阅读 507

收藏
2020-04-01

共1个答案

一尘不染

1)  Step 1 install  Rubygems
Ubuntu - https://rubygems.org/pages/download
Windows - https://forwardhq.com/support/installing-ruby-windows
$ gem
or
C:\Windows\System32>gem
RubyGems is a sophisticated package manager for Ruby.  This is a
basic help message containing pointers to more information……..

2)  Step 2:
$ gem install rhc
Or
C:\Windows\System32> gem install rhc

3)  $ rhc
Or
C:\Windows\System32> rhc

Usage: rhc [--help] [--version] [--debug] <command> [<args>]
Command line interface for OpenShift.

4)  $ rhc app create -a mysite -t python-2.7
Or 
C:\Windows\System32>  rhc app create -a mysite -t python-2.7
# Here mysite would be the sitename of your choice
#It will ask you to enter your openshift account id and password

Login to openshift.redhat.com: Enter your openshift id here
Password : **********


Application Options
---------------------
Domain:    mytutorials
Cartridges: python-2.7
Gear Size:  Default
Scaling:    no

......
......

Your application 'mysite' is now available.

 URL : http://mysite.....................
 SSH to :  39394949......................
 Git remote: ssh://......................

Run 'rhc show-app mysite' for more details about your app.

5)  Clone your site
$ rhc git-clone mysite
Or
D:\> rhc git-clone mysite
.......................
Your application Git repository has been cloned to "D:\mysite"

6)  #”D:\mysite>” is the location we cloned.
D:\mysite> git remote add upstream -m master git://github.com/rancavil/django-openshift-quickstart.git

D:\mysite> git pull -s recursive -X theirs upstream master

7)  D:\mysite> git push
remote : ................
remote: Django application credentials
               user: admin
               xertefkefkt

remote: Git Post-Receive Result: success
.............

8)  D:\mysite>virtualenv venv --no-site-packages
D:\mysite>venv\Scripts\activate.bat
<venv> D:\mysite> python setup.py install
creating .....
Searching for Django<=1.6
.............
Finished processing dependencies for mysite==1.0

9)  Change admin password
<venv> D:\mysite\wsgi\openshift> python manage.py changepassword admin
password:
...
Password changed successfully for user 'admin'
<venv> D:\mysite\wsgi\openshift> python manage.py runserver
Validating models….

10) Git add
<venv> D:\mysite> git add.
<venv> D:\mysite> git commit -am"activating the app on Django / Openshift"
   .......
<venv> D:\mysite> git push



#----------------------------------------------------------------------------------
#-----------Edit your setup.py in mysite with packages you want to install----------

from setuptools import setup

import os

# Put here required packages
packages = ['Django<=1.6',  'lxml', 'beautifulsoup4', 'openpyxl']

if 'REDISCLOUD_URL' in os.environ and 'REDISCLOUD_PORT' in os.environ and 'REDISCLOUD_PASSWORD' in os.environ:
     packages.append('django-redis-cache')
     packages.append('hiredis')

setup(name='mysite',
      version='1.0',
      description='OpenShift App',
      author='Tanveer Alam',
      author_email='xyz@gmail.com',
      url='https://pypi.python.org/pypi',
      install_requires=packages,
)

2020-04-01