Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use web2py + uWSGI + Nginx Web server built on Linux     - Ubuntu Linux Change the PATH (Linux)

- Setting Squid successful anti-hotlinking (Linux)

- Ubuntu 15.04 installed Nvidia Quadro series graphics driver (Linux)

- Linux command ls (Linux)

- CentOS 5.3 under broadcom NIC dual activation issues (Linux)

- Linux systems for entry-learning - Install Go language in Linux (Linux)

- Save the database data files into Oracle Learning (Database)

- CentOS set up FTP server (Server)

- Linux see whether there is a hacker program (Linux)

- Security Configuration SQL Server 2000 database tutorial (Linux)

- Udev: Device Manager for Linux Fundamentals (Linux)

- GRUB2 boot Ubuntu Manual (Linux)

- CentOS7 install JDK (Linux)

- Swift rewrite initialize method of navigation controller class (Programming)

- Learning how to teach safety system to prevent your own IP leakage (Linux)

- Linux Command Tutorial: cat command to view the contents of the file (Linux)

- Use mod_wsgi Django application deployment (Server)

- Elasticsearch Kibana installation notes (Linux)

- GNU Linux system variables (sysctl configuration commands) integrated use (Linux)

- About Linux backdoor (Linux)

 
         
  Use web2py + uWSGI + Nginx Web server built on Linux
     
  Add Date : 2018-11-21      
         
         
         
 

This article describes the use of Linux Python + Nginx + web2py + uWSGI process to build a web server.

Python 2.7.11

extracting installation package


tar -zxvf Python-2.7.11.tgz
cd Python-2.7.11
yum install sqlite-devel
./configure --enable-loadable-sqlite-extensions

 

prompts error


Python build finished, but the necessary bits to build these modules were not found:
_ssl _tkinter bsddb185
bz2 dl imageop
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules () for the module's name.

 

need to install the dependencies


yum install openssl-devel


according to package dependent operation, concrete can refer to this document

 

to continue the installation


make
make install
rm / usr / bin / python
ln -s /usr/local/bin/python2.7 / usr / bin / python

 

python
Python 2.7.11 (default, Feb 2 2016, 14:33:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7 -16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

 

install Nginx tar -zxvf nginx-1.8.0.tar.gz tar -xzvf zlib-1.2.8.tar.gz tar -zxvf pcre-8.37.tar.gz groupadd nginx useradd nginx ./configure --prefix = / usr / local / nginx --user = nginx --group = nginx --with-pcre = / opt / web / pcre-8.37 --with-zlib = / opt / web / zlib-1.2.8 --with-http_addition_module --with-http_realip_module make make install cd / usr / local / nginx ./nginx

Install uWSGI tar -zxvf uwsgi-latest.tar.gz cd uwsgi-2.0.12 python uwsgiconfig.py --build cp uwsgi / usr / sbin

Configuration uWSGI

Create Profile /etc/uwsgi/web2py.ini , and enter the following in the configuration file.


[Uwsgi]
socket = 127.0.0.1:9090
pythonpath = / var / www / html / web2py /
mount = / = wsgihandler: application
processes = 4
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 1
stats = /tmp/%n.stats.socket
max-requests = 5000
limit-as = 1024
reload-on-as = 256
reload-on-rss = 192
cron = 0 0 -1 -1 -1 python /var/www/html/web2py/web2py.py -Q -S welcome -M -R scripts / sessions2trash.py -A -o
no-orphans = true
chmod-socket = 666

 

Create uWSGI switch command.


'#! / Bin / sh
'# Autor: Nilton OS - www.linuxpro.com.br
'#
'#
'### BEGIN INIT INFO
'# Provides: uwsgi
'# Required-Start: $ syslog $ remote_fs
'# Should-Start: $ time ypbind smtp
'# Required-Stop: $ syslog $ remote_fs
'# Should-Stop: ypbind smtp
'# Default-Start: 3 5
'# Default-Stop: 0 1 2 6
'### END INIT INFO

 

'# Source function library.
. /etc/rc.d/init.d/functions

'# Check for missing binaries (stale symlinks should not happen)
UWSGI_BIN = which uwsgi
test -x (UWSGI_BIN || {echo ") UWSGI_BIN not installed ";
if [" $ 1 "=" stop "]; then exit 0;
else exit 5; fi;}

UWSGI_EMPEROR_MODE = true
UWSGI_VASSALS = "/ etc / uwsgi /"
UWSGI_OPTIONS = "- enable-threads --logto /var/log/uwsgi/uwsgi.log"
lockfile = / var / lock / subsys / uwsgi

UWSGI_OPTIONS = "$ UWSGI_OPTIONS --autoload"

if [ "$ UWSGI_EMPEROR_MODE" = "true"]; then
UWSGI_OPTIONS = "$ UWSGI_OPTIONS --emperor $ UWSGI_VASSALS"
fi

case "$ 1" in
start)
echo -n "Starting uWSGI"
daemon $ UWSGI_BIN $ UWSGI_OPTIONS &
;;
stop)
echo -n "Shutting down uWSGI"
killproc $ UWSGI_BIN
;;
restart)
$ 0 stop
$ 0 start
;;
status)
echo -n "Checking for service uWSGI"
status $ UWSGI_BIN
;;
*)
echo " Usage: $ 0 {start | stop | status | restart} "
exit 1
;;
esac
exit 0

 

According to the above command switch, you also need to add a uWSGI log file.


mkdir -p / var / log / uwsgi
touch /var/log/uwsgi/uwsgi.log

 

web2py installation

just need to install a so-called package web2py can unzip to the specified directory, you can download the binary package from the official website.

mkdir / var / www / html unzip web2py_src.zip mv web2py / handlers / wsgihandler.py web2py / wsgihandler.py chown -R nginx: nginx web2py cd web2py sudo -u nginx python -c "from gluon.main import save_password; save_password ( 'password', 443)"

Configuration NginX

adding a server module, monitor port 80 will be accessed using uWSGI transferred to web2py.


server {
listen 80;
server_name YOUR_SERVER_FQDN;
'#to enable correct use of response.static_version
location ~* /(w+)/static(?:/_[d]+.[d]+.[d]+)?/(.*)$ {
alias /var/www/html/web2py/applications/$1/static/$2;
expires max;
}
location / {
uwsgi_pass 127.0.0.1:9090;
uwsgi_pass unix:///var/www/html/web2py/logs/web2py.socket;
include /etc/nginx/uwsgi_params;
}

}

}

 

start Nginx and uWSGI

Note: web2py itself does not need to start with only passive call can be uWSGI.

/ Usr / local / nginx / sbin / nginx /etc/init.d/uwsgi start After

more execution in the browser to access the server's IP address, if you need the following pages illustrate successful deployment.

     
         
         
         
  More:      
 
- Oracle Incident Packaging Service (Database)
- MongoDB 2.6 deployment replica set + partitions (Database)
- ORA-600 [kcbz_check_objd_typ] Error Handling (Database)
- Java, hashcode, equals and == (Programming)
- How to upgrade to Ubuntu 14.04 Linux Kernel 4.4.1 LTS (Linux)
- Nonstandard IMP-00010 error processing one case (Database)
- Some common Linux commands Study Notes (Linux)
- Ubuntu install video playback software SMPlayer 14.9.0.7042 (Linux)
- Java uses JDBC connect database (Programming)
- Ora-1092: OPI colleague K aborting process --- killed by OO Well killer (Database)
- Java interface (Programming)
- Ubuntu derivative version of the user and how to install SmartGit / HG 6.0.0 (Linux)
- Shell Programming Regular Expressions (Programming)
- Security Features Linux and Unix operating system, programming (Linux)
- Linux User Rights Study Notes (Linux)
- How to install Zephyr Test Management Tools on CentOS 7.x (Server)
- Android to determine whether the device to open WIFI, GPRS data connection (Programming)
- Ubuntu use three methods to install Ruby (Linux)
- Let CentOS perform PPPoE dial-up, ADSL can be used in a network environment! (Linux)
- Oracle in the add & split partition on the impact of global & local index (Database)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.