ssh-copy-id root@server
#!/bin/sh
# vim -
# : , ssh
# habrahabr
wget -O ~/.vimrc http://dumpz.org/25712/nixtext/
# vim -
# , , crontab,
# nano
update-alternatives --set editor /usr/bin/vim.basic
# netselect-apt .
#
# debian
apt-get install netselect-apt -y
rm /tmp/sources.list
netselect-apt -o /tmp/sources.list -n stable
# /tmp/sources.list
#
# :
# debian-: ,
# (sid) , nginx-
# uwsgi
echo "deb http://security.debian.org/ squeeze/updates main contrib non-free" > /etc/apt/sources.list
LINE = $( cat /tmp/sources.list | grep '^deb' | head -1 )
echo $LINE /etc/apt/sources.list >> /etc/apt/sources.list
echo $LINE | sed 's/stable/testing/' >> /etc/apt/sources.list
echo $LINE | sed 's/stable/sid/' >> /etc/apt/sources.list
# -,
# , -,
cat > /etc/apt/apt.conf.d/07custom << EOF
APT::Install-Recommends "false";
APT::Default-Release "stable";
EOF
#
# sources.list
aptitude update
# : en_US -.
# ru_RU
aptitude install locales -y
echo en_US.UTF-8 > /etc/default/locale
cat > /etc/locale.gen << EOF
en_US.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8
EOF
locale-gen
#
# .. ,
aptitude upgrade -y
#
# psmisc pkill
# screen sudo
aptitude install psmisc screen sudo -y
# exim4,
# ,
# dpkg-reconfigure
aptitude install exim4 -y
#dpkg-reconfigure exim4-config
# nginx sid , uwsgi
# ngin
# -
aptitude install nginx -t sid -y
update-rc.d nginx defaults
/etc/init.d/nginx start
# web
# - django-
# RSA , ssh
# vim
useradd -m web -s /bin/bash
cp ~/.vimrc /home/web
mkdir /home/web/.ssh
cp ~/.ssh/authorized_keys /home/web/.ssh
chown -R web:web /home/web
# /web, -
mkdir /web /web/run /web/log
chown -R web:web /web
#
aptitude install mercurial subversion git-core -y
# mercurial
#
#
cat > /home/web/.hgrc << EOF
[ui]
username = Name Name
EOF
chown web:web /home/web/.hgrc
# python :)
# python-dev - python,
# python-, C
# python-setuptools easy_install
aptitude install python python-setuptools python-dev -y
# pip virtualenv
easy_install -U pip
easy_install -U virtualenv
# gcc python-
aptitude install gcc -y
# python- lxml
# ,
#
aptitude install python-lxml -y
# Fabric -
pip install -U fabric
# PIL
# ,
# , PIL JPEG :)
aptitude install libjpeg62-dev libfreetype6-dev -y
pip install -U PIL
# uwsgi
#
aptitude install libxml2-dev -y
pip install -U http://projects.unbit.it/downloads/uwsgi-latest.tar.gz
# postgres
# , - web
#
aptitude install postgresql python-psycopg2 -y
su postgres -c "cd /; createuser -s web"
# uwsgi-
#
# , ""
aptitude install supervisor -y
# ,
cat > /etc/supervisor/conf.d/inet.conf << EOF
[inet_http_server]]
port=666
#username=
#password=
EOF
# ,
# django- supervisor-
#
# uwsgi , uwsgi uwsgi.xml
#
cat > /etc/supervisor/conf.d/web.conf << EOF
#[program:PROJECT]
#directory=/web/PROJECT
#command=uwsgi -x uwsgi.xml
#user=web
EOF
# supervisor,
/etc/init.d/supervisor restop
# , web
# supervisorctl sudo
# -,
echo "web ALL = NOPASSWD: /usr/bin/supervisorctl" >> /etc/sudoers
# nginx
#
# VIM HOST PROJECT
cat > /etc/nginx/sites-enabled/template << EOF
server {
server_name .HOST.com;
error_log /web/log/HOST.com-error.log warn;
access_log /web/log/HOST.com-access.log;
location /static/admin-media {
alias /web/PROJECT/var/.env/lib/python2.6/site-packages/django/contrib/admin/media;
}
location /static/ {
root /web/PROJECT;
}
location /robots.txt {
root /web/PROJECT/static;
}
location /favicon.ico {
root /web/PROJECT/static;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/web/run/PROJECT.sock;
}
}
EOF
Source: https://habr.com/ru/post/120363/
All Articles