Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use web2py + uWSGI + Nginx Web server built on Linux     - Depth understanding of C language (Programming)

- sa weak passwords intrusion prevention (Linux)

- C ++ complex class of operator overloading (Programming)

- Turning off the interface eth0: error: Disconnect the device 'eth0' (Linux)

- Source code to compile and install MySQL 5.7.9 (Database)

- ARM runtime environment built from scratch using QEMU emulator (Linux)

- Migrate Oracle database files to ASM (Database)

- Django1.8 return json json string and the string contents of the received post (Programming)

- Python Basics Tutorial - lambda keyword (Programming)

- Linux more efficient than select a model epoll (Linux)

- SSH automatic disconnection problem solving (Linux)

- Oracle 11g Export guide problem not an empty table (Database)

- Oracle 10g in the unique and index problems (Database)

- How to use the on-screen keyboard in Linux (Linux)

- Error: Unable to establish connection with FTP SFTP server (Server)

- Android Qemu GPS module (Programming)

- Java NIO in the world (Programming)

- Use regular expressions to check whether the input box to enter a URL (Programming)

- Fedora network set up simple (Linux)

- Linux beginners should know 12 commands (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:      
 
- Get and Post requests Comments (Linux)
- CentOS Nginx achieve 3 virtual machine load balancing (Server)
- When Linux virtual machine to another copy of the operating system, a static IP NAT mode Invalid (Linux)
- Hadoop vs spark (Server)
- Iptables use examples (Linux)
- CentOS 5.3 under broadcom NIC dual activation issues (Linux)
- Python2 ---- function using dictionaries (Programming)
- Hadoop2.6.3 build clusters and the development of MapReduce WIN7 by Eclipse on Linux demo (Server)
- cat command uses the Linux redirection merge files (Linux)
- Bad name two variables (Linux)
- Redmine Installation (Linux)
- Linux (CentOS) directory file management and file system file compression packing (Linux)
- CentOS install expect (Linux)
- Install the latest Eclipse IDE in Ubuntu (Linux)
- Elasticsearch 2.20 Beginners: aggregation (Server)
- To install HDRMerge 0.4.3 under ubuntu (Linux)
- Through Oracle to help restore MySQL data problems (Database)
- How to install Git on CentOS 7 (Linux)
- To control based on IP address routing policy under Linux (Linux)
- MySQL Parameter Tuning Best Practices (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.