Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use web2py + uWSGI + Nginx Web server built on Linux     - Install Apache streaming media services on CentOS 6.4 (Server)

- VirtualBox - Linux system virtual machine shared folders (Linux)

- CentOS 6.5 installation using a data recovery software extundelete (Linux)

- PXE install CentOS 6.4 (Linux)

- About Git (Linux)

- C ++ function object (Programming)

- Editor of the popular Linux Gvim (Linux)

- Installation Yarock 1.1.4 Music Player in Ubuntu (Linux)

- Linux hybrid character device (Linux)

- Teach you the Ubuntu Server enabled SSH multifactor authentication (Server)

- Web server security policy (Linux)

- RPM package management under Linux (Linux)

- Redis-2.8.17 installation and configuration process some errors (Linux)

- Depth understanding of JavaScript new mechanism (Programming)

- Java Adapter Mode (Programming)

- Linux Network Security: nmap port scanning software (Linux)

- Ubuntu install Lighttpd + Mono support .net (Linux)

- Elaborate 10-point difference between the new and malloc (Programming)

- Install Git on CentOS (Linux)

- Oracle PLS-00231 error analysis (Database)

 
         
  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:      
 
- Executable file format Explanation under Linux (Linux)
- Installation of JDK and Tomcat under Linux (CentOS) (Linux)
- Linux server Php injection prevention (Linux)
- Django1.8 return json json string and the string contents of the received post (Programming)
- SecureCRT 7.0 Log Ubuntu 12.04 server via SSH service under Vmware (Server)
- How to turn Java String into Date (Programming)
- Shell script to crawl through AWR SQL Report Problems (Database)
- Kickstart automated installation and deployment RHEL 7.0 (Linux)
- Based AutoYaST automated installation of SUSE practice (Linux)
- Wireless LAN security solutions (Linux)
- Java eight new features 8 (Programming)
- Windows environment Android Studio v1.0 Installation Guide (Linux)
- Automatic batch resolve dependencies problem locally installed rpm package (Linux)
- Thrift 0.9.3 compiler installation under Ubuntu (Linux)
- Linux security configuration (Linux)
- Processor in protected mode of protection (Linux)
- Novice Advanced Ubuntu7.10 configured IP address (Linux)
- OpenGL Superb Learning Notes - GLSL language foundation (Programming)
- DupeGuru- find and remove duplicate files (Linux)
- CentOS permanently banned from running in the background PackageKit (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.