├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── Vagrantfile └── bootstrap.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | magento-sample-data-* 4 | httpdocs 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/magento-hackathon/BlackfireMagentoVagrant/e25df1ae935eace68ef5a19f8590ced5c5d0a4a4/.gitmodules -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, Joshua Warren, Creatuity Corp. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Blackfire + Magento Vagrant 2 | ====================== 3 | 4 | Based on https://github.com/r-baker/simple-magento-vagrant, but with the Blackfire profiler added and configured for you. 5 | 6 | Includes https://github.com/magento-hackathon/Blackfireio 7 | 8 | See the 'Prerequisites' section for important steps to launch Blackfire 9 | 10 | A VERY simple Magento environment provisioner for [Vagrant](http://www.vagrantup.com/), with the Blackfire profiler included. 11 | 12 | ![Magento & Vagrant](https://cookieflow.files.wordpress.com/2013/07/magento_vagrant.jpg?w=525&h=225) 13 | 14 | * Creates a running Magento development environment with a few simple commands. 15 | * Runs on Ubuntu (Trusty 14.04 64 Bit) \w PHP 5.5, MySQL 5.5, Apache 2.2 16 | * Uses [Magento CE 1.9.1.0](http://www.magentocommerce.com/download) 17 | * Automatically runs Magento's installer and creates CMS admin account. 18 | * Optionally installs Magento Sample Store Inventory 19 | * Automatically runs [n98-magerun](https://github.com/netz98/n98-magerun) installer. 20 | * Perfect for rapid development or extension testing with an unopionionated, bare-bones and easily tweaked configuration. 21 | * Goes from naught-to-Magento in a couple of minutes. 22 | 23 | ## Getting Started 24 | 25 | **Prerequisites** 26 | 27 | * Install [VirtualBox](https://www.virtualbox.org/wiki/Downloads) 28 | * Install [Vagrant](http://www.vagrantup.com/) 29 | * Clone or [download](https://github.com/joshuaswarren/BlackfireMagentoVagrant/archive/master.zip) this repository to the root of your project directory `git clone https://github.com/joshuaswarren/BlackfireMagentoVagrant.git` 30 | * Setup a free [Blackfire account](https://blackfire.io/) 31 | * Obtain your Server Id, Server Token, Client Id and Client Token from your [Blackfire Account](https://blackfire.io/account/credentials) 32 | * Edit bootstrap.sh and replace the placeholder text near the bottom of the file with your Blackfire Credentials. 33 | * Install the Blackfire Companion in Google Chrome from the [Chrome Web Store](https://chrome.google.com/webstore/detail/blackfire-companion/miefikpgahefdbcgoiicnmpbeeomffld?hl=en) 34 | * In your project directory, run `vagrant up` 35 | 36 | 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. 37 | 38 | Vagrant will configure the base system before downloading Magento and running the installer. 39 | 40 | ## Usage 41 | 42 | * In your browser, head to `127.0.0.1:8080` 43 | * In the Chrome toolbar, click the Blackfire icon, choose an empty profile slot and click 'Profile' to profile the current page. 44 | * To enable the Blackfire Hackathon extension to provide more refined results, login to the admin panel and set Advanced -> Developer -> Debug -> Profiler to 'Yes' on the global scope. 45 | * Magento admin panel is accessed at `127.0.0.1:8080/admin` 46 | * User: `admin` Password: `password123123` 47 | * Access the virtual machine directly using `vagrant ssh` 48 | * When you're done `vagrant halt` 49 | 50 | [Full Vagrant command documentation](http://docs.vagrantup.com/v2/cli/index.html) 51 | 52 | ## Sample Data 53 | 54 | Sample data is automatically downloaded and installed by default. However, it's a reasonably large file and can take a while to download. 55 | 56 | > "I don't want sample data" 57 | 58 | Sample data installation can be disabled: 59 | 60 | * Open `Vagrantfile` 61 | * Change `sample_data = "true"` to `sample_data = "false"` 62 | * Run `vagrant up` as normal 63 | 64 | > "I have already downloaded the sample data" 65 | 66 | * Place the sample data `tar.gz` file in the project root 67 | * Ensure `sample_data = "true"` 68 | * 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` 69 | 70 | ## Todo 71 | * Install Modman. 72 | 73 | **Why no Puppet/Chef?** 74 | 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. 75 | -------------------------------------------------------------------------------- /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 = "blackfire-magento" 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 | ln -s /usr/local/bin/n98-magerun.phar /usr/local/bin/magerun 120 | chmod a+x /usr/local/bin/magerun 121 | 122 | wget -O - https://packagecloud.io/gpg.key | apt-key add - 123 | echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list 124 | apt-get update -y 125 | apt-get install -y blackfire-agent 126 | apt-get install -y blackfire-php 127 | 128 | echo 'server-id=INSERT-SERVER-ID-HERE' >> /etc/blackfire/agent 129 | echo 'server-token=INSERT-SERVER-TOKEN-HERE' >> /etc/blackfire/agent 130 | 131 | echo 'client-id=INSERT-CLIENT-ID-HERE' >> /root/.blackfire.ini 132 | echo 'client-token=INSERT-CLIENT-TOKEN-HERE' >> /root/.blackfire.ini 133 | 134 | bash < <(wget -q --no-check-certificate -O - https://raw.github.com/colinmollenhour/modman/master/modman-installer) 135 | mv /root/bin/modman /usr/local/bin/modman 136 | 137 | echo 'xdebug.remote_autostart=0' >> /etc/php5/apache2/php.ini 138 | echo 'xdebug.remote_enable=0' >> /etc/php5/apache2/php.ini 139 | echo 'xdebug.profiler_enable=0' >> /etc/php5/apache2/php.ini 140 | 141 | /etc/init.d/blackfire-agent restart 142 | /etc/init.d/apache2 restart 143 | 144 | apt-get -y install git 145 | 146 | cd /var/www/html/ 147 | modman init 148 | modman clone https://github.com/magento-hackathon/Blackfireio 149 | magerun dev:profiler 1 150 | magerun dev:symlinks 1 151 | magerun cache:flush 152 | magerun sys:setup:run --------------------------------------------------------------------------------