Skip to content

Instantly share code, notes, and snippets.

@amiroff
Last active December 31, 2015 10:59
Show Gist options
  • Save amiroff/7976592 to your computer and use it in GitHub Desktop.
Save amiroff/7976592 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
export DEBIAN_FRONTEND=noninteractive
#echo "--> Configuring locales <--"
#locale-gen en_US.UTF-8
#apt-get install language-pack-en-base
echo "--> Updating package db <--"
apt-get update
# Install MySQL without prompt
#debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
#debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
echo "--> Installing base apps <--"
apt-get install -y vim tmux curl htop wget python-software-properties git-core
echo "--> Adding up-to-date PHP repositories <--"
# Add repo for latest PHP
sudo add-apt-repository -y ppa:ondrej/php5
echo "--> Updating package db <--"
apt-get update
echo "--> Installing LAMP <--"
apt-get install -y php5 apache2 libapache2-mod-php5 php5-mysql php5-intl php5-memcache php5-curl php5-gd php5-json php5-curl php5-mcrypt php5-xdebug mysql-server
echo "--> Configuring Server <--"
# xdebug Config
cat << EOF | sudo tee -a /etc/php5/mods-available/xdebug.ini
xdebug.scream=0
xdebug.max_nesting_level=250
xdebug.cli_color=1
xdebug.show_local_vars=1
EOF
echo "--> Setting up Apache virtual host <--"
#rm -rf /var/www
#ln -fs /vagrant /var/www
echo "ServerName localhost" > /etc/apache2/httpd.conf
echo "ServerName localhost" >> /etc/apache2/apache2.conf
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant/public"
ServerName project.dev
<Directory "/vagrant/public">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-available/000-default.conf
echo "--> Enabling mod-rewrite <--"
# Apache Config
a2enmod rewrite
#curl https://gist.github.com/fideloper/2710970/raw/vhost.sh > vhost
#chmod guo+x vhost
#mv vhost /usr/local/bin
# PHP Config
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php5/cli/php.ini
sed -i "s/;date.timezone =.*/date.timezone = Europe\\/Istanbul/g" /etc/php5/cli/php.ini
sed -i "s/;date.timezone =.*/date.timezone = Europe\\/Istanbul/g" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/apache2/php.ini
sed -i "s/display_errors = .*/display_errors = On/" /etc/php5/cli/php.ini
#sed -i "s/short_open_tag = Off/short_open_tag = On/g" /etc/php5/cli/php.ini
#sed -i "s/short_open_tag = Off/short_open_tag = On/g" /etc/php5/apache2/php.ini
sed -i 's/disable_functions =/;disable_functions =/' /etc/php5/cli/php.ini
sudo service apache2 restart
echo "--> Installing Composer <--"
curl -s https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
echo "--> Setting up Mysql <--"
sed -i 's/^bind-address.*127.0.0.1/#&/' /etc/mysql/my.cnf
echo "CREATE USER 'user'@'%' IDENTIFIED BY 'user'" | mysql
echo "GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION" | mysql
service mysql restart
echo "--> Done! Now, get to work! Mysql credidentials: user:user <--"
#echo "Set virtual host to Laravel Project web root"
#echo "using provided 'vhost' tool:"
#echo "sudo vhost -s mysite.local -d /vagrant/project-name/public"
#echo "sudo service apache2 reload"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment