Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Use web2py + uWSGI + Nginx Web server built on Linux     - CentOS7 installed VMware 10 (Linux)

- To build a private Docker registry (Server)

- Java abstract class instantiation (Programming)

- The principle Httpclient4.4 (execution request) (Programming)

- Fatal: unable to connect to github.com problem solving (Linux)

- Linux file and directory management - ls, cp, mv (Linux)

- Oracle Linux 5.9 configuration Xmanager (Linux)

- Ubuntu Backup and Recovery (Linux)

- RedHat install GCC problem --- Depends (Linux)

- Java source implementation of the observer pattern instance (Programming)

- Linux operating system set up to effectively prevent ARP attacks (Linux)

- How to Install Xombrero 1.6.4 (minimalist Web browser) on Ubuntu and Archlinux (Linux)

- HAProxy Windows version of the compiler and its application in the CORS (Server)

- Two programs HAProxy + Heartbeat (note, the secondary server vip, normal HAProxy boot method) (Server)

- Build ASP.NET 5 development environment in Ubuntu (Server)

- Redis-- persistence articles (Database)

- CentOS boot image to achieve semi-automatic installation (Linux)

- The oh-my-zsh into true my zsh (Linux)

- Tomcat configuration memory and remote debug port (Server)

- pkg-config to use (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:      
 
- Three easy open source firewall on the Linux platform (Linux)
- You must ask yourself four questions before deploying Docker (Server)
- Linux compression and decompression command (Linux)
- Linux system security configuration (Linux)
- Fatal: unable to connect to github.com problem solving (Linux)
- Ubuntu study notes and related problem solving (Linux)
- GitLab Guide installation under Ubuntu 14.04 (Server)
- Oracle Duplicate build DataGuard (Database)
- SUSE Linux firewall configuration notes (Linux)
- How to configure HTTP Strict Transport Security (HSTS) (Linux)
- The lambda expression Java8 (constructor references) (Programming)
- Fedora 23 How to install LAMP server (Server)
- Linux FAQ - How to fix tar:Exitingwith failure status due to previous errors (Linux)
- Linux operating system security management skills notes (Linux)
- Java reflection mechanism explained in detail and Method.invoke explanation (Programming)
- Deployment Kubernetes manage Docker example cluster on Ubuntu (Server)
- Linux command binlog by filtering out the complete SQL statement (Database)
- SSH mutual trust configuration (Server)
- Reason C ++ program running under Linux a segmentation fault core dumped in (Programming)
- Varnish achieve page jump (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.