centos 6.3 因为python 2.6的版本优势,勿须要 另装PYTHON版本。所以用来配置PYTHON再好不过。
1、 配置基本编译环境
yum -y install gcc gdbm-devel readline-devel ncurses-devel zlib-devel sqlite-devel db4-devel tk-devel bluez-libs-devel make bzip2-devel gcc-c++ openssl-devel
2、安装uwsgi
wget /upload/2021/11/6597907594517029671.jpg >
3、安装 virtualenv
下载地址:
http://pypi.python.org/pypi/virtualenv#downloads
wget -S 'http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.8.4.tar.gz#md5=1c7e56a7f895b2e71558f96e365ee7a7'
tar zx virtualenv-1.8.4.tar.gz
cd virtualenv-1.8.1
python setup.py build
python setup.py install
virtualenv /home/virtualenv
cd /home/virtualenv && source bin/activate
#安装web.py
pip install web.py
安装mysql
yum install mysql-devel
pip install MySql-python
安装pil
yum install libjpeg* libpng*
pip install PIL
安装memcached
yum install memcached
pip install python-memcached
安装mako
附uwsgi启动脚本
#!/bin/bash
uwsgi - Use uwsgi to run python and wsgi web apps.
chkconfig: - 85 15
description: Use uwsgi to run python and wsgi web apps.
processname: uwsgi
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/uwsgi
OWNER=uwsgi
NAME=uwsgi
DESC=uwsgi
test -x $DAEMON || exit 0
Include uwsgi defaults if available
if [ -f /etc/default/uwsgi ] ; then
. /etc/default/uwsgi
fi
set -e
get_pid() {
if [ -f /var/run/$daemon_name.pid ]; then
if [ -f /var/run/$NAME.pid ]; then
echo `cat /var/run/$NAME.pid`
fi
}
get_pid1() {
if [ -f /var/run/$daemon_name.pid ]; then
echo cat /var/run/$daemon_name.pid
fi
}
#DAEMON_OPTS=-s 127.0.0.1:9001 -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pidfile /var/run/$NAME.pid --pythonpath $PYTHONPATH --module $MODULE
DAEMON_OPTS=-s 127.0.0.1:9002 -L -C -M -p 6 -t 50 --limit-as 1000 -R 10240 --vhost -d /var/log/uwsgi.log --pidfile /var/run/$NAME.pid —pythonpath /home --enable-threads
ulimit -SHn 65535
case $1 in
start)
echo -n Starting $DESC:
PID=$(get_pid)
if [ -z $PID ]; then
[ -f /var/run/$NAME.pid ] && rm -f /var/run/$NAME.pid
touch /var/run/$NAME.pid
chown $OWNER /var/run/$NAME.pid
su - $OWNER -pc $DAEMON $DAEMON_OPTS
echo $NAME.
fi
;;
stop)
echo -n Stopping $DESC:
PID=$(get_pid)
[ ! -z $PID ] && kill -s 3 $PID &> /dev/null
if [ $? -gt 0 ]; then
echo was not running
exit 1
else
echo $NAME.
rm -f /var/run/$NAME.pid &> /dev/null
fi
;;
reload)
echo Reloading $NAME
PID=$(get_pid)
[ ! -z $PID ] && kill -s 1 $PID &> /dev/null
if [ $? -gt 0 ]; then
echo was not running
exit 1
else
echo $NAME.
rm -f /var/run/$NAME.pid &> /dev/null
fi
;;
force-reload)
echo Reloading $NAME
PID=$(get_pid)
[ ! -z $PID ] && kill -s 15 $PID &> /dev/null
if [ $? -gt 0 ]; then
echo was not running
exit 1
else
echo $NAME.
rm -f /var/run/$NAME.pid &> /dev/null
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
status)
killall -10 $DAEMON
;;
*)
N=/etc/init.d/$NAME
echo Usage: $N {start|stop|restart|reload|force-reload|status} >&2
exit 1
;;
esac
exit 0