Magento 2 (Stable) Vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
listen [::]:80 default_server ipv6only=on; | |
set $MAGE_ROOT /var/www/; | |
set $MAGE_MODE developer; | |
root $MAGE_ROOT/pub; | |
index index.php; | |
autoindex off; | |
charset off; | |
location /setup { | |
root $MAGE_ROOT; | |
location ~ ^/setup/index.php { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
} | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location /pub { | |
alias $MAGE_ROOT/pub; | |
} | |
location /static/ { | |
if ($MAGE_MODE = "production") { | |
expires max; | |
} | |
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { | |
add_header Cache-Control "public"; | |
expires +1y; | |
if (!-f $request_filename) { | |
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; | |
} | |
} | |
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { | |
add_header Cache-Control "no-store"; | |
expires off; | |
if (!-f $request_filename) { | |
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; | |
} | |
} | |
if (!-f $request_filename) { | |
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; | |
} | |
} | |
location /media/ { | |
try_files $uri $uri/ /get.php?$args; | |
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { | |
add_header Cache-Control "public"; | |
expires +1y; | |
try_files $uri $uri/ /get.php?$args; | |
} | |
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { | |
add_header Cache-Control "no-store"; | |
expires off; | |
try_files $uri $uri/ /get.php?$args; | |
} | |
} | |
location /media/customer/ { | |
deny all; | |
} | |
location /media/downloadable/ { | |
deny all; | |
} | |
location ~ /media/theme_customization/.*\.xml$ { | |
deny all; | |
} | |
location /errors/ { | |
try_files $uri =404; | |
} | |
location ~ ^/errors/.*\.(xml|phtml)$ { | |
deny all; | |
} | |
location ~ cron\.php { | |
deny all; | |
} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
location ~ (index|get|static|report|404|503)\.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; | |
fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600"; | |
fastcgi_read_timeout 600s; | |
fastcgi_connect_timeout 600s; | |
fastcgi_param MAGE_MODE $MAGE_MODE; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "debian/jessie64" | |
config.vm.network "private_network", ip: "10.0.0.7" | |
config.vm.hostname = "magento2.local" | |
config.vm.provider "virtualbox" do |vb| | |
# Display the VirtualBox GUI when booting the machine | |
# vb.gui = true | |
# Customize the amount of memory on the VM: | |
vb.memory = "2048" | |
vb.cpus = 2 | |
end | |
config.vm.provision "shell", inline: <<-SHELL | |
# General | |
sudo apt-get update -qq | |
sudo apt-get install -qq wget nano | |
HOSTNAME=`hostname --fqdn` | |
# Dotdeb Repo's | |
wget https://www.dotdeb.org/dotdeb.gpg | |
sudo apt-key add dotdeb.gpg | |
sudo echo "deb http://packages.dotdeb.org jessie all" >> /etc/apt/sources.list | |
sudo apt-get update -qq | |
# NginX | |
sudo apt-get install -qq nginx-full | |
# Redis | |
sudo apt-get install -qq redis-server | |
# Memcached | |
sudo apt-get install -qq memcached | |
# MariaDB | |
MYSQLPW=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16` | |
sudo export DEBIAN_FRONTEND=noninteractive | |
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password password ${MYSQLPW}" | |
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password_again password ${MYSQLPW}" | |
sudo apt-get install -qq mariadb-server | |
sudo echo "MariaDB Root Password: ${MYSQLPW}" >> /etc/autosetup | |
# Git | |
sudo apt-get install -qq git | |
# Get PHP5 (latest) | |
sudo apt-get install -qq php5-cli php5-fpm php5-curl php5-common php5-gd php5-geoip php5-imagick php5-imap php5-intl php5-json php5-mcrypt | |
sudo apt-get install -qq php5-memcached php5-mssql php5-mysql php5-pgsql php5-readline php5-redis php5-sqlite php5-ssh2 php5-twig php5-xsl | |
# Get Composer | |
sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer | |
# Activate PHP5-FPM with phpinfo file | |
cd /etc/nginx/sites-available | |
sudo wget -O default http://lewiscowles.co.uk/recipies/jessie-nginx-php5-fpm-magento | |
sudo service nginx restart | |
cd /home/vagrant | |
# App specific config can go here! | |
sudo echo "<?php phpinfo();" > /var/www/html/info.php | |
# Magento2 BS | |
sudo adduser --home /var/www --no-create-home --ingroup www-data --disabled-password --gecos "" magento_user | |
sudo passwd -d -q magento_user | |
sudo chown -R magento_user:www-data /var/www | |
sudo chmod -R 775 /var/www | |
cd /var/www | |
sudo -u magento_user mkdir -p magento2 | |
cd magento2 | |
sudo -u magento_user git clone https://github.com/magento/magento2 . | |
sudo -u magento_user git checkout 2.0.0 | |
sudo -u magento_user composer config --global http-basic.repo.magento.com {magentodeveloperpublickey} {magentodeveloperprivatekey} | |
sudo -u magento_user composer config --global github-oauth.github.com {githuboauthtoken} | |
sudo -u magento_user composer install --no-progress --no-dev | |
sudo cp -R * ../ | |
sudo chown -R magento_user:www-data /var/www | |
sudo chmod -R 775 /var/www | |
sudo service nginx restart | |
MAGENTOPW=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16` | |
MAGENTODBPW=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c16` | |
mysql -u root -p$MYSQLPW -e "create database magento; GRANT ALL ON magento.* TO magento@127.0.0.1 IDENTIFIED BY '${MAGENTODBPW}'; FLUSH PRIVILEGES;" | |
sudo echo "Magento DB Password: ${MAGENTODBPW}" >> /etc/autosetup | |
sudo -u magento_user /var/www/bin/magento setup:install --admin-firstname "store" --admin-lastname "owner" --admin-email "some@email.com" --admin-user "admin" --admin-password "${MAGENTOPW}" --db-name "magento" --db-user "magento" --db-password "${MAGENTOPW}" --db-host "127.0.0.1" --base-url "http://${HOSTNAME}/" | |
sudo echo "Magento admin Password: ${MAGENTOPW}" >> /etc/autosetup | |
sudo cp /etc/autosetup /vagrant/autosetup | |
SHELL | |
end |
Can you make one that uses PHP7?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You actually only need the vagrantfile, but I wanted to store everything together.
This uses the vagrant hostsupdater plugin