Установка python 27, pip, virtualenvwrapper, supervisor, mysql в CentOS 6

Установка python 27 на CentOS

Ставим зависимости

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

Скачиваем и устанавливаем нужную версию питона

wget http://python.org/ftp/python/2.7.x/Python-2.7.x.tgz
tar xf Python-2.7.x.tar.bz2
cd Python-2.7.x
./configure --prefix=/usr/local --enable-shared
make 
make altinstall
echo '/usr/local/lib' > /etc/ld.so.conf.d/python2.7.conf
ldconfig

После инсталляции новая версия Python доступна по /usr/local/bin/python2.7

Системная версия продолжает быть доступной по /usr/bin/python или /usr/bin/python2.6.

Установка pip на CentOS

curl https://bootstrap.pypa.io/get-pip.py | python2.7 -

Установка virtualenvwrapper на CentOS

pip install virtualenvwrapper

Добавить следующее в .bashrc

export WORKON_HOME=/root/envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
source /usr/local/bin/virtualenvwrapper.sh

Активируем наши изменения

source .bashrc
virtualenvwrapper.user_scripts creating /root/envs/premkproject
virtualenvwrapper.user_scripts creating /root/envs/postmkproject
virtualenvwrapper.user_scripts creating /root/envs/initialize
virtualenvwrapper.user_scripts creating /root/envs/premkvirtualenv
virtualenvwrapper.user_scripts creating /root/envs/postmkvirtualenv
virtualenvwrapper.user_scripts creating /root/envs/prermvirtualenv
virtualenvwrapper.user_scripts creating /root/envs/postrmvirtualenv
virtualenvwrapper.user_scripts creating /root/envs/predeactivate
virtualenvwrapper.user_scripts creating /root/envs/postdeactivate
virtualenvwrapper.user_scripts creating /root/envs/preactivate
virtualenvwrapper.user_scripts creating /root/envs/postactivate
virtualenvwrapper.user_scripts creating /root/envs/get_env_details

И можно пользоваться

workon
mkvirtualenv

Установка supervisor в CentOS

pip install supervisor

Создаем дефолтный конфиг для supervisor

echo_supervisord_conf > /etc/supervisord.conf

Создаем папку для хранения конфигов запуска приложении

mkdir /etc/supervisor/

И прописываем его в конфиг /etc/supervisord.conf

...
[include]
files = /etc/supervisord.d/*.conf
...

Создаем файл для управления демоном /etc/rc.d/init.d/supervisord, со следующим содержанием

#!/bin/sh       
#
# /etc/rc.d/init.d/supervisord
#
# Supervisor is a client/server system that
# allows its users to monitor and control a
# number of processes on UNIX-like operating
# systems.
#
# chkconfig: - 64 36
# description: Supervisor Server
# processname: supervisord

# Source init functions
. /etc/rc.d/init.d/functions

prog="supervisord"

prefix="/usr/local/"
exec_prefix="${prefix}"
prog_bin="${exec_prefix}/bin/supervisord"
PIDFILE="/var/run/$prog.pid"

start()
{
    echo -n $"Starting $prog: "
    daemon $prog_bin --pidfile $PIDFILE
    [ -f $PIDFILE ] && success $"$prog startup" || failure $"$prog startup"
    echo
}

stop()
{
    echo -n $"Shutting down $prog: "
    [ -f $PIDFILE ] && killproc $prog || success $"$prog shutdown"
    echo
}

case "$1" in

    start)
        start
    ;;

    stop)
        stop
    ;;

    status)
        status $prog
    ;;

    restart)
        stop
        start
    ;;

    *)
        echo "Usage: $0 {start|stop|restart|status}"
    ;;

esac

Даем права

chmod +x /etc/rc.d/init.d/supervisord

Прописываем в автозапуск

chkconfig --add supervisord
chkconfig supervisord on

Стартуем

service supervisord start
Starting supervisord: /usr/local/lib/python2.7/site-packages/supervisor/options.py:296: 
UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations 
(including its current working directory); 
you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '                                                           [  OK  ]

Установка mysql в CentOS

yum -y install mysql mysql-server

Прописываем в автозапуск

chkconfig mysqld on

Стартуем

service mysqld start

Устанавливаем root пароль MySQL

mysqladmin -u root password 'new-password'

Пароль также можно сменить через

mysqladmin -u root -p password 'new-password'

Установка других вспомогательных утилит

yum -y install epel-release
yum install htop vim mc wget git libxml2 libxml2-devel libxslt libxslt-devel python-devel mysql-devel -y