[Web design] Deploy web2py server with Nginx in Debian

Web2py is a great python web platform. However I don’t find any article on how to integrate it to Nginx. I also found a few issues that were not that easy to solve.

Web2py doesn’t need to be installed. Simple download the latest version.

cd /www
wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
rm web2py_src.zip

Install uwsgi by:

apt-get install uwsgi
apt-get install uwsgi-plugin-python

Add a setting profile to /etc/uwsgi/apps-available/web2py.xml

<uwsgi>
    <socket>/tmp/web2py.socket</socket>
    <pythonpath>/www/web2py/</pythonpath>
    <mount>/=wsgihandler:application</mount>
    <master/>
    <processes>1</processes>
    <harakiri>60</harakiri>
    <reload-mercy>8</reload-mercy>
    <cpu-affinity>1</cpu-affinity>
    <stats>/tmp/stats.socket</stats>
    <max-requests>2000</max-requests>
    <limit-as>512</limit-as>
    <reload-on-as>256</reload-on-as>
    <reload-on-rss>192</reload-on-rss>
    <uid>nginx</uid>
    <gid>nginx</gid>
    <no-orphans/>
    <plugins>python</plugins>
</uwsgi>

make a link to app-enable:

ln -s /etc/uwsgi/apps-available/web2py.xml /etc/uwsgi/apps-enabled/

restart uwsgi service:

service uwsgi restart

Modify nginx vhost file, adding the following to server section:

        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /www/web2py/applications/$1/static/$2;
            #remove next comment on production
            #expires max;
        }
        location / {
            root /www/web2py/applications/;
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
        }

change the folder name as you need. Go to /www/web2py directory and set the password for 80 port, change owner of the folder to nginx:

chown -R nginx:nginx /www/web2py
cd /www/web2py
sudo -u nginx python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),80)"

till now, you should be able to visit the default welcome project by the top level domain.

If you need to deploy the project at a subdirectory, you need to change the nginx settings to:

        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /www/web2py/applications/$1/static/$2;
            #remove next comment on production
            #expires max;
        }
        location /app/ {
            root /www/web2py/applications/;
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
            uwsgi_param SCRIPT_NAME /app;
            uwsgi_modifier1 30;
        }

Web2py is located at http://yourdomain.com/app now. Due to the security reason, by default, web2py doesn’t allow you to connect from remote. To change this, you need to modify the file applications/admin/model/access.py by adding

request.is_local=True

before

if request.is_https:
    session.secure()
elif not request.is_local and not DEMO_MODE:
    raise HTTP(200, T('Admin is disabled because insecure channel'))

Replys:

  1. Namxokprari

    Where to Take Installment Loans?

    If you want money at once, the most optimal way to receive it is to turn to installment loans which have been historically taken into consideration as the most working and opportune for huge purchasing. In this case, installment loan passes for a limited loan, supposing an indicated timeframe for start and end that should be identified at the time of process of application. Everyone can pop up how frequently he will return the money. For instance, everybody might apply for the loan, being formed in the form of a monthly payment with twenty four the same parts for two years.

    Taking into account installment loan varieties, you may take out between unsecured and secured one. Unsecured type presents itself signature loan since it would be secured only with contract signing and justification of your readiness in such a way. Secured loan type must be supported by bail which may be altered in the event of unforeseen developments. Let's analyse an example, automobile loan is frequently upheld by the vehicle you pay cash in hand for. Thus, Idaho installment loans with bad credit become a real escape to receive cash at profitable rates.

    Installment Loans with Bad Credit Scores

    To be honest, you decide on only two ways. The first one means to come in a banking establishment, but take into consideration that the causes for applying for installment loans are really limited: private, mortgage, student, and vehicle loans. To add to it, banking institutions dispose severe conditions for these lends, especially if you need an unsecured type. Borrowers with marginal form of credit should search after a co-signer that must be creditworthy and responsible. Furthermore, banks ask for a irritative and time-consuming application that won't suit if you hasten.

    Another variant and effective solution in that case is to make use of our client-oriented services and have installment loans without bad consequences. We secure the most flexible conditions for your definite state of affairs, offering favorable benefits and privileges. You can check it!

    The Best Solution to Take Installment Loan

    With us, you could depend on guaranteed values: Simple and swift|Swift and simple. Our portal esteems your time and wants to save it by granting comfortable online application process. Since you can't wait for several weeks to get 'approved' and have your money , we offer up-to-date replies and variants from creditors.

    Ready money at hand. Our terms are flexible and customizable; so, we distinguish ourselves by a honest working scheme and no extra payments, signifying that we offer a financial aid in case if you want it above all with no questions asked.

    Debtees for your situation. We partner with trustworthy and revised lenders from all over the U.S., who want to help you!|

    Not perfect history shouldn't be called the last sentence. When the majority of banking establishments and debtees tell you 'no' and deny loan, we will make all efforts to look for the most fitting variant for your case. We appreciate all our clients and desire to render an individual attitude!

    Payments you will afford. Have you remembered these enormous rates by examining competitors' portals? We see them too! Furthermore, we prefer to take care of customers than to raise money on their problems.

    No checks of your credits. We see your point why you've turned to us; therefore, we don't take account of your credit history by rendering you an opportunity both to possess cash and improve your credit score for future plans, showing what a reliable borrower you are!

    Reflect upon Installment Loans?

    Don't have doubts and keep in touch us to have more information about installment loans and conditions https://maybeloan.com/installment-loans/il-usa-il . Our consultants are available on the round-the-clock basis and usually wish to help you, that's why you will get a reply within the shortest timeframes. Don't try to wait for the better conditions to posses cash, assume them straight away with our service!


Leave a Reply

Your email address will not be published. Required fields are marked *