fixed Issue 1538:Update Script setup-web2py-nginx-uwsgi-centos64.sh, thanks jniltinho
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.5.1-stable+timestamp.2013.06.16.07.20.03
|
Version 2.5.1-stable+timestamp.2013.06.16.16.58.29
|
||||||
|
|||||||
@@ -2,54 +2,54 @@
|
|||||||
# Autor: Nilton OS -- www.linuxpro.com.br
|
# Autor: Nilton OS -- www.linuxpro.com.br
|
||||||
echo 'setup-web2py-nginx-uwsgi-centos64.sh'
|
echo 'setup-web2py-nginx-uwsgi-centos64.sh'
|
||||||
echo 'Support CentOS 6.4'
|
echo 'Support CentOS 6.4'
|
||||||
echo 'Installs Nginx 1.4 + uWSGI + Web2py'
|
echo 'Installs Nginx 1.4.1 + uWSGI + Web2py'
|
||||||
|
|
||||||
|
|
||||||
# Get Web2py Admin Password
|
# Get Web2py Admin Password
|
||||||
echo -e "Web2py Admin Password: \c "
|
echo -e "Web2py Admin Password: \c "
|
||||||
read PW
|
read PW
|
||||||
|
|
||||||
echo -e "Set Server Name Ex: web2py.domain.com : \c "
|
echo -e "Set Server Name Ex: web2py.domain.com : \c "
|
||||||
read SERVER_FQDN
|
read SERVER_FQDN
|
||||||
|
|
||||||
echo -e "Set Server IP: \c "
|
echo -e "Set Server IP: \c "
|
||||||
read SERVER_IP
|
read SERVER_IP
|
||||||
|
|
||||||
|
|
||||||
echo "" >>/etc/hosts
|
echo "" >>/etc/hosts
|
||||||
echo "$SERVER_IP $SERVER_FQDN" >>/etc/hosts
|
echo "$SERVER_IP $SERVER_FQDN" >>/etc/hosts
|
||||||
|
|
||||||
yum update -y
|
yum update -y
|
||||||
|
|
||||||
yum install -y http://mirror-fpt-telecom.fpt.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
|
yum install -y http://mirror-fpt-telecom.fpt.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
|
||||||
yum clean all
|
yum clean all
|
||||||
yum install -y gcc libxml2-devel python-devel python-pip PyXML unzip make sudo
|
yum install -y gcc libxml2-devel python-devel python-pip PyXML unzip make sudo
|
||||||
|
|
||||||
## 64Bits System
|
## 64Bits System
|
||||||
## yum install -y http://nginx.org/packages/rhel/6/x86_64/RPMS/nginx-1.4.0-1.el6.ngx.x86_64.rpm
|
## yum install -y http://nginx.org/packages/rhel/6/x86_64/RPMS/nginx-1.4.1-1.el6.ngx.x86_64.rpm
|
||||||
yum install -y http://nginx.org/packages/rhel/6/i386/RPMS/nginx-1.4.0-1.el6.ngx.i386.rpm
|
yum install -y http://nginx.org/packages/rhel/6/i386/RPMS/nginx-1.4.1-1.el6.ngx.i386.rpm
|
||||||
|
|
||||||
|
|
||||||
pip-python install --upgrade pip
|
pip-python install --upgrade pip
|
||||||
PIPPATH=`which pip`
|
PIPPATH=`which pip`
|
||||||
$PIPPATH install --upgrade uwsgi
|
$PIPPATH install --upgrade uwsgi
|
||||||
|
|
||||||
|
|
||||||
# Prepare folders for uwsgi
|
# Prepare folders for uwsgi
|
||||||
mkdir /etc/uwsgi
|
mkdir /etc/uwsgi
|
||||||
mkdir /var/log/uwsgi
|
mkdir /var/log/uwsgi
|
||||||
mkdir -p /var/www/
|
mkdir -p /var/www/
|
||||||
|
|
||||||
#usermod -a -G apache nginx
|
#usermod -a -G apache nginx
|
||||||
mkdir -p /etc/nginx/ssl/
|
mkdir -p /etc/nginx/ssl/
|
||||||
|
|
||||||
|
|
||||||
cd /etc/nginx/ssl
|
cd /etc/nginx/ssl
|
||||||
openssl genrsa 1024 > web2py.key && chmod 400 web2py.key
|
openssl genrsa 1024 > web2py.key && chmod 400 web2py.key
|
||||||
openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt
|
openssl req -new -x509 -nodes -sha1 -days 1780 -key web2py.key > web2py.crt
|
||||||
openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
|
openssl x509 -noout -fingerprint -text < web2py.crt > web2py.info
|
||||||
|
|
||||||
|
|
||||||
echo 'server {
|
echo 'server {
|
||||||
listen YOUR_SERVER_IP:80;
|
listen YOUR_SERVER_IP:80;
|
||||||
server_name YOUR_SERVER_FQDN;
|
server_name YOUR_SERVER_FQDN;
|
||||||
@@ -69,6 +69,10 @@ echo 'server {
|
|||||||
include /etc/nginx/uwsgi_params;
|
include /etc/nginx/uwsgi_params;
|
||||||
uwsgi_param UWSGI_SCHEME $scheme;
|
uwsgi_param UWSGI_SCHEME $scheme;
|
||||||
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
||||||
|
|
||||||
|
### remove the comments if you use uploads (max 10 MB)
|
||||||
|
#client_max_body_size 10m;
|
||||||
|
###
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
@@ -88,36 +92,42 @@ server {
|
|||||||
include /etc/nginx/uwsgi_params;
|
include /etc/nginx/uwsgi_params;
|
||||||
uwsgi_param UWSGI_SCHEME $scheme;
|
uwsgi_param UWSGI_SCHEME $scheme;
|
||||||
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
|
||||||
}
|
|
||||||
|
|
||||||
}' >/etc/nginx/conf.d/web2py.conf
|
|
||||||
|
|
||||||
|
### remove the comments if you use uploads (max 10 MB)
|
||||||
|
#client_max_body_size 10m;
|
||||||
|
###
|
||||||
|
}
|
||||||
|
|
||||||
|
}' >/etc/nginx/conf.d/web2py.conf
|
||||||
|
|
||||||
sed -i "s/YOUR_SERVER_IP/$SERVER_IP/" /etc/nginx/conf.d/web2py.conf
|
sed -i "s/YOUR_SERVER_IP/$SERVER_IP/" /etc/nginx/conf.d/web2py.conf
|
||||||
sed -i "s/YOUR_SERVER_FQDN/$SERVER_FQDN/" /etc/nginx/conf.d/web2py.conf
|
sed -i "s/YOUR_SERVER_FQDN/$SERVER_FQDN/" /etc/nginx/conf.d/web2py.conf
|
||||||
|
|
||||||
|
|
||||||
|
# Create configuration file /etc/uwsgi/web2py.ini
|
||||||
|
echo '[uwsgi]
|
||||||
|
|
||||||
|
socket = /var/www/web2py/logs/%n.socket
|
||||||
# Create configuration file /etc/uwsgi/web2py.xml
|
pythonpath = /var/www/web2py/
|
||||||
echo '<uwsgi>
|
mount = /=wsgihandler:application
|
||||||
<socket>/var/www/web2py/logs/web2py.socket</socket>
|
processes = 4
|
||||||
<pythonpath>/var/www/web2py/</pythonpath>
|
master = true
|
||||||
<mount>/=wsgihandler:application</mount>
|
harakiri = 60
|
||||||
<master/>
|
reload-mercy = 8
|
||||||
<processes>4</processes>
|
cpu-affinity = 1
|
||||||
<harakiri>60</harakiri>
|
stats = /tmp/%n.stats.socket
|
||||||
<reload-mercy>8</reload-mercy>
|
max-requests = 2000
|
||||||
<cpu-affinity>1</cpu-affinity>
|
limit-as = 512
|
||||||
<stats>/var/www/web2py/logs/stats.socket</stats>
|
reload-on-as = 256
|
||||||
<max-requests>2000</max-requests>
|
reload-on-rss = 192
|
||||||
<limit-as>512</limit-as>
|
uid = nginx
|
||||||
<reload-on-as>256</reload-on-as>
|
gid = nginx
|
||||||
<reload-on-rss>192</reload-on-rss>
|
cron = 0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
|
||||||
<uid>nginx</uid>
|
no-orphans = true
|
||||||
<gid>nginx</gid>
|
chmod-socket = 666
|
||||||
<cron>0 0 -1 -1 -1 python /var/www/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o</cron>
|
' >/etc/uwsgi/web2py.ini
|
||||||
<no-orphans/>
|
|
||||||
</uwsgi>' >/etc/uwsgi/web2py.xml
|
|
||||||
|
|
||||||
|
|
||||||
cd /var/www/
|
cd /var/www/
|
||||||
curl --progress -O http://web2py.com/examples/static/web2py_src.zip
|
curl --progress -O http://web2py.com/examples/static/web2py_src.zip
|
||||||
unzip web2py_src.zip && rm -rf web2py_src.zip
|
unzip web2py_src.zip && rm -rf web2py_src.zip
|
||||||
@@ -126,11 +136,11 @@ curl --output /var/www/web2py/scripts/sessions2trash.py http://web2py.googlecode
|
|||||||
chown -R nginx:nginx web2py
|
chown -R nginx:nginx web2py
|
||||||
cd /var/www/web2py
|
cd /var/www/web2py
|
||||||
sudo -u nginx python -c "from gluon.main import save_password; save_password('$PW',443)"
|
sudo -u nginx python -c "from gluon.main import save_password; save_password('$PW',443)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Daemons /start/stop
|
## Daemons /start/stop
|
||||||
|
|
||||||
echo '#!/bin/sh
|
echo '#!/bin/sh
|
||||||
# Autor: Nilton OS -- www.linuxpro.com.br
|
# Autor: Nilton OS -- www.linuxpro.com.br
|
||||||
#
|
#
|
||||||
@@ -144,27 +154,27 @@ echo '#!/bin/sh
|
|||||||
# Default-Start: 3 5
|
# Default-Start: 3 5
|
||||||
# Default-Stop: 0 1 2 6
|
# Default-Stop: 0 1 2 6
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
# Check for missing binaries (stale symlinks should not happen)
|
# Check for missing binaries (stale symlinks should not happen)
|
||||||
UWSGI_BIN=`which uwsgi`
|
UWSGI_BIN=`which uwsgi`
|
||||||
test -x $UWSGI_BIN || { echo "$UWSGI_BIN not installed";
|
test -x $UWSGI_BIN || { echo "$UWSGI_BIN not installed";
|
||||||
if [ "$1" = "stop" ]; then exit 0;
|
if [ "$1" = "stop" ]; then exit 0;
|
||||||
else exit 5; fi; }
|
else exit 5; fi; }
|
||||||
|
|
||||||
UWSGI_EMPEROR_MODE=true
|
UWSGI_EMPEROR_MODE=true
|
||||||
UWSGI_VASSALS="/etc/uwsgi/"
|
UWSGI_VASSALS="/etc/uwsgi/"
|
||||||
UWSGI_OPTIONS="--enable-threads --logto /var/log/uwsgi/uwsgi.log"
|
UWSGI_OPTIONS="--enable-threads --logto /var/log/uwsgi/uwsgi.log"
|
||||||
lockfile=/var/lock/subsys/uwsgi
|
lockfile=/var/lock/subsys/uwsgi
|
||||||
|
|
||||||
UWSGI_OPTIONS="$UWSGI_OPTIONS --autoload"
|
UWSGI_OPTIONS="$UWSGI_OPTIONS --autoload"
|
||||||
|
|
||||||
if [ "$UWSGI_EMPEROR_MODE" = "true" ] ; then
|
if [ "$UWSGI_EMPEROR_MODE" = "true" ] ; then
|
||||||
UWSGI_OPTIONS="$UWSGI_OPTIONS --emperor $UWSGI_VASSALS"
|
UWSGI_OPTIONS="$UWSGI_OPTIONS --emperor $UWSGI_VASSALS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting uWSGI "
|
echo -n "Starting uWSGI "
|
||||||
@@ -188,19 +198,19 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
exit 0 '> /etc/init.d/uwsgi
|
exit 0 '> /etc/init.d/uwsgi
|
||||||
|
|
||||||
chmod +x /etc/init.d/uwsgi
|
chmod +x /etc/init.d/uwsgi
|
||||||
|
|
||||||
/etc/init.d/uwsgi start
|
/etc/init.d/uwsgi start
|
||||||
/etc/init.d/nginx start
|
/etc/init.d/nginx start
|
||||||
|
|
||||||
/etc/init.d/iptables stop
|
/etc/init.d/iptables stop
|
||||||
chkconfig --del iptables
|
chkconfig --del iptables
|
||||||
|
|
||||||
chkconfig --levels 235 uwsgi on
|
chkconfig --levels 235 uwsgi on
|
||||||
chkconfig --levels 235 nginx on
|
chkconfig --levels 235 nginx on
|
||||||
|
|
||||||
## you can reload uwsgi with
|
## you can reload uwsgi with
|
||||||
#/etc/init.d/uwsgi restart
|
#/etc/init.d/uwsgi restart
|
||||||
## to reload web2py only (without restarting uwsgi)
|
## to reload web2py only (without restarting uwsgi)
|
||||||
# touch /etc/uwsgi/web2py.xml
|
# touch /etc/uwsgi/web2py.ini
|
||||||
Reference in New Issue
Block a user