Ubuntu 16.04 - installation script stops

424 views
Skip to first unread message

Martin Weissenboeck

unread,
Aug 8, 2016, 12:39:51 PM8/8/16
to web2py-users
I have tried to setup a new web2py server with nginx  on Ubuntu 16.04 LTS

I have used the script


The script stopped with 

 extracting: web2py/applications/__init__.py
 extracting: web2py/site-packages/__init__.py
[ ok ] Starting nginx (via systemctl): nginx.service.
./setup-web2py-nginx-uwsgi-ubuntu.sh: line 217: start: command not found


Nginx seems to work:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.


Any comments?

By the way: I have tried the Apache version too - the Apache script works correctly.

Regards, Martin

Niphlod

unread,
Aug 8, 2016, 3:45:30 PM8/8/16
to web2py-users, mwei...@gmail.com
as soon as I get some free time this should become the new (and only) "official" script. Or as soon as somebody else takes that responsibility.

Message has been deleted

Martin Weissenboeck

unread,
Aug 9, 2016, 5:39:56 AM8/9/16
to Niphlod, web2py-users
Thank you for this script. I am using a dedicted server from noez.de and it is possible to choose one of a lot of operating systems. I have choosen Ubuntu 16.04.

I have tried:

chmod 755 web2py-on-ubuntu.sh
./web2py-on-ubuntu.sh

I got an error message - these are the last lines:

upstream web2py27 {
    server unix:///run/uwsgi/web2py27.socket;
}

server {
        listen          80;
        server_name     $hostname;

        # static serving
        include /etc/nginx/conf.d/web2py/serve_static.conf;
        include /etc/nginx/conf.d/web2py/serve_web2py27.conf;
}
server {
        listen 443 default_server ssl;
        server_name     $hostname;
        ssl_certificate         /etc/nginx/ssl/web2py.crt;
        ssl_certificate_key     /etc/nginx/ssl/web2py.key;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
        ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets off; # Requires nginx >= 1.5.9
        ssl_stapling on; # Requires nginx >= 1.3.7
        ssl_stapling_verify on; # Requires nginx => 1.3.7
        resolver 8.8.8.8 8.8.4.4 valid=300s;
        resolver_timeout 5s;
        ssl_dhparam /etc/ssl/certs/dhparam.pem;
        ## remove only if you know what youre doing
./web2py-on-ubuntu.sh: line 116: include: command not found
./web2py-on-ubuntu.sh: line 117: include: command not found
./web2py-on-ubuntu.sh: line 139: } >/etc/nginx/sites-available/web2py27

ln -s /etc/nginx/sites-available/web2py27 /etc/nginx/sites-enabled/web2py27
rm /etc/nginx/sites-enabled/default
cd /etc/ssl/certs
openssl dhparam -out dhparam.pem 4096
mkdir /etc/nginx/ssl
cd /etc/nginx/ssl

if [ "$nocertificate" -eq 0 ]
then
  openssl req -x509 -newykey rsa:2048 -nodes -keyout web2py.key -out web2py.crt -days 1780
  chmod 400 web2py.key
  openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
fi
# Prepare folders for uwsgi
sudo mkdir /etc/uwsgi
sudo mkdir /etc/uwsgi/vassals


