{"id":20785,"date":"2016-11-30T07:49:24","date_gmt":"2016-11-30T13:49:24","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=20785"},"modified":"2022-06-03T03:42:30","modified_gmt":"2022-06-03T08:42:30","slug":"install-and-configure-web2py-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/install-and-configure-web2py-on-centos-7\/","title":{"rendered":"How to install and configure web2py on CentOS 7"},"content":{"rendered":"
<\/p>\n
Web2Py is a simple yet powerful Python framework for developing web applications. In this tutorial we will show how to install the Web2Py framework on a CentOS 7 VPS<\/a>.<\/p>\n First things first. Once you have the VPS<\/a> make sure that you update it so that you can have the latest software.<\/p>\n Create your application directory. In this example, we will be working in the \/opt directory but you can use a directory of your choice.<\/p>\n We will need an SSL key and a certificate<\/a> so that we can later access the administrative interface. For safety reasons, it is best if we put them in a different directory.<\/p>\n If everything is done correctly by this step, this is how should our layout in We are ready to start our python application server now.<\/p>\n IMPORTANT:<\/strong> Make sure that you put your own strong password<\/a> after the To stop the webserver use the 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.<\/p>\n To stop the server use the process ID that is provided when you start the server:<\/p>\n 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.<\/p>\n Of course, you don\u2019t have to do any of this if you use one of our Python VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Web2Py\u00a0for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/strong>. 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.<\/p>\n","protected":false},"excerpt":{"rendered":" Web2Py is a simple yet powerful Python framework for developing web applications. In this tutorial we will show how to … <\/p>\n# yum update<\/pre>\n
# mkdir \/opt\/web2pyapp\r\n# git clone --recursive https:\/\/github.com\/web2py\/web2py.git \/opt\/web2pyapp\r\n<\/pre>\n
# mkdir \/opt\/web2pyapp_keys\r\n# cd \/opt\/web2pyapp_keys\r\n# openssl req -x509 -new -newkey rsa:4096 -days 3652 -nodes -keyout web2pyapp.key -out web2pyapp.crt\r\n\r\nGenerating a 4096 bit RSA private key\r\n......++\r\n.......................................................++\r\nwriting new private key to 'web2pyapp.key'\r\n-----\r\nYou are about to be asked to enter information that will be incorporated\r\ninto your certificate request.\r\nWhat you are about to enter is what is called a Distinguished Name or a DN.\r\nThere are quite a few fields but you can leave some blank\r\nFor some fields there will be a default value,\r\nIf you enter '.', the field will be left blank.\r\n-----\r\nCountry Name (2 letter code) [XX]:US\r\nState or Province Name (full name) []:Missouri\r\nLocality Name (eg, city) [Default City]:St. Louis\r\nOrganization Name (eg, company) [Default Company Ltd]:Web2Py\r\nOrganizational Unit Name (eg, section) []:Web2Py\r\nCommon Name (eg, your name or your server's hostname) []:web2py.myvps.com\r\nEmail Address []:\r\n\r\n\r\n### Set proper privileges for the ssl certificate\r\ncd \/opt\r\n# chmod 700 web2pyapp_keys\r\n# chmod -R 600 web2pyapp_keys\/*\r\n<\/pre>\n
\/opt<\/code> should look like.<\/p>\n
# ls -l \/opt\r\ntotal 8\r\ndrwxr-xr-x 13 root root 4096 Nov 12 11:21 web2pyapp\r\ndrwx------ 2 root root 4096 Nov 12 11:04 web2pyapp_keys\r\n\r\n# ls -l \/opt\/web2pyapp\r\ntotal 1268\r\n-rw-r--r-- 1 root root 214 Nov 12 09:46 ABOUT\r\n-rw-r--r-- 1 root root 12965 Nov 12 09:46 anyserver.py\r\ndrwxr-xr-x 5 root root 4096 Nov 12 10:37 applications\r\n-rw-r--r-- 1 root root 747 Nov 12 09:46 appveyor.yml\r\n-rw-r--r-- 1 root root 65085 Nov 12 09:46 CHANGELOG\r\ndrwxr-xr-x 2 root root 4096 Nov 12 10:01 deposit\r\ndrwxr-xr-x 2 root root 4096 Nov 12 09:46 docs\r\ndrwxr-xr-x 2 root root 4096 Nov 12 09:46 examples\r\ndrwxr-xr-x 4 root root 4096 Nov 12 09:46 extras\r\n-rw-r--r-- 1 root root 6067 Nov 12 09:46 fabfile.py\r\ndrwxr-xr-x 5 root root 4096 Nov 12 10:37 gluon\r\ndrwxr-xr-x 2 root root 4096 Nov 12 09:46 handlers\r\n-rw-r--r-- 1 root root 18338 Nov 12 11:21 httpserver.log\r\n-rw-r--r-- 1 root root 5727 Nov 12 09:46 LICENSE\r\ndrwxr-xr-x 2 root root 4096 Nov 12 10:01 logs\r\n-rw-r--r-- 1 root root 5684 Nov 12 09:46 Makefile\r\n-rw-r--r-- 1 root root 24 Nov 12 09:46 MANIFEST.in\r\n-rw------- 1 root root 756 Nov 12 11:10 nohup.out\r\n-rw-r--r-- 1 root root 92 Nov 12 11:20 parameters_8000.py\r\n-rw-r--r-- 1 root root 3896 Nov 12 09:46 README.markdown\r\ndrwxr-xr-x 2 root root 4096 Nov 12 09:46 scripts\r\n-rw-r--r-- 1 root root 3320 Nov 12 09:46 setup.py\r\ndrwxr-xr-x 2 root root 4096 Nov 12 09:46 site-packages\r\n-rw-r--r-- 1 root root 337 Nov 12 09:46 tox.ini\r\n-rw-r--r-- 1 root root 52 Nov 12 09:46 VERSION\r\n-rwxr-xr-x 1 root root 900 Nov 12 09:46 web2py.py\r\n-rw-r--r-- 1 root root 1089202 Nov 12 10:01 welcome.w2p\r\n\r\n# ls -l \/opt\/web2pyapp_keys\r\ntotal 8\r\n-rw------- 1 root root 2057 Nov 12 09:52 web2pyapp.crt\r\n-rw------- 1 root root 3272 Nov 12 09:52 web2pyapp.key\r\n<\/pre>\n
# python \/opt\/web2pyapp\/web2py.py -a 'STRONG-PASSWORD-HERE' -k \/opt\/web2pyapp_keys\/web2pyapp.key -c \/opt\/web2pyapp_keys\/web2pyapp.crt -i 0.0.0.0 -p 8000\r\n\r\nweb2py Web Framework\r\nCreated by Massimo Di Pierro, Copyright 2007-2016\r\nVersion 2.14.6-stable+timestamp.2016.05.09.19.18.48\r\nDatabase drivers available: sqlite3, imaplib, pymysql, pg8000\r\n\r\nplease visit:\r\n https:\/\/127.0.0.1:8000\/\r\nuse \"kill -SIGTERM 1284\" to shutdown the web2py server\r\n<\/pre>\n
-a<\/code> flag.
\nOpen up a web browser and put https:\/\/VPS-IP-ADDRESS:8000\/<\/code> in the navbar, where VPS-IP-ADDRESS is your VPS IP Address.
\nAccept 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.<\/p>\nCTRL+C key<\/code> combination.<\/p>\n
Avoiding the open terminal to keep the Web2Py server alive<\/h2>\n
# python \/opt\/web2pyapp\/web2py.py -a 'Password01' -k \/opt\/web2pyapp_keys\/web2pyapp.key -c \/opt\/web2pyapp_keys\/web2pyapp.crt -i 0.0.0.0 -p 8000 &\r\n[1] 1468\r\n<\/pre>\n
# kill -9 1468\r\n<\/pre>\n
\n