In this tutorial, we will show you how to install and configuration of Web2py on your CentOS 7. For those of you who didn’t know, Web2Py is a free open-source full-stack framework for the rapid development of fast, scalable, secure, and portable database-driven web-based applications. With web2py, you can easily develop and manage your applications through the use of an administrative web UI.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS or dedicated server. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Web2py on a CentOS 7 server.
- A server running one of the following operating systems: CentOS 7.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install Web2py on CentOS 7
Step 1. First, let’s start by ensuring your system is up-to-date.
yum clean all yum -y update
Step 2. Installing Web2py.
Create your application directory and clone the repository to our user’s home directory:
mkdir /opt/web2pyapp git clone --recursive https://github.com/web2py/web2py.git /opt/web2pyapp
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
You will have to fill out some information for the certificate you are generating. The only part that actually matters in this circumstance is the Common Name field, which should reference your server’s domain name or IP address:
Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:New York Locality Name (eg, city) :New York City Organization Name (eg, company) [Web2Py]:idr00t Organizational Unit Name (eg, section) : Common Name (e.g. server FQDN or YOUR name) :server_domain_or_IP Email Address :email@example.com
Set proper privileges for the SSL certificate:
cd /opt chmod 700 web2pyapp_keys chmod -R 600 web2pyapp_keys/*
We are ready to start our python application server now:
$ python /opt/web2pyapp/web2py.py -a 'STRONG-PASSWORD-HERE' -k /opt/web2pyapp_keys/web2pyapp.key web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2016 Version 2.14.6-stable+timestamp.2016.12.05.19.18.48 Database drivers available: sqlite3, imaplib, pymysql, pg8000 please visit: https://127.0.0.1:8000/ use "kill -SIGTERM 1284" to shutdown the web2py server
Step 3. Accessing Web2py.
Web2py will be available on HTTP port 8000 by default. Open your favorite browser and navigate to
http://your-server-ip:8000. Accept the certificate warning and the Web2Py welcoming page should appear. To log in to the administration back-end, click on my sites and enter your password, the one that you used while starting the web server. If you are using a firewall, please open port 8000 to enable access to the control panel.
Congratulations! You have successfully installed Web2py. Thanks for using this tutorial for installing Web2py on your CentOS 7 system. For additional help or useful information, we recommend you to check the official Web2py website.