Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use web2py + uWSGI + Nginx Web server built on Linux     - Taught you how to install Ubuntu Linux (Linux)

- Eclipse distributed management using GitHub project development (Linux)

- Ubuntu: HDF5 error: HDF5 header version does not match with the HDF5 library (Linux)

- Using Android Studio integrated development environment to build Android (Linux)

- Oracle table space create large files (Database)

- Getting Started with Linux: Learn how to upgrade Docker in Ubuntu (Server)

- MySQL Data Types (Database)

- MySQL Tutorial: Some optimized for I / O memory areas (Database)

- Python: Finding meet the conditions specified in the file directory (Programming)

- Linux iptables firewall settings to use (Linux)

- Ubuntu system process is bound CPU core (Linux)

- Oracle multi-user concurrency and transaction processing (Database)

- CentOS 6.5 / 6.6 modify the default SSH port number (Linux)

- Linux development management utility command (Linux)

- pureftpd basis: Install, configure, implement, anonymous logon (Linux)

- Security experience: to see how the experts deal with DDoS attacks (Linux)

- CentOS 7 source code to compile and install PHP5.6 Nginx1.7.9 and MySQL (LNMP build environment) (Server)

- Linux Getting Started Tutorial: How to set up a static MAC address on VMware ESXi virtual machine (Mobile)

- MySQL to recover the data through binlog (Database)

- Spring AOP custom annotation way to achieve log management (Programming)

 
         
  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:      
 
- Struts2 Result Types (Programming)
- Oracle 11g through SCN do incremental backup repair standby library detailed process (Database)
- Linux Getting Started tutorial: GNU C and Vim will fight the C / C ++ IDE semi-automatic (Linux)
- ACL permissions Linux command (Linux)
- JQuery implements the same content merge cells (Programming)
- Learning the Linux powerful network management capabilities (Linux)
- Getting Started with Linux system to learn: how to configure a static IP address for CentOS7 (Linux)
- Without Visual Studio .NET Windows application development (Programming)
- Linux System Getting Started Learning: Disable HTTP forwarding wget in (Linux)
- JavaScript Advanced Programming notes event capture and event bubbling (Programming)
- Terminal fun: 6 interesting Linux command-line tools (Linux)
- Android Studio and Git Git configuration file status (Linux)
- A detailed introduction to the Hadoop ecosystem (Server)
- Configuring Haproxy log support (syslog logging support) (Server)
- CentOS 7 install Hadoop-cdh-2.5 on Mesos (Server)
- Deploy OpenStack Juno on Ubuntu 14.04 (Linux)
- Memcached and Redis (Linux)
- MySQL DATE_FORMAT () function (Database)
- Php and MySQL command add to the environment variable method in Linux system (Linux)
- C ++ Supplements - malloc free and new delete the same and different (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.