#uWSGI Emperor
echo [Unit]: No such file or directory
./web2py-on-ubuntu.sh: line 140: Description: command not found
./web2py-on-ubuntu.sh: line 141: After: command not found
./web2py-on-ubuntu.sh: line 142: [Service]: command not found
./web2py-on-ubuntu.sh: line 143: ExecStart: command not found
./web2py-on-ubuntu.sh: line 144: RuntimeDirectory: command not found
./web2py-on-ubuntu.sh: line 145: Restart: command not found
./web2py-on-ubuntu.sh: line 146: KillSignal: command not found
./web2py-on-ubuntu.sh: line 147: Type: command not found
./web2py-on-ubuntu.sh: line 148: StandardError: command not found
./web2py-on-ubuntu.sh: line 149: NotifyAccess: command not found
./web2py-on-ubuntu.sh: line 150: [Install]: command not found
./web2py-on-ubuntu.sh: line 151: WantedBy: command not found
./web2py-on-ubuntu.sh: line 154:  > /etc/systemd/system/emperor.uwsgi.service
# Create configuration for emperor
echo [uwsgi]: No such file or directory
./web2py-on-ubuntu.sh: line 155: emperor: command not found
./web2py-on-ubuntu.sh: line 156: uid: command not found
./web2py-on-ubuntu.sh: line 157: gid: command not found
./web2py-on-ubuntu.sh: line 160: >/etc/uwsgi/emperor.ini
# Create configuration file /etc/uwsgi/web2py.ini
echo [uwsgi]: No such file or directory
./web2py-on-ubuntu.sh: line 161: home: command not found
./web2py-on-ubuntu.sh: line 162: socket: command not found
./web2py-on-ubuntu.sh: line 163: pythonpath: command not found
mount: mount point /=wsgihandler:application does not exist
./web2py-on-ubuntu.sh: line 165: processes: command not found
./web2py-on-ubuntu.sh: line 166: vacuum: command not found
./web2py-on-ubuntu.sh: line 167: master: command not found
./web2py-on-ubuntu.sh: line 168: harakiri: command not found
./web2py-on-ubuntu.sh: line 169: reload-mercy: command not found
./web2py-on-ubuntu.sh: line 170: cpu-affinity: command not found
./web2py-on-ubuntu.sh: line 171: stats: command not found
./web2py-on-ubuntu.sh: line 172: max-requests: command not found
./web2py-on-ubuntu.sh: line 173: limit-as: command not found
./web2py-on-ubuntu.sh: line 174: reload-on-as: command not found
./web2py-on-ubuntu.sh: line 175: reload-on-rss: command not found
./web2py-on-ubuntu.sh: line 176: uid: command not found
./web2py-on-ubuntu.sh: line 177: gid: command not found
./web2py-on-ubuntu.sh: line 178: touch-reload: command not found
cron: invalid option -- '1'
usage: cron
./web2py-on-ubuntu.sh: line 180: no-orphans: command not found
./web2py-on-ubuntu.sh: line 199: unexpected EOF while looking for matching `''
./web2py-on-ubuntu.sh: line 216: syntax error: unexpected end of file
root@f82uxxxx

Problems with the echo command?

Niphlod

unread,
Aug 9, 2016, 5:51:38 AM8/9/16
to web2py-users, nip...@gmail.com, mwei...@gmail.com
ahem. maybe a dos2unix first solves it.

Mirek Zvolský

unread,
Aug 9, 2016, 8:03:18 AM8/9/16
to web2py-users, mwei...@gmail.com
If you have lot of time, you can test if this script works:


Here I try use systemctl instead of start.







Dne pondělí 8. srpna 2016 18:39:51 UTC+2 mweissen napsal(a):

Mirek Zvolský

unread,
Aug 9, 2016, 8:06:23 AM8/9/16
to web2py-users, mwei...@gmail.com
Or maybe all is properly installed but the service control command is unknown.
So you can just try the systemctl command from bottom of (patched) script:

sudo systemctl restart nginx

sudo systemctl restart emperor
.uwsgi





Dne úterý 9. srpna 2016 14:03:18 UTC+2 Mirek Zvolský napsal(a):

Martin Weissenboeck

unread,
Aug 9, 2016, 8:19:01 AM8/9/16
to Mirek Zvolský, web2py-users

Ok, I'll try it. It takes only about 15 minutes to get new "fresh" server.

Ron Chatterjee

unread,
Aug 9, 2016, 10:43:40 AM8/9/16
to web...@googlegroups.com
Does someone has a similar script for sun solaris? Reason I asked because oracle still sells lot of their servers with solaris os as oppose to linux. Would be interesting to know. I would imagine it would be the same installation process. Correct me if I am wrong. 

Mirek Zvolský

unread,
Dec 8, 2016, 7:31:30 AM12/8/16
to web2py-users, mwei...@gmail.com
The link is no longer working.
Here is the script. This version worked for me:

#!/bin/bash
echo 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh'
echo 'Requires Ubuntu > 12.04 or Debian >= 8 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
   echo "You must run the script as root or using sudo"
   exit 1
fi
# parse command line arguments
nopassword=0
nocertificate=0
while [ "$#" -gt 0 ]; do
  case "$1" in
    --no-password) nopassword=1; shift 1;;
    --no-certificate) nocertificate=1; shift 1;;
  esac
done
# Get Web2py Admin Password
if [ "$nopassword" -eq 0 ]
then
  echo -e "Web2py Admin Password: \c "
  read  PW
fi
# Upgrade and install needed software
apt-get update
apt-get -y upgrade
apt-get autoremove
apt-get autoclean
apt-get -y install nginx-full
apt-get -y install build-essential python-dev libxml2-dev python-pip unzip
pip install setuptools --no-use-wheel --upgrade
PIPPATH=`which pip`
$PIPPATH install --upgrade uwsgi
# Create common nginx sections
mkdir /etc/nginx/conf.d/web2py
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/web2py/gzip_static.conf
echo '
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/web2py/gzip.conf
# Create configuration file /etc/nginx/sites-available/web2py
echo 'server {
        listen          80;
        server_name     $hostname;
        ###to enable correct use of response.static_version
        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /home/www-data/web2py/applications/$1/static/$2;
            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/web2py/gzip_static.conf;
        }
        ###

        ###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/web2py/applications/$1/;
        #    try_files static/$2/$3 static/$3 =404;
        #}
        ###
        
        location / {
            #uwsgi_pass      127.0.0.1:9001;
            uwsgi_pass      unix:///tmp/web2py.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/web2py/gzip.conf;
            ### end gzip section

            ### remove the comments if you use uploads (max 10 MB)
            #client_max_body_size 10m;
            ###
        }
}
server {
        listen 443 default_server ssl;
        server_name     $hostname;
        ssl_certificate         /etc/nginx/ssl/web2py.crt;
        ssl_certificate_key     /etc/nginx/ssl/web2py.key;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        keepalive_timeout    70;
        location / {
            #uwsgi_pass      127.0.0.1:9001;
            uwsgi_pass      unix:///tmp/web2py.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/web2py/gzip.conf;
            ### end gzip section
            ### remove the comments if you want to enable uploads (max 10 MB)
            #client_max_body_size 10m;
            ###
        }
        ###to enable correct use of response.static_version
        location ~* ^/(\w+)/static(?:/_[\d]+\.[\d]+\.[\d]+)?/(.*)$ {
            alias /home/www-data/web2py/applications/$1/static/$2;
            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/web2py/gzip_static.conf;
        }
        ###

}' >/etc/nginx/sites-available/web2py

ln -s /etc/nginx/sites-available/web2py /etc/nginx/sites-enabled/web2py
rm /etc/nginx/sites-enabled/default
mkdir /etc/nginx/ssl
cd /etc/nginx/ssl
if [ "$nocertificate" -eq 0 ]
then
  openssl genrsa 1024 > web2py.key
  chmod 400 web2py.key
  openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt
  openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
fi
# Prepare folders for uwsgi
sudo mkdir /etc/uwsgi
sudo mkdir /var/log/uwsgi
sudo mkdir /etc/systemd
sudo mkdir /etc/systemd/system

#uWSGI Emperor
echo '[Unit]
Description = uWSGI Emperor
After = syslog.target

[Service]
ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
RuntimeDirectory = uwsgi
Restart = always
KillSignal = SIGQUIT
Type = notify
StandardError = syslog
NotifyAccess = all

[Install]
WantedBy = multi-user.target
' > /etc/systemd/system/emperor.uwsgi.service

# Create configuration file /etc/uwsgi/web2py.ini
echo '[uwsgi]

socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 512
reload-on-as = 256
reload-on-rss = 192
uid = www-data
gid = www-data
touch-reload = /home/www-data/web2py/routes.py
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
no-orphans = true
' >/etc/uwsgi/web2py.ini

#Create a configuration file for uwsgi in emperor-mode
#for Upstart in /etc/init/uwsgi-emperor.conf
echo '# Emperor uWSGI script

description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [06]
##
#remove the comments in the next section to enable static file compression for the welcome app
#in that case, turn on gzip_static on; on /etc/nginx/nginx.conf
##
#pre-start script
#    python /home/www-data/web2py/web2py.py -S welcome -R scripts/zip_static_files.py
#    chown -R www-data:www-data /home/www-data/web2py/*
#end script
respawn
exec uwsgi --master --die-on-term --emperor /etc/uwsgi --logto /var/log/uwsgi/uwsgi.log
' > /etc/init/uwsgi-emperor.conf
# Install Web2py
mkdir /home/www-data
cd /home/www-data
unzip web2py_src.zip
mv web2py/handlers/wsgihandler.py web2py/wsgihandler.py
rm web2py_src.zip
chown -R www-data:www-data web2py
cd /home/www-data/web2py
if [ "$nopassword" -eq 0 ]
then
   sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)"
fi

sudo systemctl restart nginx
sudo systemctl restart emperor.uwsgi

echo <<EOF
you can stop uwsgi and nginx with

  sudo systemctl stop nginx
  sudo systemctl stop emperor.uwsgi
 
and start it with

  sudo systemctl start nginx
  sudo systemctl start emperor.uwsgi

EOF


Richard Vézina

unread,
Dec 8, 2016, 10:04:44 AM12/8/16
to web2py-users
Hello Mirek,

Can send a PR over github so we get a better idea what your improvements are and can include them more easily.

Thanks

Richard

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages