Skip to content

Instantly share code, notes, and snippets.

@hoangsetup
Last active March 3, 2016 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoangsetup/5f6227f8d4abd87b8276 to your computer and use it in GitHub Desktop.
Save hoangsetup/5f6227f8d4abd87b8276 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Updating packages
apt-get update
# ---------------------------------------
# Apache Setup
# ---------------------------------------
# Installing Packages
apt-get install -y apache2 libapache2-mod-fastcgi apache2-mpm-worker
# Add ServerName to httpd.conf
echo "ServerName localhost" > /etc/apache2/httpd.conf
# Setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "~/www"
ServerName localhost
<Directory "~/www">
AllowOverride All
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default.conf
# Loading needed modules to make apache work
a2enmod actions fastcgi rewrite
service apache2 reload
# ---------------------------------------
# PHP Setup
# ---------------------------------------
# Installing packages
apt-get install -y php5 php5-cli php5-fpm curl php5-curl php5-mcrypt php5-xdebug
# Creating the configurations inside Apache
cat > /etc/apache2/conf-available/php5-fpm.conf << EOF
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
# NOTE: using '/usr/lib/cgi-bin/php5-cgi' here does not work,
# it doesn't exist in the filesystem!
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
EOF
# Enabling php modules
php5enmod mcrypt
# Triggering changes in apache
a2enconf php5-fpm
service apache2 reload
# ---------------------------------------
# MySQL Setup
# ---------------------------------------
# Setting MySQL root user password root/root
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
# Installing packages
apt-get install -y mysql-server mysql-client php5-mysql
# ---------------------------------------
# PHPMyAdmin setup
# ---------------------------------------
# Default PHPMyAdmin Settings
debconf-set-selections <<< 'phpmyadmin phpmyadmin/dbconfig-install boolean true'
debconf-set-selections <<< 'phpmyadmin phpmyadmin/app-password-confirm password root'
debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/admin-pass password root'
debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/app-pass password root'
debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2'
# Install PHPMyAdmin
apt-get install -y phpmyadmin
# Make Composer available globally
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/sites-enabled/phpmyadmin.conf
# Restarting apache to make changes
service apache2 restart
# ---------------------------------------
# Tools Setup
# ---------------------------------------
# Adding NodeJs PPA Repository
add-apt-repository -y ppa:chris-lea/node.js
apt-get update
# Installing nodejs and npm
apt-get install -y nodejs
ln -s /usr/bin/nodejs /usr/bin/node
# Installing Curl
apt-get install -y curl
# Installing OhmyZSH
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# Installing Bower and Grunt, Gulp, Pnpm
npm install -g bower grunt-cli gulp pnpm
# Installing GIT
apt-get install -y git
# Install Composer
curl -s https://getcomposer.org/installer | php
# Make Composer available globally
mv composer.phar /usr/local/bin/composer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment