Created
December 3, 2012 02:08
-
-
Save benphelps/4192158 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "#####" | |
echo "Core System Setup" | |
echo "#####" | |
echo "" | |
read -p "Set MySQL Root Password: " mysqlrootpass | |
# | |
# add dotdeb.org repo for php5.4 | |
# | |
echo -n "Adding dotdeb.org repo ... " | |
echo "deb http://packages.dotdeb.org squeeze all" >> /etc/apt/sources.list.d/dotdeb.list | |
echo "deb-src http://packages.dotdeb.org squeeze all" >> /etc/apt/sources.list.d/dotdeb.list | |
echo "deb http://packages.dotdeb.org squeeze-php54 all" >> /etc/apt/sources.list.d/dotdeb.list | |
echo "deb-src http://packages.dotdeb.org squeeze-php54 all" >> /etc/apt/sources.list.d/dotdeb.list | |
wget http://www.dotdeb.org/dotdeb.gpg > /dev/null 2>&1 | |
cat dotdeb.gpg | apt-key add - > /dev/null 2>&1 | |
rm dotdeb.gpg | |
apt-get -qq update > /dev/null 2>&1 | |
echo "Done" | |
# | |
# get root password for mysql | |
# | |
echo "mysql-server-5.1 mysql-server/root_password password $mysqlrootpass" | debconf-set-selections | |
echo "mysql-server-5.1 mysql-server/root_password_again password $mysqlrootpass" | debconf-set-selections | |
# | |
# install packages | |
# | |
echo -n "Installing Core Packages ... " | |
apt-get install -y -qq htop autoconf curl git-core build-essential postgresql libpq-dev mysql-server libmysqlclient-dev php5-cgi php5-cli php5-fpm php5-common php5-gd php5-mysql php5-pgsql lighttpd lighttpd-mod-mysql-vhost libgd2-noxpm-dev > /dev/null 2>&1 | |
echo "Done" | |
# | |
# Install vnstat | |
# | |
echo -n "Installing vnstat ... " | |
wget http://humdi.net/vnstat/vnstat-1.11.tar.gz > /dev/null 2>&1 | |
tar zxf vnstat-1.11.tar.gz > /dev/null 2>&1 | |
cd vnstat-1.11 | |
make all install > /dev/null 2>&1 | |
cp examples/init.d/debian/vnstat /etc/init.d/vnstat | |
chmod a+rx /etc/init.d/vnstat | |
update-rc.d vnstat defaults > /dev/null 2>&1 | |
service vnstat start > /dev/null 2>&1 | |
echo "Done" | |
# | |
# Install rbenv and ruby with rails | |
# | |
echo -n "Installing rbenv ... " | |
cd /usr/local | |
git clone git://github.com/sstephenson/rbenv.git rbenv > /dev/null 2>&1 | |
mkdir /usr/local/rbenv/plugins | |
cd /usr/local/rbenv/plugins | |
git clone git://github.com/sstephenson/ruby-build.git > /dev/null 2>&1 | |
cd ~ | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> .profile | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> .profile | |
echo 'eval "$(rbenv init -)"' >> .profile | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> .bashrc | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> .bashrc | |
echo 'eval "$(rbenv init -)"' >> .bashrc | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> .bash_profile | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> .bash_profile | |
echo 'eval "$(rbenv init -)"' >> .bash_profile | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/skel/.profile | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/skel/.profile | |
echo 'eval "$(rbenv init -)"' >> /etc/skel/.profile | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/skel/.bashrc | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/skel/.bashrc | |
echo 'eval "$(rbenv init -)"' >> /etc/skel/.bashrc | |
echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/skel/.bash_profile | |
echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/skel/.bash_profile | |
echo 'eval "$(rbenv init -)"' >> /etc/skel/.bash_profile | |
echo "Done" | |
echo -n "Installing ruby ... " | |
# exec a login shell so we can get the rbenv sourced in | |
bash --login -c 'export CFLAGS="-O3 -pipe -fomit-frame-pointer";curl https://raw.github.com/gist/1688857/rbenv.sh | sh ; rbenv global 1.9.3-p327-perf' > /dev/null 2>&1 | |
echo "Done" | |
echo -n "Installing rails ... " | |
bash --login -c 'gem install rails --no-rdoc --no-ri' > /dev/null 2>&1 | |
echo "Done" | |
# | |
# Install Lighttpd config files | |
# | |
echo -n "Configuring Lighttpd ... " | |
cd ~ | |
git clone git://gist.github.com/4183197.git lighttpd-setup > /dev/null 2>&1 | |
cd ~/lighttpd-setup | |
rm /etc/lighttpd/lighttpd.conf | |
cp lighttpd.conf /etc/lighttpd/lighttpd.conf | |
cp mysql-vhost.conf /etc/lighttpd/conf-available/10-mysql-vhost.conf | |
cp suphp.conf /etc/lighttpd/conf-available/15-suphp.conf | |
cp fastcgi-php.conf /etc/lighttpd/conf-available/10-fastcgi-phpfpm.conf | |
lighttpd-enable-mod fastcgi-phpfpm > /dev/null 2>&1 | |
echo "Done" | |
# Setup Lighttpd with MySQL | |
echo -n "Configuring mod_mysql_vhost ... " | |
randpass=`date +%s | sha256sum | head -c 10` | |
echo " | |
mysql-vhost.pass = \"$randpass\"" >> /etc/lighttpd/conf-available/10-mysql-vhost.conf | |
mysql -uroot -p$mysqlrootpass -e "CREATE USER 'lighttpd'@'localhost' IDENTIFIED BY '$randpass';" | |
mysql -uroot -p$mysqlrootpass -e "GRANT SELECT ON lighttpd.* TO 'lighttpd'@'localhost';" | |
mysql -uroot -p$mysqlrootpass -e "FLUSH PRIVILEGES;" | |
mysql -uroot -p$mysqlrootpass -e "CREATE DATABASE lighttpd; | |
USE lighttpd; | |
CREATE TABLE hosts ( | |
hostname varchar(64) not null primary key, | |
docroot varchar(256) not null | |
);" | |
lighttpd-enable-mod mysql-vhost > /dev/null 2>&1 | |
echo "Done" | |
# | |
# configure php | |
# | |
echo -n "Configuring PHP ... " | |
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/' /etc/php5/cgi/php.ini | |
sed -i 's/post_max_size = 8M/post_max_size = 1G/' /etc/php5/cgi/php.ini | |
sed -i 's/;date.timezone =/date.timezone = "America\/Chicago"/' /etc/php5/cgi/php.ini | |
sed -i 's/allow_url_fopen = On/allow_url_fopen = Off/' /etc/php5/cgi/php.ini | |
sed -i 's/display_errors = Off/display_errors = On/' /etc/php5/cgi/php.ini | |
sed -i 's/;session.save_path = "\/var\/lib\/php5"/session.save_path = "\/var\/lib\/php5"/' /etc/php5/cgi/php.ini | |
echo "Done" | |
# | |
# configure php-fpm | |
# | |
echo -n "Configuring PHP-FPM ... " | |
sed -i 's/;listen.owner = www-data/listen.owner = www-data/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/;listen.group = www-data/listen.group = www-data/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/;listen.mode = 0666/listen.mode = 0600/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/pm.max_children = 5/pm.max_children = 12/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/pm.start_servers = 2/pm.start_servers = 4/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/pm.min_spare_servers = 1/pm.min_spare_servers = 2/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/pm.max_spare_servers = 3/pm.max_spare_servers = 4/' /etc/php5/fpm/pool.d/www.conf | |
sed -i 's/;pm.max_requests = 500/pm.max_requests = 500/' /etc/php5/fpm/pool.d/www.conf | |
/etc/init.d/php5-fpm restart > /dev/null 2>&1 | |
service lighttpd restart > /dev/null 2>&1 | |
echo "Done" | |
# | |
# Clean up | |
# | |
echo -n "Cleaning up ... " | |
cd ~ | |
myself = `basename $0` | |
rm vnstat-1.11.tar.gz | |
rm -rf vnstat-1.11 | |
rm -rf lighttpd-setup | |
rm myself | |
echo "Done" | |
echo "" | |
echo "#####" | |
echo "Core System Setup Complete!" | |
echo "#####" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment