Steps to create in OPENSHIFT
1. Create a Project:
- create a python2.7 application in openshift
- create an sshkey
ssh-keygen -t rsa
and upload the publickeycat ~/.ssh/id_rsa.pub
2. Clone the Project:
- clone the app.(ie
git clone ssh://52fb16fa4382..@n-suhail.rhcloud.com/~/git/n.git/
)
Now a folder is created with files : requirements.txt
,setup.py
and wsgi.py
3. Copy the project folder to that directory.
So that the project tree is something like:
requirements.txt
setup.py
wsgi.py
mysite/
manage.py
sample/
__init__.py
settings.py
urls.py
wsgi.py
4. Edit the file wsgi.py
Replace the whole content by:
note: You need to correct the path of settings.py
(sample.settings
) and the path of your project(mysite
)
#!/usr/bin/python
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'sample.settings'
sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'],'mysite'))
virtenv = os.path.join(os.environ['OPENSHIFT_PYTHON_DIR'],'virtenv')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:execfile(virtualenv, dict(__file__=virtualenv))
except IOError:pass
from django.core.handlers import wsgi
application = wsgi.WSGIHandler()
5. Add your project's requirements in requirements.txt
file :
something like:
Django
6. Commit and push to server
git add .
git commit -m "Initialization"
git push