Skip to content

Instantly share code, notes, and snippets.

@brianteachman
Last active January 3, 2016 04:29
Show Gist options
  • Save brianteachman/8409470 to your computer and use it in GitHub Desktop.
Save brianteachman/8409470 to your computer and use it in GitHub Desktop.
Install script to setup base Magento installation on Ubuntu 12.04 lts running Nginx/PHP-FPM/MySQL. This script assumes if nginx is installed, it was done with this script so all dependencies are also installed or it attempts to install them.
#!/bin/sh
#
domain_name=$1
# check arguements
if $1==''; then
domain_name='test'
fi
# install server
if ! which nginx > /dev/null 2>&1; then
echo "Nginx not installed, trying to install..."
sudo apt-get install nginx
fi
if ! which mysql > /dev/null 2>&1; then
echo "MySQL not installed, trying to install..."
sudo apt-get install mysql-server mysql-workbench
fi
if ! which php5-fpm > /dev/null 2>&1; then
echo "PHP-FPM not installed, trying to install..."
sudo apt-get install php5-fpm php5-gd php5-mcrypt php5-mysql php5-curl php5-cli php-pear php-apc
fi
if ! which subversion > /dev/null 2>&1; then
echo "svn not installed, trying to install..."
sudo apt-get install subversion
fi
# setup vhost
if [ ! -f /etc/nginx/sites-available/${domain_name} ]; then
echo "Creating new vhost: ${domain_name}"
sudo cp /etc/nginx/sites-available/ecommerce /etc/nginx/sites-available/${domain_name}
sudo sed -i -e "s/ecommerce/${domain_name}/g" /etc/nginx/sites-available/${domain_name}
sudo ln -s /etc/nginx/sites-available/${domain_name} /etc/nginx/sites-enabled
# add domain_name to host file
echo "127.0.0.1 ${domain_name}.local" >> /etc/hosts
fi
#restart server
sudo service php5-fpm restart
sudo service nginx restart
# setup MySQL
echo "CREATE DATABASE ${domain_name};" >> /var/tmp/${domain_name}.sql
#echo "GRANT ALL PRIVILEGES ON ${domain_name}.* TO \\\`${domain_name}\\\`@\\\`localhost\\\` IDENTIFIED BY '${domain_name}';" >> /var/tmp/${domain_name}.sql
#echo "FLUSH PRIVILEGES; exit;" >> /var/tmp/${domain_name}.sql
cat /var/tmp/${domain_name}.sql
## mysql call below uses ~/.my.cnf defined as:
# [client]
# user = root
# password = password
mysql < /var/tmp/${domain_name}.sql
sudo rm /var/tmp/${domain_name}.sql
# download/setup magento src
cd /usr/share/nginx/www
svn checkout http://svn.magentocommerce.com/source/branches/1.7 ${domain_name}
sudo chown -R $USER ${domain_name}
cd ${domain_name}
sudo chown -R www-data app/etc var media
# install magento using install.php though cli
php -f install.php -- --license_agreement_accepted yes --locale en_US --timezone "America/Vancouver" --default_currency USD --db_host localhost --db_name ${domain_name} --db_user ${domain_name} --db_pass balsaas --url "http://${domain_name}.local" --use_rewrites yes --skip_url_validation yes --use_secure no --secure_base_url "http://${domain_name}.local" --use_secure_admin no --admin_firstname Brian --admin_lastname Teachman --admin_email brian@balsaas.com --admin_username $USER --admin_password "$USER@${domain_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment