We will need an SSL key and a certificate so that we can later access the administrative interface. For safety reasons, it is best if we put them in a different directory.

# mkdir /opt/web2pyapp_keys
# cd /opt/web2pyapp_keys
# openssl req -x509 -new -newkey rsa:4096 -days 3652 -nodes -keyout web2pyapp.key -out web2pyapp.crt
Generating a 4096 bit RSA private key
......++
.......................................................++
writing new private key to 'web2pyapp.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:US
State or Province Name (full name) []:Missouri
Locality Name (eg, city) [Default City]:St. Louis
Organization Name (eg, company) [Default Company Ltd]:Web2Py
Organizational Unit Name (eg, section) []:Web2Py
Common Name (eg, your name or your server's hostname) []:web2py.myvps.com
Email Address []:
### Set proper privileges for the ssl certificate
cd /opt
# chmod 700 web2pyapp_keys
# chmod -R 600 web2pyapp_keys/*

If everything is done correctly by this step, this is how should our layout in /opt should look like.

IMPORTANT: Make sure that you put your own strong password after the -a flag.
Open up a web browser and put https://VPS-IP-ADDRESS:8000/ in the navbar, where VPS-IP-ADDRESS is your VPS IP Address.
Accept the certificate warning and the Web2Py welcoming page should appear. To login to the administration back-end, click on mysites and enter your password, the one that you used while starting the webserver.

To stop the webserver use the CTRL+C key combination.

Avoiding the open terminal to keep the Web2Py server alive

Since the Web2Py service requires an open terminal to be active, one option that you can use if you wish to exit the terminal and continue working, is by using the ampersand at the end of the command after which you can exit the SSH session.

To stop the server use the process ID that is provided when you start the server:

# kill -9 1468

Keep in mind that with this way you may miss any important errors or warnings that may show up on the server while you are developing.

Of course, you don’t have to do any of this if you use one of our Python VPS Hosting services, in which case you can simply ask our expert Linux admins to install Web2Py for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.