Created
August 27, 2014 12:59
-
-
Save bastiankoetsier/484e693252b4981d17e2 to your computer and use it in GitHub Desktop.
Basic provisioning 4 vagrant
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
#!/usr/bin/env bash | |
# Install Some PPAs | |
apt-get install -y software-properties-common | |
apt-add-repository ppa:nginx/stable -y | |
apt-add-repository ppa:ondrej/php5 -y | |
# Update Package Lists | |
apt-get update | |
# Install Some Basic Packages | |
apt-get install -y build-essential curl dos2unix gcc git libmcrypt4 libpcre3-dev \ | |
make python2.7-dev python-pip re2c supervisor unattended-upgrades whois vim | |
# Set My Timezone | |
ln -sf /usr/share/zoneinfo/UTC /etc/localtime | |
# Install PHP Stuffs | |
apt-get install -y php5-cli php5-dev php-pear \ | |
php5-mysqlnd php5-pgsql php5-sqlite \ | |
php5-apcu php5-json php5-curl php5-gd \ | |
php5-gmp php5-imap php5-mcrypt php5-xdebug \ | |
php5-memcached php5-redis | |
# Make MCrypt Available | |
ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available | |
sudo php5enmod mcrypt | |
# Install Mailparse PECL Extension | |
pecl install mailparse | |
echo "extension=mailparse.so" > /etc/php5/mods-available/mailparse.ini | |
ln -s /etc/php5/mods-available/mailparse.ini /etc/php5/cli/conf.d/20-mailparse.ini | |
# Install Composer | |
curl -sS https://getcomposer.org/installer | php | |
mv composer.phar /usr/local/bin/composer | |
# Add Composer Global Bin To Path | |
printf "\nPATH=\"/home/vagrant/.composer/vendor/bin:\$PATH\"\n" | tee -a /home/vagrant/.profile | |
# Set Some PHP CLI Settings | |
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/cli/php.ini | |
sudo sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/cli/php.ini | |
sudo sed -i "s/memory_limit = .*/memory_limit = 1024M/" /etc/php5/cli/php.ini | |
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php5/cli/php.ini | |
# Install Nginx & PHP-FPM | |
apt-get install -y nginx php5-fpm | |
rm /etc/nginx/sites-enabled/default | |
rm /etc/nginx/sites-available/default | |
service nginx restart | |
# Setup Some PHP-FPM Options | |
ln -s /etc/php5/mods-available/mailparse.ini /etc/php5/fpm/conf.d/20-mailparse.ini | |
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/fpm/php.ini | |
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/fpm/php.ini | |
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini | |
sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php5/fpm/php.ini | |
sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php5/fpm/php.ini | |
# Set The Nginx & PHP-FPM User | |
sed -i "s/user www-data;/user vagrant;/" /etc/nginx/nginx.conf | |
sed -i "s/# server_names_hash_bucket_size.*/server_names_hash_bucket_size 64;/" /etc/nginx/nginx.conf | |
sed -i "s/user = www-data/user = vagrant/" /etc/php5/fpm/pool.d/www.conf | |
sed -i "s/group = www-data/group = vagrant/" /etc/php5/fpm/pool.d/www.conf | |
sed -i "s/;listen\.owner.*/listen.owner = vagrant/" /etc/php5/fpm/pool.d/www.conf | |
sed -i "s/;listen\.group.*/listen.group = vagrant/" /etc/php5/fpm/pool.d/www.conf | |
sed -i "s/;listen\.mode.*/listen.mode = 0666/" /etc/php5/fpm/pool.d/www.conf | |
service nginx restart | |
service php5-fpm restart | |
# Add nginx-host | |
block="server { | |
listen 80; | |
server_name social-stream-server.local; | |
root /vagrant/public; | |
index index.html index.htm index.php; | |
charset utf-8; | |
location / { | |
try_files \$uri \$uri/ /index.php?\$query_string; | |
} | |
location = /favicon.ico { access_log off; log_not_found off; } | |
location = /robots.txt { access_log off; log_not_found off; } | |
access_log off; | |
error_log /var/log/nginx/social-stream-error.log error; | |
error_page 404 /index.php; | |
sendfile off; | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_read_timeout 21600; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} | |
" | |
echo "$block" > "/etc/nginx/sites-available/social-stream-server.local" | |
ln -fs /etc/nginx/sites-available/social-stream-server.local /etc/nginx/sites-enabled/social-stream-server.local | |
service nginx restart | |
service php5-fpm restart | |
# Add Vagrant User To WWW-Data | |
usermod -a -G www-data vagrant | |
id vagrant | |
groups vagrant | |
# Install SQLite | |
apt-get install -y sqlite3 libsqlite3-dev | |
# Install MySQL | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password secret" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password secret" | |
apt-get install -y mysql-server | |
# Configure MySQL Remote Access | |
sed -i '/^bind-address/s/bind-address.*=.*/bind-address = 10.0.2.15/' /etc/mysql/my.cnf | |
mysql --user="root" --password="secret" -e "GRANT ALL ON *.* TO root@'10.0.2.2' IDENTIFIED BY 'secret' WITH GRANT OPTION;" | |
service mysql restart | |
mysql --user="root" --password="secret" -e "CREATE USER 'social-stream'@'10.0.2.2' IDENTIFIED BY 'secret';" | |
mysql --user="root" --password="secret" -e "GRANT ALL ON *.* TO 'social-stream'@'10.0.2.2' IDENTIFIED BY 'secret' WITH GRANT OPTION;" | |
mysql --user="root" --password="secret" -e "GRANT ALL ON *.* TO 'social-stream'@'%' IDENTIFIED BY 'secret' WITH GRANT OPTION;" | |
mysql --user="root" --password="secret" -e "FLUSH PRIVILEGES;" | |
mysql --user="root" --password="secret" -e "CREATE DATABASE social_stream;" | |
service mysql restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment