You are not logged in.
I've created an installer for web2py:
#!/bin/env python2.4
import random
import sys
from webfaction.api import *
def create():
# Create application.
app = api.create_app(app_name, 'custom_app_with_port')
api.system((
# Download web2py.
'wget -q http://mdp.cti.depaul.edu/examples/static/web2py_src.zip;'
'unzip -q web2py_src.zip;'
'mv web2py/* .;'
'python2.5 web2py.py > /dev/null 2>&1;'
# Cleanup
'rm web2py_src.zip;'
'rmdir web2py/;'
))
# Create start_web2py.py.
start_web2py = """#!/bin/env python2.5
from gluon.main import HttpServer
HttpServer(port=%(port)s).start()
""" % app
api.write_file('start_web2py.py', start_web2py)
# Create cron job.
api.create_cronjob('*/%s * * * * %s' % (random.choice(range(0, 10)), cron_job))
print app['id']
def delete():
# Stop web2py.
cmd = (
'cd %s/webapps/%s/;'
'ls httpserver.pid > /dev/null 2>&1 && kill `cat httpserver.pid` > /dev/null '
'2>&1;'
)
api.system(cmd % (api.account['home_dir'], app_name))
# Delete application and cron job.
api.delete_app(app_name)
api.delete_cronjob(cron_job)
if __name__ == '__main__':
action, username, password, server, app_name, autostart, extra_info = \
sys.argv[1:]
api = API(username, password, server)
cron_job = (
'cd %s/webapps/%s/;'
'ls httpserver.pid > /dev/null 2>&1 && ps -p `cat httpserver.pid` > /dev/null '
'2>&1 || /usr/local/bin/python2.5 start_web2py.py > /dev/null 2>&1 &'
) % (api.account['home_dir'], app_name)
try:
locals()[action]()
except APIError, e:
print e.message
sys.exit()It sets the latest version of web2py up with Python 2.5 and creates a cron job which will restart web2py within 10 minutes of it going down.
Hope it helps. ![]()
Offline
This is great!
One thing is missing (unless I am mistaken), you need to also have a file called
parameters_%(ports).py
that contains
password="aasdfasdfasdfsdf" # md5.new(admin_password).hexdigest()
otherwise admin will not be accessible. There should also be a way to make sure that /admin/* requests only go via https or ssh tunnels.
Massimo
Offline
mdipierro wrote:
This is great!
One thing is missing (unless I am mistaken), you need to also have a file called
parameters_%(ports).py
that contains
password="aasdfasdfasdfsdf" # md5.new(admin_password).hexdigest()
otherwise admin will not be accessible. There should also be a way to make sure that /admin/* requests only go via https or ssh tunnels.
Massimo
You'd know better than I but can't the password be specified in start_web2py.py in the following line?
HttpServer(port=%(port)s).start()
Re the admin, it seems web2py checks the X-Forwarded-For in addition to REMOTE_ADDR to determine if the request is local so when you setup web2py using my installer you won't be able to use the admin unless you use an SSH tunnel. Is that good enough?
Last edited by IAIHMB (2008-03-19 14:33:04)
Offline
Version 1.27 will support x_forward_for, the current version (1.26) does not. In the current version if you go over mod_proxy admin will be exposed and it will think it is running from localhost.
We can wait one week when version 1.27 will be posted. From your prospective there is a value in allowing users to do everything through the web interface without having to create tunnels.
Whatever you do, you still need to set the password.
You can set the password programmatically by calling
python web2py.py -a password
or as you suggest
from gluon.main import HttpServer
server=HttpServer(password="password",...)
one way or another a password has to be set otherwise admin will not be accessible, not even by tunneling. It would be great if the admin password were set to the same password used to login into webfaction. If you set it in some other way you need to communicate it to the user somehow. Do you have the ability to send email?
Offline
You can set the password programmatically by calling
python web2py.py -a password
I wouldn't recommend that approach in a shared hosting environment. Someone could see your password if they were to execute "ps -o command -u (Your Username)". Anyways, I get the idea. I'll update the script to use a password.
If you set it in some other way you need to communicate it to the user somehow. Do you have the ability to send email?
I think displaying it in "Your web2py application has been created successfully! It's default admin password is..." type message would probably be the way to go but e-mail is an option. So, other than setting a password is there anything that can be done to improve the installer? The sooner all of the problems are worked out the sooner we can consider adding it to the control panel. ![]()
Offline
Thank you. Any chance I can try it before it goes live?
I thing it should work fine. The only thing I am concerned is security since you are setting it up for your clients.
Offline
mdipierro wrote:
Thank you. Any chance I can try it before it goes live?
I thing it should work fine. The only thing I am concerned is security since you are setting it up for your clients.
You can test it now, just:
1) Go to "Domain Names/Websites -> Applications" in the control panel and click the "Create" button.
2) Set "Application Type" to "Custom Install Script".
3) Click the "View/Hide Script" link and paste the script in the "Install Script" field.
4) Click the create button.
Then you can add it to a website just like any other application. ![]()
Offline
When will the web2py script be available in the installer?
Offline
ejtech wrote:
When will the web2py script be available in the installer?
We currently have no plans to add an official installer for web2py - but the instructions presented in this thread do work.
Regards,
Sean F
Offline
seanf wrote:
We currently have no plans to add an official installer for web2py - but the instructions presented in this thread do work.
So how do I setup an admin password then?
A step by step list from the start would be most helpful, if anyone can advise. Thanks.
Offline
ejtech,
you can just create the password file locally on your PC and copy it on webfaction using ssh. Alternatively you just import gluon.main and use the save_password function in there from any Python program.
seanf.
You should really consider supporting web2py via your interface. You do support other Python frameworks and here are some recent trends
http://www.google.com/trends?q=web2py%2 … amp;sort=0
Web2py interface would allow you to compete with Heroku because users could be able to do everything on the web including development and maintenance.
If you choose to do so I can help (for free)!
Mind that web2py runs on google app engine too so if you make the entry barrier to high users will move away.
Offline
Ok, It sets up great, but how do I get to the admin?
Offline
for a more modern installation:
"setup web2py as wsgi" -- http://forum.webfaction.com/viewtopic.p … 8473#p8473
Offline
Here are the steps I use to set up web2py development server (non-wsgi) on Webfaction:
Create two subdomains: one for site, one for admin
Create a new webfaction 'custom install script' application through control panel; copying and pasting the script code at top of this thread from IAIHMB/David Sissitka; do not be concerned that it uses Python2.4, that's just the installer
create two new sites through control panel; both will use newly created application at '/' ; make the admin site https
edit ~/webapps/[your-web2py]/start_web2py.py:
- HttpServer(port=NNNN).start()
+ HttpServer(port=NNNN,password='your-passord').start()
you can then start the server with:
screen python2.5 start_web2py.py
and from another terminal, 'screen -d' to detach the first screen
Offline