├── .gitignore ├── README.md ├── Vagrantfile └── bootstrap.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | package.box 3 | httpdocs 4 | magento-sample-data*.tar.gz 5 | 6 | # Numerous always-ignore extensions 7 | *.diff 8 | *.err 9 | *.orig 10 | *.log 11 | *.rej 12 | *.swo 13 | *.swp 14 | *.vi 15 | *~ 16 | *.sass-cache 17 | 18 | # OS or Editor folders 19 | .DS_Store 20 | Thumbs.db 21 | .cache 22 | .project 23 | .settings 24 | .tmproj 25 | *.esproj 26 | nbproject 27 | 28 | # Dreamweaver added files 29 | _notes 30 | dwsync.xml 31 | 32 | # Komodo 33 | *.komodoproject 34 | .komodotools 35 | 36 | # Folders to ignore 37 | .hg 38 | .svn 39 | .CVS 40 | .idea 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | simple-magento-vagrant 2 | ====================== 3 | 4 | A VERY simple Magento environment provisioner for [Vagrant](http://www.vagrantup.com/). 5 | 6 | ![Magento & Vagrant](https://cookieflow.files.wordpress.com/2013/07/magento_vagrant.jpg?w=525&h=225) 7 | 8 | * Creates a running Magento development environment with a few simple commands. 9 | * Runs on Ubuntu (Trusty 14.04 64 Bit) \w PHP 5.5, MySQL 5.5, Apache 2.2 10 | * Uses [Magento CE 1.9.1.0](http://www.magentocommerce.com/download) 11 | * Automatically runs Magento's installer and creates CMS admin account. 12 | * Optionally installs Magento Sample Store Inventory 13 | * Automatically runs [n98-magerun](https://github.com/netz98/n98-magerun) installer. 14 | * Perfect for rapid development or extension testing with an unopionionated, bare-bones and easily tweaked configuration. 15 | * Goes from naught-to-Magento in a couple of minutes. 16 | 17 | ## Getting Started 18 | 19 | **Prerequisites** 20 | 21 | * Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 22 | * Install [Vagrant](http://www.vagrantup.com/) 23 | * Clone or [download](https://github.com/r-baker/simple-magento-vagrant/archive/master.zip) this repository to the root of your project directory `git clone https://github.com/r-baker/simple-magento-vagrant.git` 24 | * In your project directory, run `vagrant up` 25 | 26 | The first time you run this, Vagrant will download the bare Ubuntu box image. This can take a little while as the image is a few-hundred Mb. This is only performed once. 27 | 28 | Vagrant will configure the base system before downloading Magento and running the installer. 29 | 30 | ## Usage 31 | 32 | * In your browser, head to `127.0.0.1:8080` 33 | * Magento CMS is accessed at `127.0.0.1:8080/admin` 34 | * User: `admin` Password: `password123123` 35 | * Access the virtual machine directly using `vagrant ssh` 36 | * When you're done `vagrant halt` 37 | 38 | [Full Vagrant command documentation](http://docs.vagrantup.com/v2/cli/index.html) 39 | 40 | ## Sample Data 41 | 42 | Sample data is automatically downloaded and installed by default. However, it's a reasonably large file and can take a while to download. 43 | 44 | > "I don't want sample data" 45 | 46 | Sample data installation can be disabled: 47 | 48 | * Open `Vagrantfile` 49 | * Change `sample_data = "true"` to `sample_data = "false"` 50 | * Run `vagrant up` as normal 51 | 52 | > "I have already downloaded the sample data" 53 | 54 | * Place the sample data `tar.gz` file in the project root 55 | * Ensure `sample_data = "true"` 56 | * The provisioning script will skip the download and use the provided file instead. The same goes for when the provisioner is rerun. e.g. `vagrant reload --provision` 57 | 58 | ## Todo 59 | * Install Modman. 60 | 61 | **Why no Puppet/Chef?** 62 | Admittedly, Puppet and Chef are excellent solutions for predictable and documented system configurations. The emphasis for this provisioner is on unopinionated simplicity. There are some excellent Puppet / Chef Magento configurations on Github with far more bells and whistles. 63 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # To install store sample data 5 | sample_data = "true" 6 | 7 | Vagrant.configure("2") do |config| 8 | # All Vagrant configuration is done here. The most common configuration 9 | # options are documented and commented below. For a complete reference, 10 | # please see the online documentation at vagrantup.com. 11 | 12 | # Every Vagrant virtual environment requires a box to build off of. 13 | config.vm.box = "ubuntu/trusty64" 14 | 15 | config.vm.provision :shell, :path => "bootstrap.sh", :args => [sample_data] 16 | 17 | # Create a forwarded port mapping which allows access to a specific port 18 | # within the machine from a port on the host machine. In the example below, 19 | # accessing "localhost:8080" will access port 80 on the guest machine. 20 | config.vm.network :forwarded_port, guest: 80, host: 8080 21 | config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"] 22 | 23 | config.ssh.forward_agent = true 24 | 25 | config.vm.provider :virtualbox do |vb| 26 | vb.customize ["modifyvm", :id, "--memory", "1024"] 27 | vb.name = "simple-magento-vagrant" 28 | end 29 | 30 | end 31 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SAMPLE_DATA=$1 4 | MAGE_VERSION="1.9.1.0" 5 | DATA_VERSION="1.9.0.0" 6 | 7 | # Update Apt 8 | # -------------------- 9 | apt-get update 10 | 11 | # Install Apache & PHP 12 | # -------------------- 13 | apt-get install -y apache2 14 | apt-get install -y php5 15 | apt-get install -y libapache2-mod-php5 16 | apt-get install -y php5-mysqlnd php5-curl php5-xdebug php5-gd php5-intl php-pear php5-imap php5-mcrypt php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php-soap 17 | 18 | php5enmod mcrypt 19 | 20 | # Delete default apache web dir and symlink mounted vagrant dir from host machine 21 | # -------------------- 22 | rm -rf /var/www/html 23 | mkdir /vagrant/httpdocs 24 | ln -fs /vagrant/httpdocs /var/www/html 25 | 26 | # Replace contents of default Apache vhost 27 | # -------------------- 28 | VHOST=$(cat < 32 | DocumentRoot "/var/www/html" 33 | ServerName localhost 34 | 35 | AllowOverride All 36 | 37 | 38 | 39 | DocumentRoot "/var/www/html" 40 | ServerName localhost 41 | 42 | AllowOverride All 43 | 44 | 45 | EOF 46 | ) 47 | 48 | echo "$VHOST" > /etc/apache2/sites-enabled/000-default.conf 49 | 50 | a2enmod rewrite 51 | service apache2 restart 52 | 53 | # Mysql 54 | # -------------------- 55 | # Ignore the post install questions 56 | export DEBIAN_FRONTEND=noninteractive 57 | # Install MySQL quietly 58 | apt-get -q -y install mysql-server-5.5 59 | 60 | mysql -u root -e "CREATE DATABASE IF NOT EXISTS magentodb" 61 | mysql -u root -e "GRANT ALL PRIVILEGES ON magentodb.* TO 'magentouser'@'localhost' IDENTIFIED BY 'password'" 62 | mysql -u root -e "FLUSH PRIVILEGES" 63 | 64 | 65 | # Magento 66 | # -------------------- 67 | # http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/installing_magento_via_shell_ssh 68 | 69 | # Download and extract 70 | if [[ ! -f "/vagrant/httpdocs/index.php" ]]; then 71 | cd /vagrant/httpdocs 72 | wget http://www.magentocommerce.com/downloads/assets/${MAGE_VERSION}/magento-${MAGE_VERSION}.tar.gz 73 | tar -zxvf magento-${MAGE_VERSION}.tar.gz 74 | mv magento/* magento/.htaccess . 75 | chmod -R o+w media var 76 | chmod o+w app/etc 77 | # Clean up downloaded file and extracted dir 78 | rm -rf magento* 79 | fi 80 | 81 | 82 | # Sample Data 83 | if [[ $SAMPLE_DATA == "true" ]]; then 84 | cd /vagrant 85 | 86 | if [[ ! -f "/vagrant/magento-sample-data-${DATA_VERSION}.tar.gz" ]]; then 87 | # Only download sample data if we need to 88 | wget http://www.magentocommerce.com/downloads/assets/${DATA_VERSION}/magento-sample-data-${DATA_VERSION}.tar.gz 89 | fi 90 | 91 | tar -zxvf magento-sample-data-${DATA_VERSION}.tar.gz 92 | cp -R magento-sample-data-${DATA_VERSION}/media/* httpdocs/media/ 93 | cp -R magento-sample-data-${DATA_VERSION}/skin/* httpdocs/skin/ 94 | mysql -u root magentodb < magento-sample-data-${DATA_VERSION}/magento_sample_data_for_${DATA_VERSION}.sql 95 | rm -rf magento-sample-data-${DATA_VERSION} 96 | fi 97 | 98 | 99 | # Run installer 100 | if [ ! -f "/vagrant/httpdocs/app/etc/local.xml" ]; then 101 | cd /vagrant/httpdocs 102 | sudo /usr/bin/php -f install.php -- --license_agreement_accepted yes \ 103 | --locale en_US --timezone "America/Los_Angeles" --default_currency USD \ 104 | --db_host localhost --db_name magentodb --db_user magentouser --db_pass password \ 105 | --url "http://127.0.0.1:8080/" --use_rewrites yes \ 106 | --use_secure no --secure_base_url "http://127.0.0.1:8080/" --use_secure_admin no \ 107 | --skip_url_validation yes \ 108 | --admin_lastname Owner --admin_firstname Store --admin_email "admin@example.com" \ 109 | --admin_username admin --admin_password password123123 110 | /usr/bin/php -f shell/indexer.php reindexall 111 | fi 112 | 113 | # Install n98-magerun 114 | # -------------------- 115 | cd /vagrant/httpdocs 116 | wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar 117 | chmod +x ./n98-magerun.phar 118 | sudo mv ./n98-magerun.phar /usr/local/bin/ 119 | --------------------------------------------------------------------------------