Skip to content

Instantly share code, notes, and snippets.

@jacksonfdam
Created September 23, 2016 14:45
Show Gist options
  • Save jacksonfdam/3e884bfa57ed983a9292e55440a662dd to your computer and use it in GitHub Desktop.
Save jacksonfdam/3e884bfa57ed983a9292e55440a662dd to your computer and use it in GitHub Desktop.
Ubuntu 14/15 for PHP5 development (LAMP, Composer, Git, phpMyAdmin)
#!/bin/bash
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
set -euo pipefail
IFS=$'\n\t'
# Script will auto terminate on errors
# run like - bash script_name.sh
# Prevent source
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && echo -e "\e[91m This script is being sourced, will exit now \e[39m" && return
# Composer requires php v5.3.2 pre-installed
# Old way
# curl -sS https://getcomposer.org/installer | php
# Download composer (new)
echo -e "\e[96m Downloading composer.phar \e[39m"
EXPECTED_SIGNATURE=$(wget https://composer.github.io/installer.sig -O - -q)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" = "$ACTUAL_SIGNATURE" ]
then
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
#exit $RESULT
else
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
# Make composer global
sudo mv composer.phar /usr/local/bin/composer
# Check composer version
composer --version
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Script will auto terminate on errors
# run like - bash script_name.sh
# Prevent source
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && echo -e "\e[91m This script is being sourced, will exit now \e[39m" && return
# Install latest git
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get -y install git
# My Git Configs
git config --global --add merge.ff false
git config --global push.followTags true
git config --global core.autocrlf false
git config --global push.default simple
git config --global color.ui auto
git config --global branch.autosetuprebase always
git config --global core.compression 9
git config --global credential.helper 'cache --timeout 28800'
git config --global core.filemode false
git config --global alias.st status
# Clean up
sudo apt-get clean
# Check for git version
git --version
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 14.04/15.10 Dev Server
# Warning: Don't run this on Ubuntu 16.04
# Script will auto terminate on errors
# run like - bash script_name.sh
# Prevent source
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && echo -e "\e[91m This script is being sourced, will exit now \e[39m" && return
# Update indexes (optional)
sudo apt-get update
# Install apache
sudo apt-get -y install apache2
# Install php with apache module
sudo apt-get -y install php5 libapache2-mod-php5 php5-xdebug
# Install mysql ext
sudo apt-get -y install php5-mysql
# Install mycrypt ext
sudo apt-get -y install mcrypt php5-mcrypt
sudo php5enmod mcrypt
# Install curl ext
sudo apt-get -y install curl php5-curl
sudo php5enmod curl
# Enable some apache modules
sudo a2enmod rewrite
#sudo a2enmod headers
# Restart apache server to reflect changes
sudo service apache2 restart
echo -e "\e[96m Install mysql server \e[39m"
echo -e "\e[93m User: root, Password: root \e[39m"
# Install MySQL Server in a Non-Interactive mode. Default root password will be "root"
echo "mysql-server-5.6 mysql-server/root_password password root" | sudo debconf-set-selections
echo "mysql-server-5.6 mysql-server/root_password_again password root" | sudo debconf-set-selections
sudo apt-get -y install mysql-server-5.6
### Run next command on production server
#sudo mysql_secure_installation
# Check php version
php -v
# Check apache version
apachectl -v
# Check mysql version
mysql --version
# Check if php is working or not
php -r 'echo "\nIt means your PHP installation is working fine.\n";'
echo "Open http://localhost/ to check if apache is working or not"
# Clean up
sudo apt-get clean
# Reboot
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 14.04, apache2.4, php 5.5+
# You should have MySQL pre-installed
# Script will auto terminate on errors
# run like - bash script_name.sh
# Prevent source
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && echo -e "\e[91m This script is being sourced, will exit now \e[39m" && return
echo -e "\e[96m Begin silent install phpMyAdmin \e[39m"
echo -e "\e[93m User: root, Password: root \e[39m"
# Set non-interactive mode, u can comment next lines if u want manual install
sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/dbconfig-install boolean true'
sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/app-password-confirm password root'
sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/admin-pass password root'
sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/app-pass password root'
sudo debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2'
# Start
sudo apt-get -y install phpmyadmin
# Restart apache server
sudo service apache2 restart
# Clean up
sudo apt-get clean
echo -e "\e[92m phpMyAdmin installed successfully \e[39m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment