Hi all, I'm trying to learn how to use web2py, it's my first time using a framework to develop web apps, I have to say it's being very hard to learn because all the documentation is very outdated. Now I'm trying to set up web2py to work with postrgerSQL and nginx on a fresh Debian 10 install. Not sure how to do it properly since all the examples are for old linux distros that don't use systemd, I tried using the script that I found here: https://github.com/motasmarcelo/setup-web2py-nginx-uwsgi-debian8
because it's the most recent I could find But I modified it to use Python3 as follows: #!/bin/bashLOG_FILE=/tmp/setup-web2py.loglogged () { echo $(date +"%F_%T") $* | tee -a $LOG_FILE}echo 'Setup-web2py-nginx-uwsgi-debian8.sh'echo 'Requires Debian 8 (Jessie) and installs Nginx + uWSGI + Web2py'# Check if user has root privilegesif [[ $EUID -ne 0 ]]; then logged "Aborting..." logged "You must run the script as root or using sudo" exit 1filogged "Starting SETUP on $(date)"# Get Web2py Application Nameecho -e "Web2py Application Name: \c "read APPNAMEecho# Get Domain Nameecho -e "Enter app's domains names (Ex: www.example.com, example.com): \c "read DOMAINSecho# Get Web2py Admin Passwordecho -e "Web2py Admin Password: \c "read PWlogged "[+]Updating system and installing needed software"# Upgrade and install needed softwareapt-get updateapt-get -y upgradeapt-get -y autoremoveapt-get -y autocleanecho "Installing nginx"apt-get -y install nginxecho "Installing uwsgi"apt-get -y install uwsgi uwsgi-plugin-python3apt-get -y install build-essential sudo python3-dev libxml2-dev unzipechologged "[+]Configuring nginx's $APPNAME config at /etc/nginx/conf.d/$APPNAME"# Create common nginx sectionsmkdir /etc/nginx/conf.d/"$APPNAME"echo 'gzip_static on;gzip_http_version 1.1;gzip_proxied expired no-cache no-store private auth;gzip_disable "MSIE [1-6]\.";gzip_vary on;' > /etc/nginx/conf.d/"$APPNAME"/gzip_static.confecho 'gzip on;gzip_disable "msie6";gzip_vary on;gzip_proxied any;gzip_comp_level 6;gzip_buffers 16 8k;gzip_http_version 1.1;gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;' > /etc/nginx/conf.d/"$APPNAME"/gzip.conf# Create configuration file /etc/nginx/sites-available/"$APPNAME"echo "server { listen 80; server_name $DOMAINS; ###to enable correct use of response.static_version #location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ { # alias /home/www-data/$APPNAME/applications/\$1/static/\$2; # expires max; #} ### ###if you use something like myapp = dict(languages=['en', 'it', 'jp'], default_language='en') in your routes.py #location ~* ^/(\w+)/(en|it|jp)/static/(.*)$ { # alias /home/www-data/$APPNAME/applications/\$1/; # try_files static/\$2/\$3 static/\$3 = 404; #} ### location ~* ^/(\w+)/static/ { root /home/www-data/$APPNAME/applications/; #remove next comment on production #expires max; ### if you want to use pre-gzipped static files (recommended) ### check scripts/zip_static_files.py and remove the comments # include /etc/nginx/conf.d/$APPNAME/gzip_static.conf; ### } location / { uwsgi_pass unix:///tmp/$APPNAME.socket; include uwsgi_params; uwsgi_param UWSGI_SCHEME \$scheme; uwsgi_param SERVER_SOFTWARE 'nginx/\$nginx_version'; ###remove the comments to turn on if you want gzip compression of your pages # include /etc/nginx/conf.d/$APPNAME/gzip.conf; ### end gzip section ### remove the comments if you use uploads (max 10 MB) #client_max_body_size 10m; ### }}server { listen 443 ssl spdy; server_name $DOMAINS; ssl_certificate /etc/nginx/ssl/$APPNAME.crt; ssl_certificate_key /etc/nginx/ssl/$APPNAME.key; ssl_prefer_server_ciphers on; ssl_session_cache shared:ssl_session_cache:1M; ssl_session_timeout 600m; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:EDH-RSA-DES-CBC3-SHA; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; keepalive_timeout 70; location / { uwsgi_pass unix:///tmp/$APPNAME.socket; include uwsgi_params; uwsgi_param UWSGI_SCHEME \$scheme; uwsgi_param SERVER_SOFTWARE 'nginx/\$nginx_version'; ###remove the comments to turn on if you want gzip compression of your pages # include /etc/nginx/conf.d/$APPNAME/gzip.conf; ### end gzip section ### remove the comments if you want to enable uploads (max 10 MB) #client_max_body_size 10m; ### } ## if you serve static files through https, copy here the section ## from the previous server instance to manage static files}" >/etc/nginx/sites-available/"$APPNAME"#Link to sites-enabled (up)ln -s /etc/nginx/sites-available/"$APPNAME" /etc/nginx/sites-enabled/"$APPNAME"rm /etc/nginx/sites-enabled/defaultlogged "[+]Building SSL/TLS stuff"#### Work on SSL stuffmkdir /etc/nginx/sslcd /etc/nginx/ssl# Create a temporary openssl confecho "[ req ]default_bits = 2048default_keyfile = privkey.pemdistinguished_name = req_distinguished_namestring_mask = utf8only[ req_distinguished_name ]countryName = Country Name (2 letter code)countryName_default = AUcountryName_min = 2countryName_max = 2stateOrProvinceName = State or Province Name (full name)stateOrProvinceName_default = Some-StatelocalityName = Locality Name (eg, city)0.organizationName = Organization Name (eg, company)0.organizationName_default = Internet Widgits Pty LtdorganizationalUnitName = Organizational Unit Name (eg, section)commonName = Common Name (e.g. server FQDN, your PRIMARY domain)commonName_max = 64emailAddress = Email AddressemailAddress_max = 64[ usr_cert ]basicConstraints=CA:TRUEkeyUsage = digitalSignature, keyEncipherment, keyAgreementextendedKeyUsage=serverAuthsubjectKeyIdentifier=hashauthorityKeyIdentifier=keyid,issuer" > /tmp/openssl.cnflogged '[+]Creating a x509 certificate (2048 bits key-length and valid for 365 days) to run HTTPS'openssl genrsa -out "$APPNAME".key 2048chmod 400 "$APPNAME".keyopenssl req -new -x509 -sha256 -days 365 -key "$APPNAME".key -config /tmp/openssl.cnf -extensions usr_cert -out "$APPNAME".crtopenssl x509 -noout -fingerprint -text -in "$APPNAME".crt > "$APPNAME".inform -rf /tmp/certificate.txtlogged "[+]Creating uwsgi configuration file /etc/uwsgi/apps-available/$APPNAME.ini"####### Create configuration file /etc/uwsgi/"$APPNAME".iniecho "[uwsgi]socket = /tmp/$APPNAME.socketpythonpath = /home/www-data/$APPNAME/mount = /=wsgihandler:applicationprocesses = 4master = trueharakiri = 60reload-mercy = 8cpu-affinity = 1stats = /tmp/$APPNAME.stats.socketmax-requests = 2000limit-as = 512reload-on-as = 256reload-on-rss = 192uid = www-datagid = www-datacron = 0 0 -1 -1 -1 python3 /home/www-data/$APPNAME/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -ono-orphans = trueenable-threads = true" >/etc/uwsgi/apps-available/"$APPNAME".iniln -s /etc/uwsgi/apps-available/"$APPNAME".ini /etc/uwsgi/apps-enabled/logged "[+]Downloading and installing Web2py"# Install Web2pymkdir /home/www-datacd /home/www-datawget http://web2py.com/examples/static/web2py_src.zipunzip web2py_src.ziprm web2py_src.zipmv web2py "$APPNAME"chown -R www-data:www-data "$APPNAME"cd /home/www-data/"$APPNAME"sudo -u www-data python3 -c "from gluon.main import save_password; save_password('$PW',443)"# Needed on new versions of web2py where new folders where addedln -s handlers/wsgihandler.py .logged "[+]"Creating app\'s remove\(rm\) script at /home/www-data/"$APPNAME"/"$APPNAME"_remove_app.sh#Create app remove(rm) scriptecho "#!/bin/bashrm -rf /etc/uwsgi/apps-available/"$APPNAME".ini /tmp/$APPNAME* /home/www-data/$APPNAMEsystemctl stop nginx.servicefind /etc/nginx/ -name *$APPNAME* -exec rm -rf {} \\;systemctl restart nginx.servicesystemctl reload uwsgi.service" > /home/www-data/"$APPNAME"/"$APPNAME"_remove_app.sh && chmod +x /home/www-data/"$APPNAME"/"$APPNAME"_remove_app.shlogged '[+](Re)Starting services'#(Re)Start servicessystemctl restart nginx.servicesystemctl restart uwsgi.serviceecho 'Done! Enjoy your app!'echoecho -e '**** you can reload uwsgi withsudo systemctl reload uwsgi.service**** and stop it withsudo systemctl stop uwsgi.service**** to reload web2py only (without restarting uwsgi)sudo touch --no-dereference /etc/uwsgi/"$APPNAME".ini'logged 'Finished SETUP'echo '=====================================================' | tee -a "$LOG_FILE" I'm just testing locally so I don't have a public IP address or a domain name so I just enter random names for domain name and app name. I get a 502 bad gateway error when I try to browse the website. In my /var/log/uwsgi/app/appname.log I get this errors: Mon Jul 6 04:15:02 2020 - mapped 364600 bytes (356 KB) for 4 cores Mon Jul 6 04:15:02 2020 - *** Operational MODE: preforking *** Mon Jul 6 04:15:02 2020 - *** no app loaded. going in full dynamic mode *** Mon Jul 6 04:15:02 2020 - *** uWSGI is running in multiple interpreter mode *** Mon Jul 6 04:15:02 2020 - !!!!!!!!!!!!!! WARNING !!!!!!!!!!!!!! Mon Jul 6 04:15:02 2020 - no request plugin is loaded, you will not be able to manage requests. Mon Jul 6 04:15:02 2020 - you may need to install the package for your language of choice, or simply load it with --plugin. Mon Jul 6 04:15:02 2020 - !!!!!!!!!!! END OF WARNING !!!!!!!!!! I need help to make this work since I really don't know how to fix this because I basically don't know what I'm doing and I would also like to run uwsgi in emperor mode but I don;t really know how to achieve that, any help would be highly appreciated. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/5b7d2665-22f6-4ae3-abc2-053fc08c09cao%40googlegroups.com.