Created
January 16, 2017 11:04
-
-
Save rajivseelam/649ae083633e381516744a8ae1d0b40f to your computer and use it in GitHub Desktop.
Provision New Server
This file contains 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
# Update Package List | |
apt-get update | |
# Update System Packages | |
apt-get -y upgrade | |
# Force Locale | |
echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale | |
locale-gen en_US.UTF-8 | |
# Install Some PPAs | |
apt-get install -y software-properties-common curl | |
apt-add-repository ppa:nginx/development -y | |
apt-add-repository ppa:chris-lea/redis-server -y | |
apt-add-repository ppa:ondrej/php -y | |
# gpg: key 5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported | |
# apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 5072E1F5 | |
# sh -c 'echo "deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7" >> /etc/apt/sources.list.d/mysql.list' | |
# wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | |
# sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" >> /etc/apt/sources.list.d/postgresql.list' | |
curl -s https://packagecloud.io/gpg.key | apt-key add - | |
echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list | |
curl --silent --location https://deb.nodesource.com/setup_6.x | bash - | |
# Update Package Lists | |
apt-get update | |
# Install Some Basic Packages | |
apt-get install -y build-essential dos2unix gcc git libmcrypt4 libpcre3-dev \ | |
make python2.7-dev python-pip re2c supervisor unattended-upgrades whois vim libnotify-bin | |
# Set My Timezone | |
ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime | |
# Install PHP Stuffs | |
apt-get install -y --force-yes php7.1-cli php7.1-dev \ | |
php7.1-pgsql php7.1-sqlite3 php7.1-gd \ | |
php7.1-curl php7.1-memcached \ | |
php7.1-imap php7.1-mysql php7.1-mbstring \ | |
php7.1-xml php7.1-zip php7.1-bcmath php7.1-soap \ | |
php7.1-intl php7.1-readline | |
# Install Composer | |
curl -sS https://getcomposer.org/installer | php | |
mv composer.phar /usr/local/bin/composer | |
# Install Laravel Envoy & Installer | |
sudo su vagrant <<'EOF' | |
/usr/local/bin/composer global require "laravel/envoy=~1.0" | |
/usr/local/bin/composer global require "laravel/installer=~1.1" | |
EOF | |
# Set Some PHP CLI Settings | |
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.1/cli/php.ini | |
sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/cli/php.ini | |
sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.1/cli/php.ini | |
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.1/cli/php.ini | |
# Install Nginx & PHP-FPM | |
apt-get install -y --force-yes nginx php7.1-fpm | |
rm /etc/nginx/sites-enabled/default | |
rm /etc/nginx/sites-available/default | |
service nginx restart | |
echo "opcache.revalidate_freq = 0" >> /etc/php/7.1/mods-available/opcache.ini | |
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.1/fpm/php.ini | |
sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.1/fpm/php.ini | |
service nginx restart | |
service php7.1-fpm restart | |
# Install Node | |
apt-get install -y nodejs | |
/usr/bin/npm install -g gulp | |
/usr/bin/npm install -g bower | |
/usr/bin/npm install -g yarn | |
/usr/bin/npm install -g grunt-cli | |
# Install MySQL | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/data-dir select ''" | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password secret" | |
debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password secret" | |
apt-get install -y mysql-server | |
# Configure MySQL Password Lifetime | |
echo "default_password_lifetime = 0" >> /etc/mysql/mysql.conf.d/mysqld.cnf | |
# Configure MySQL Remote Access | |
sed -i '/^bind-address/s/bind-address.*=.*/bind-address = 0.0.0.0/' /etc/mysql/mysql.conf.d/mysqld.cnf | |
mysql --user="root" --password="secret" -e "GRANT ALL ON *.* TO root@'0.0.0.0' IDENTIFIED BY 'secret' WITH GRANT OPTION;" | |
service mysql restart | |
# Add Timezone Support To MySQL | |
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql --user=root --password=secret mysql | |
# Install Blackfire | |
apt-get install -y blackfire-agent blackfire-php | |
# Install A Few Other Things | |
apt-get install -y redis-server memcached beanstalkd | |
# Configure Beanstalkd | |
sed -i "s/#START=yes/START=yes/" /etc/default/beanstalkd | |
/etc/init.d/beanstalkd start | |
# Configure Supervisor | |
systemctl enable supervisor.service | |
service supervisor start | |
# Clean Up | |
apt-get -y autoremove | |
apt-get -y clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment