datasci
datasci

Reputation: 1029

Deploying a Web2py App

I'm deploying a Web2py application via CentOS VPS on Bluehost with Apache pre-installed.

I've manually gone through the process of installing Web2py, Python, and some additional software in /home/username. When I run the following command in /home/username/web2py to launch Web2py via Rocket at port 8000 python web2py.py --ip xxx.xx.xx.xx --port=8000, I and others can successfully visit http://xxx.xx.xx.xx/8000 or http://mywebsite.com/8000 to view Web2py's welcome screen (and ultimately my application).

However, when I attempt to run python web2py.py --ip xxx.xx.xx.xx --port=80, so that I can visit the application at http://xxx.xx.xx.xx/ or http://mywebsite.com/, I receive the following error:

ERROR:Rocket.Errors.Port80:Socket in use by other process and it won't share 

Apache is already running on port 80. Ultimately, I'd like the user to visit the application at http://xxx.xx.xx.xx/ or http://mywebsite.com/. How do I make this happen in my current configuration WITHOUT using one step production deployment described here: http://web2py.com/book/default/chapter/13#Apache-setup?

I'm interested in how to do this in each of the following three ways:

1) Using the pre-installed Apache server already on port 80.

2) Using the Web2py's built-in Rocket server on port 80, thus adjusting the system so that the pre-installed Apache server is ignored and port 80 opened.

3) Using the built-in Rocket server on another port, say 8000, but doing so in such a way that the user can still access the site and all of its functionality by visiting http://xxx.xx.xx.xx/ or http://mywebsite.com/. THis means that they would NOT need to append 8000 to the url (as in http://xxx.xx.xx.xx/8000 or http://mywebsite.com/8000).

Thank you.

Upvotes: 0

Views: 1093

Answers (1)

Maximilian Kindshofer
Maximilian Kindshofer

Reputation: 2843

A port can only be used by one application. So you can't run both an Apache and a web2py server on the same port (e.g. port 80).

All ports from 0 to 1024 are privileged ports. This means only a superuser can assign an application to the port. Typically this can also produce sayed error message, that the port is in use (even if there is no application listening to the port)

Case 1 and 3 - Using the Apache-Server but not mod_wsgi:

I assume you don't want to use modwsgi or any wsgi on you apache. Than you have to proxy you application with mod_proxy:

<VirtualHost *:80>
   Alias / /users/www-data/web2py/applications
   ### serve static files directly
   <LocationMatch "^/static/.*">
    Order Allow, Deny
    Allow from all
   </LocationMatch>
   ### proxy all the other requests
   <Location "/">
     Order deny,allow
     Allow from all
     ProxyRequests off
     ProxyPass http://localhost:8000/
     ProxyPassReverse http://localhost:8000/
     ProxyHTMLURLMap http://127.0.0.1:8000/ /
   </Location>

You have to adjust the Locations to your actual setup and the web2py server has to be running.

Case 2 - Not using apache:

In this case you have to stop the apache server and start you application with a privileged account (e.g. root):

sudo python web2py.py --ip xxx.xx.xx.xx --port=80

Hope this helps ;)

Upvotes: 2

Related Questions