From f13fd3e1f03d58beadaacfd8b0c0c98d7c9607fa Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 18:30:42 +0100 Subject: [PATCH 01/16] Added new composer modules, new nginx server blocks and domains --- provision/Magestead.yaml | 4 +- provision/magento-bootstrap.sh | 28 +++++- provision/magestead.rb | 10 ++- provision/server.sh | 122 ++++++++++++++++++++++++++ provision/stubs/magento-composer.json | 4 +- provision/stubs/services.xml | 7 ++ 6 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 provision/server.sh create mode 100644 provision/stubs/services.xml diff --git a/provision/Magestead.yaml b/provision/Magestead.yaml index e8307d0..abd0b40 100644 --- a/provision/Magestead.yaml +++ b/provision/Magestead.yaml @@ -8,10 +8,12 @@ authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa +domain: magento.dev + databases: - magestead -# bootstrap: magento +bootstrap: magento # bootstrap: laravel # bootstrap: symfony diff --git a/provision/magento-bootstrap.sh b/provision/magento-bootstrap.sh index aa71e6f..a10cb73 100644 --- a/provision/magento-bootstrap.sh +++ b/provision/magento-bootstrap.sh @@ -1,13 +1,37 @@ #!/usr/bin/env bash +DB=$1; +domain=$2; echo "--- Bootstrapping Magento ---" cp -R /vagrant/provision/stubs/magento-composer.json /vagrant/composer.json cd /vagrant; /usr/local/bin/composer install; +cp -R /vagrant/provision/stubs/services.xml /vagrant/public/app/etc/services.xml; + +echo "--- Installing Magento ---" cd /vagrant/public; -/usr/local/bin/modgit init; -/usr/local/bin/modgit add Cm_Cache_Backend_Redis git://github.com/colinmollenhour/Cm_Cache_Backend_Redis.git; \ No newline at end of file +php-cli -f install.php -- \ +--license_agreement_accepted "yes" \ +--locale "en_GB" \ +--timezone "Europe/London" \ +--default_currency "GBP" \ +--db_host "localhost" \ +--db_name "$DB" \ +--db_user "root" \ +--db_pass "root" \ +--url "$domain" \ +--use_rewrites "yes" \ +--secure_base_url "$domain" \ +--admin_firstname "RichDynamix" \ +--admin_lastname "Magestead" \ +--admin_email "admin@admin.com" \ +--admin_username "admin" \ +--admin_password "password123" + +echo "Magento admin username = admin"; +echo "Magento admin password = password123"; +echo "Magento installed at http://$domain/. Remember and set your hosts file."; diff --git a/provision/magestead.rb b/provision/magestead.rb index f543cbc..43acec8 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -9,6 +9,9 @@ def Magestead.configure(config, settings) # Bootstrap type bootstrap = settings["bootstrap"] ||= nil + # setup domain + domain = settings["domain"] ||= "magestead.dev" + # Prevent TTY Errors config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" @@ -115,7 +118,7 @@ def Magestead.configure(config, settings) if (bootstrap == "magento") config.vm.provision "shell" do |s| s.path = scriptDir + "/magento-bootstrap.sh" - s.args = [settings["databases"][0]] + s.args = [settings["databases"][0], domain] end end @@ -133,5 +136,10 @@ def Magestead.configure(config, settings) end end + config.vm.provision "shell" do |s| + s.path = scriptDir + "/server.sh" + s.args = [domain, bootstrap] + end + end end diff --git a/provision/server.sh b/provision/server.sh new file mode 100644 index 0000000..b8cebe5 --- /dev/null +++ b/provision/server.sh @@ -0,0 +1,122 @@ +#!/usr/bin/env bash + +if [ $2 -eq "magento" ] +then + root = "/vagrant/public" +elif [ $2 -eq "laravel" ] +then + root = "/vagrant/laravel/public" +elif [ $2 -eq "symfony" ] +then + root = "/vagrant/symfony/web" +fi + +block="server { + listen 80; + server_name $1; + root \"$root\"; + autoindex on; + + index index.html index.htm index.php; + + charset utf-8; + + ## + # dont log robots.txt requests + ## + location /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + ## These locations would be hidden by .htaccess normally + location ^~ /app/ { deny all; } + location ^~ /includes/ { deny all; } + location ^~ /lib/ { deny all; } + location ^~ /media/downloadable/ { deny all; } + location ^~ /pkginfo/ { deny all; } + location ^~ /report/config.xml { deny all; } + location ^~ /var/ { deny all; } + location /var/export/ { deny all; } + # deny htaccess files + location ~ /\. { + deny all; + access_log off; + log_not_found off; + } + + ## + # Rewrite for versioned CSS+JS via filemtime + ## + location ~* ^.+\.(css|js)\$ { + rewrite ^(.+)\.(\d+)\.(css|js)\$ \$1.\$3 last; + expires 31536000s; + access_log off; + log_not_found off; + add_header Pragma public; + add_header Cache-Control \"max-age=31536000, public\"; + } + ## + # Aggressive caching for static files + # If you alter static files often, please use + # add_header Cache-Control \"max-age=31536000, public, must-revalidate, proxy-revalidate\"; + ## + location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)\$ { + expires 31536000s; + access_log off; + log_not_found off; + add_header Pragma public; + #add_header Cache-Control \"max-age=31536000, public\"; + add_header Cache-Control \"max-age=31536000, public, must-revalidate, proxy-revalidate\"; + } + + # error pages + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + location / { + try_files /maintenance.html \$uri \$uri/ @handler; ## If missing pass the URI to Magento's front handler + expires 30d; ## Assume all files are cachable + } + location @handler { ## Magento uses a common front handler + rewrite / /index.php; + } + location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler + rewrite ^(.*.php)/ \$1 last; + } + + location ~ \.php$ { + #try_files $uri =404; + + if (!-e $request_filename) { rewrite / /index.php last; } + + expires off; + fastcgi_pass 127.0.0.1:9000; + fastcgi_split_path_info ^(.+\.php)(/.+)\$; + fastcgi_index index.php; + + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; + + ## Store code is defined in administration > Configuration > Manage Stores + fastcgi_param MAGE_RUN_CODE default; + fastcgi_param MAGE_RUN_TYPE store; + + include fastcgi_params; ## See /etc/nginx/fastcgi_params + + } + + rewrite ^/minify/([0-9]+)(/.*.(js|css))\$ /lib/minify/m.php?f=\$2&d=\$1 last; + rewrite ^/skin/m/([0-9]+)(/.*.(js|css))\$ /lib/minify/m.php?f=\$2&d=\$1 last; +} +" + +echo "$block" > "/etc/nginx/conf.d/$1" +sudo service nginx restart +sudo service php5-fpm restart \ No newline at end of file diff --git a/provision/stubs/magento-composer.json b/provision/stubs/magento-composer.json index 60f1e57..7f53b3b 100644 --- a/provision/stubs/magento-composer.json +++ b/provision/stubs/magento-composer.json @@ -8,7 +8,9 @@ "require": { "aydin-hassan/magento-core-composer-installer" : "~1.0", "magento/magento" : "1.9.1.0", - "magento-hackathon/magento-composer-installer": "3.0.*" + "magento-hackathon/magento-composer-installer": "3.0.*", + "inviqa/magento-symfony-container": "*", + "colinmollenhour/cache-backend-redis": "*" }, "authors": [ { diff --git a/provision/stubs/services.xml b/provision/stubs/services.xml new file mode 100644 index 0000000..e197a71 --- /dev/null +++ b/provision/stubs/services.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file From 571e06d620b015bda42443e3e96e9ac169a96e32 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 19:50:28 +0100 Subject: [PATCH 02/16] Install via command line, set domains correctly and update composer package versions. --- provision/magento-bootstrap.sh | 8 +++++--- provision/magestead.rb | 14 +++++++++++++- provision/server.sh | 19 ++++--------------- provision/stubs/magento-composer.json | 2 +- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/provision/magento-bootstrap.sh b/provision/magento-bootstrap.sh index a10cb73..c246a55 100644 --- a/provision/magento-bootstrap.sh +++ b/provision/magento-bootstrap.sh @@ -8,13 +8,13 @@ cp -R /vagrant/provision/stubs/magento-composer.json /vagrant/composer.json cd /vagrant; /usr/local/bin/composer install; -cp -R /vagrant/provision/stubs/services.xml /vagrant/public/app/etc/services.xml; +cp -R /vagrant/provision/stubs/services.xml /vagrant/magento/app/etc/services.xml; echo "--- Installing Magento ---" -cd /vagrant/public; +cd /vagrant/magento; -php-cli -f install.php -- \ +php -f install.php -- \ --license_agreement_accepted "yes" \ --locale "en_GB" \ --timezone "Europe/London" \ @@ -25,6 +25,8 @@ php-cli -f install.php -- \ --db_pass "root" \ --url "$domain" \ --use_rewrites "yes" \ +--use_secure "no" \ +--use_secure_admin "no" \ --secure_base_url "$domain" \ --admin_firstname "RichDynamix" \ --admin_lastname "Magestead" \ diff --git a/provision/magestead.rb b/provision/magestead.rb index 43acec8..6315941 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -12,6 +12,18 @@ def Magestead.configure(config, settings) # setup domain domain = settings["domain"] ||= "magestead.dev" + # Path setting + path = "/vagrant/public" + if (bootstrap == "magento") + path = "/vagrant/magento" + end + if (bootstrap == "laravel") + path = "/vagrant/laravel/public" + end + if (bootstrap == "symfony") + path = "/vagrant/symfony/web" + end + # Prevent TTY Errors config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" @@ -138,7 +150,7 @@ def Magestead.configure(config, settings) config.vm.provision "shell" do |s| s.path = scriptDir + "/server.sh" - s.args = [domain, bootstrap] + s.args = [domain, path] end end diff --git a/provision/server.sh b/provision/server.sh index b8cebe5..a86cec9 100644 --- a/provision/server.sh +++ b/provision/server.sh @@ -1,20 +1,9 @@ #!/usr/bin/env bash -if [ $2 -eq "magento" ] -then - root = "/vagrant/public" -elif [ $2 -eq "laravel" ] -then - root = "/vagrant/laravel/public" -elif [ $2 -eq "symfony" ] -then - root = "/vagrant/symfony/web" -fi - block="server { listen 80; server_name $1; - root \"$root\"; + root $2; autoindex on; index index.html index.htm index.php; @@ -93,9 +82,9 @@ block="server { } location ~ \.php$ { - #try_files $uri =404; + #try_files \$uri =404; - if (!-e $request_filename) { rewrite / /index.php last; } + if (!-e \$request_filename) { rewrite / /index.php last; } expires off; fastcgi_pass 127.0.0.1:9000; @@ -119,4 +108,4 @@ block="server { echo "$block" > "/etc/nginx/conf.d/$1" sudo service nginx restart -sudo service php5-fpm restart \ No newline at end of file +sudo service php-fpm restart \ No newline at end of file diff --git a/provision/stubs/magento-composer.json b/provision/stubs/magento-composer.json index 7f53b3b..64daa86 100644 --- a/provision/stubs/magento-composer.json +++ b/provision/stubs/magento-composer.json @@ -29,7 +29,7 @@ } ], "extra": { - "magento-root-dir": "public" + "magento-root-dir": "magento" }, "config": { "bin-dir": "bin" From a51e502d5042c4aeb971fafb67932203b2d18110 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 19:51:20 +0100 Subject: [PATCH 03/16] update gitignore and set versions --- .gitignore | 1 + provision/stubs/magento-composer.json | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 33bf56f..441d062 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea .vagrant vendor/ composer.lock \ No newline at end of file diff --git a/provision/stubs/magento-composer.json b/provision/stubs/magento-composer.json index 64daa86..178bb31 100644 --- a/provision/stubs/magento-composer.json +++ b/provision/stubs/magento-composer.json @@ -9,8 +9,8 @@ "aydin-hassan/magento-core-composer-installer" : "~1.0", "magento/magento" : "1.9.1.0", "magento-hackathon/magento-composer-installer": "3.0.*", - "inviqa/magento-symfony-container": "*", - "colinmollenhour/cache-backend-redis": "*" + "inviqa/magento-symfony-container": "0.1.2", + "colinmollenhour/cache-backend-redis": "1.8.1" }, "authors": [ { From 73e6d771d9b1143888fd04f8a5a06729c6edcccf Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 19:52:08 +0100 Subject: [PATCH 04/16] update gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 441d062..3d1cf38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ .idea .vagrant vendor/ -composer.lock \ No newline at end of file +composer.lock +magento/ +laravel/ +symfony/ \ No newline at end of file From 19276d60fb973fb48a96674df0bf8a56066e0219 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 20:34:39 +0100 Subject: [PATCH 05/16] Skip url validation for install. --- provision/magento-bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/provision/magento-bootstrap.sh b/provision/magento-bootstrap.sh index c246a55..fa9ee59 100644 --- a/provision/magento-bootstrap.sh +++ b/provision/magento-bootstrap.sh @@ -25,6 +25,7 @@ php -f install.php -- \ --db_pass "root" \ --url "$domain" \ --use_rewrites "yes" \ +--skip_url_validation "yes" \ --use_secure "no" \ --use_secure_admin "no" \ --secure_base_url "$domain" \ From 5b988ce33c732faba884c66a06085b066f3bb09a Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Thu, 30 Jul 2015 20:37:22 +0100 Subject: [PATCH 06/16] Use DB for session saves - gets round NFS issues with NGINX --- provision/magento-bootstrap.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/provision/magento-bootstrap.sh b/provision/magento-bootstrap.sh index fa9ee59..0c81b4e 100644 --- a/provision/magento-bootstrap.sh +++ b/provision/magento-bootstrap.sh @@ -23,6 +23,7 @@ php -f install.php -- \ --db_name "$DB" \ --db_user "root" \ --db_pass "root" \ +--session_save "db" \ --url "$domain" \ --use_rewrites "yes" \ --skip_url_validation "yes" \ From 775ab2edb636a0c15bbbe5b8ee696d6d6dc5c031 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 08:27:49 +0100 Subject: [PATCH 07/16] Add magento2 option to YAML --- provision/Magestead.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/provision/Magestead.yaml b/provision/Magestead.yaml index abd0b40..ce7b362 100644 --- a/provision/Magestead.yaml +++ b/provision/Magestead.yaml @@ -13,7 +13,8 @@ domain: magento.dev databases: - magestead -bootstrap: magento +#bootstrap: magento +bootstrap: magento2 # bootstrap: laravel # bootstrap: symfony From ee1f52178f1880208db7b2cfab86747a8d58b566 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 08:39:46 +0100 Subject: [PATCH 08/16] Setup the magento2 bash script and server blocks --- provision/magento2-bootstrap.sh | 42 +++++++++++++++++++++++++++++++++ provision/magestead.rb | 34 ++++++++++++++++++++------ 2 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 provision/magento2-bootstrap.sh diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh new file mode 100644 index 0000000..5689d18 --- /dev/null +++ b/provision/magento2-bootstrap.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# Clone the repo +cd /vagrant; +git clone git@github.com:magento/magento2.git magento2; + +# Set permissions +cd magento2; +sudo find . -type d -exec chmod 700 {} \; && sudo find . -type f -exec chmod 600 {} \; && sudo chmod +x bin/magento +/usr/local/bin/composer install; + +# Export the path to use global +export PATH=$PATH:/vagrant/magento2/bin; + +# Create the NGINX server block +block="# Magento Vars + +set $MAGE_ROOT /vagrant/magento2; +set $MAGE_MODE default; # or production or developer + +# Example configuration: + upstream fastcgi_backend { + # use tcp connection + server 127.0.0.1:9000; + # or socket + # server unix:/var/run/php5-fpm.sock; + } + server { + listen 80; + server_name mage.dev; + set $MAGE_ROOT /var/www/magento2; + set $MAGE_MODE developer; + include /vagrant/magento2/nginx.conf.sample; + } +" + +# Add the block and restart PHP-FPM and NGINX +echo "$block" > "/etc/nginx/conf.d/$1" +sudo service nginx restart +sudo service php-fpm restart + +# Run the setup wizard from command line \ No newline at end of file diff --git a/provision/magestead.rb b/provision/magestead.rb index 6315941..aac9e7f 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -131,26 +131,46 @@ def Magestead.configure(config, settings) config.vm.provision "shell" do |s| s.path = scriptDir + "/magento-bootstrap.sh" s.args = [settings["databases"][0], domain] - end + end + + config.vm.provision "shell" do |s| + s.path = scriptDir + "/server.sh" + s.args = [domain, path] + end + + end + + # Bootstrap Magento2 Intallation + if (bootstrap == "magento2") + config.vm.provision "shell" do |s| + s.path = scriptDir + "/magento2-bootstrap.sh" + s.args = [settings["databases"][0], domain] + end end # Bootstrap Laravel Intallation if (bootstrap == "laravel") config.vm.provision "shell" do |s| s.path = scriptDir + "/laravel-bootstrap.sh" - end + end + + config.vm.provision "shell" do |s| + s.path = scriptDir + "/server.sh" + s.args = [domain, path] + end + end # Bootstrap Symfony Intallation if (bootstrap == "symfony") config.vm.provision "shell" do |s| s.path = scriptDir + "/symfony-bootstrap.sh" - end - end + end - config.vm.provision "shell" do |s| - s.path = scriptDir + "/server.sh" - s.args = [domain, path] + config.vm.provision "shell" do |s| + s.path = scriptDir + "/server.sh" + s.args = [domain, path] + end end end From 3e6c61bbded53aa0e5d9ce87a19cc709546452f5 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 09:17:04 +0100 Subject: [PATCH 09/16] Magento2 installtion scripts --- provision/magento2-bootstrap.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index 5689d18..f17ee3f 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +DB=$1; +domain=$2; + # Clone the repo cd /vagrant; git clone git@github.com:magento/magento2.git magento2; @@ -39,4 +42,24 @@ echo "$block" > "/etc/nginx/conf.d/$1" sudo service nginx restart sudo service php-fpm restart -# Run the setup wizard from command line \ No newline at end of file +# Run the setup wizard from command line + +magento setup:install --base-url=http://$domain/ \ +--db-host=localhost \ +--db-name=$DB \ +--db-user=root \ +--db-password=root \ +--admin-firstname=Magento \ +--admin-lastname=Admin \ +--admin-email=admin@admin.com \ +--admin-user=admin \ +--admin-password=password123 \ +--language=en_GB \ +--currency=GBP \ +--timezone=Europe/London \ +--use-rewrites=1 \ +--session-save=db + +echo "Magento admin username = admin"; +echo "Magento admin password = password123"; +echo "Magento installed at http://$domain/. Remember and set your hosts file."; \ No newline at end of file From b8ce1400e28593fbbd6d21041683f4337417bdef Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 09:18:16 +0100 Subject: [PATCH 10/16] Clean up server block --- provision/magento2-bootstrap.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index f17ee3f..c084843 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -18,9 +18,6 @@ export PATH=$PATH:/vagrant/magento2/bin; # Create the NGINX server block block="# Magento Vars -set $MAGE_ROOT /vagrant/magento2; -set $MAGE_MODE default; # or production or developer - # Example configuration: upstream fastcgi_backend { # use tcp connection @@ -31,7 +28,7 @@ set $MAGE_MODE default; # or production or developer server { listen 80; server_name mage.dev; - set $MAGE_ROOT /var/www/magento2; + set $MAGE_ROOT /vagrant/magento2; set $MAGE_MODE developer; include /vagrant/magento2/nginx.conf.sample; } From d0ad8dbb9d0db313b683296c57d8dc01a870cf9c Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 11:15:26 +0100 Subject: [PATCH 11/16] install missing package --- provision/blackfire.sh | 0 provision/magento2-bootstrap.sh | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) mode change 100755 => 100644 provision/blackfire.sh diff --git a/provision/blackfire.sh b/provision/blackfire.sh old mode 100755 new mode 100644 diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index c084843..c60b462 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -3,9 +3,14 @@ DB=$1; domain=$2; +echo "--- Bootstrapping Magento 2 ---" + +# Install missing package +sudo yum -y install php-intl; + # Clone the repo cd /vagrant; -git clone git@github.com:magento/magento2.git magento2; +git clone https://github.com/magento/magento2.git # Set permissions cd magento2; From 7bbd499d725e582a1ee73c4a54d12b101a6eb0c5 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Fri, 31 Jul 2015 19:50:53 +0100 Subject: [PATCH 12/16] Fix server block, remove uneeded items --- provision/magento2-bootstrap.sh | 123 ++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 21 deletions(-) diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index c60b462..58ed0cb 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -5,12 +5,11 @@ domain=$2; echo "--- Bootstrapping Magento 2 ---" -# Install missing package -sudo yum -y install php-intl; - # Clone the repo cd /vagrant; -git clone https://github.com/magento/magento2.git +if [ ! -d /vagrant/magento2 ]; then + git clone https://github.com/magento/magento2.git +fi # Set permissions cd magento2; @@ -21,31 +20,113 @@ sudo find . -type d -exec chmod 700 {} \; && sudo find . -type f -exec chmod 600 export PATH=$PATH:/vagrant/magento2/bin; # Create the NGINX server block -block="# Magento Vars - -# Example configuration: - upstream fastcgi_backend { - # use tcp connection - server 127.0.0.1:9000; - # or socket - # server unix:/var/run/php5-fpm.sock; - } - server { +block="server { listen 80; - server_name mage.dev; - set $MAGE_ROOT /vagrant/magento2; - set $MAGE_MODE developer; - include /vagrant/magento2/nginx.conf.sample; - } + server_name $domain; + set \$MAGE_ROOT /vagrant/magento2; + set \$MAGE_MODE developer; + + root \$MAGE_ROOT/pub; + + index index.php; + autoindex off; + charset off; + + 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; + } + + location ~ (index|get|static|report|404|503)\.php$ { + try_files \$uri =404; + fastcgi_pass 127.0.0.1:9000; + fastcgi_split_path_info ^(.+\.php)(/.+)\$; + fastcgi_index index.php; + + 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; + include fastcgi_params; + } +} " # Add the block and restart PHP-FPM and NGINX -echo "$block" > "/etc/nginx/conf.d/$1" +echo "$block" > "/etc/nginx/conf.d/$domain" sudo service nginx restart sudo service php-fpm restart # Run the setup wizard from command line - magento setup:install --base-url=http://$domain/ \ --db-host=localhost \ --db-name=$DB \ From b1151638e67577c34dae0000924f1ab1db1ff020 Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Mon, 3 Aug 2015 09:49:28 +0100 Subject: [PATCH 13/16] Magento 2 config updates, changed mysql password --- provision/Magestead.yaml | 3 ++ provision/create-mysql.sh | 2 +- provision/magento2-bootstrap.sh | 73 ++++++++++++++++++++++++--------- provision/magestead.rb | 8 +++- 4 files changed, 63 insertions(+), 23 deletions(-) diff --git a/provision/Magestead.yaml b/provision/Magestead.yaml index ce7b362..36d1889 100644 --- a/provision/Magestead.yaml +++ b/provision/Magestead.yaml @@ -18,6 +18,9 @@ bootstrap: magento2 # bootstrap: laravel # bootstrap: symfony +# Install Sample Data (MAGENTO 2 ONLY) +sampledata: "true" + # blackfire: # - id: foo # token: bar diff --git a/provision/create-mysql.sh b/provision/create-mysql.sh index 76dd22e..cf4c35b 100644 --- a/provision/create-mysql.sh +++ b/provision/create-mysql.sh @@ -2,4 +2,4 @@ DB=$1; -mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci"; +mysql -uroot -pvagrant -e "CREATE DATABASE IF NOT EXISTS \`$DB\` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci"; diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index 58ed0cb..1e22fca 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -2,23 +2,28 @@ DB=$1; domain=$2; +sampledata=$3; echo "--- Bootstrapping Magento 2 ---" # Clone the repo cd /vagrant; if [ ! -d /vagrant/magento2 ]; then + echo "Cloning Magento 2 Repo" git clone https://github.com/magento/magento2.git fi +echo "Setting Permissions" # Set permissions cd magento2; sudo find . -type d -exec chmod 700 {} \; && sudo find . -type f -exec chmod 600 {} \; && sudo chmod +x bin/magento /usr/local/bin/composer install; +echo "Exporting PATH" # Export the path to use global export PATH=$PATH:/vagrant/magento2/bin; +echo "Setting NGINX Server Block" # Create the NGINX server block block="server { listen 80; @@ -57,11 +62,11 @@ block="server { expires off; if (!-f \$request_filename) { - rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$\2 last; + rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last; } } if (!-f \$request_filename) { - rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$\2 last; + rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=\$2 last; } } @@ -120,29 +125,57 @@ block="server { } } " - +echo "Restart Services" # Add the block and restart PHP-FPM and NGINX echo "$block" > "/etc/nginx/conf.d/$domain" sudo service nginx restart sudo service php-fpm restart -# Run the setup wizard from command line -magento setup:install --base-url=http://$domain/ \ ---db-host=localhost \ ---db-name=$DB \ ---db-user=root \ ---db-password=root \ ---admin-firstname=Magento \ ---admin-lastname=Admin \ ---admin-email=admin@admin.com \ ---admin-user=admin \ ---admin-password=password123 \ ---language=en_GB \ ---currency=GBP \ ---timezone=Europe/London \ ---use-rewrites=1 \ ---session-save=db +echo "Installing Magento 2" + +# Install Sample Data +if [ $sampledata == "true" ]; then + echo "Setting Up Sample Data Install -- Please wait" + /usr/local/bin/composer config repositories.magento composer http://packages.magento.com + /usr/local/bin/composer require magento/sample-data:~1.0.0-beta + + echo "Installing Sample Data" + # Run the setup wizard from command line + magento setup:install --base-url=http://$domain/ \ + --db-host=localhost \ + --db-name=$DB \ + --db-user=root \ + --db-password=vagrant \ + --admin-firstname=Magento \ + --admin-lastname=Admin \ + --admin-email=admin@admin.com \ + --admin-user=admin \ + --admin-password=password123 \ + --language=en_GB \ + --currency=GBP \ + --timezone=Europe/London \ + --use-rewrites=1 \ + --use-sample-data \ + --session-save=db +else + # Run the setup wizard from command line + magento setup:install --base-url=http://$domain/ \ + --db-host=localhost \ + --db-name=$DB \ + --db-user=root \ + --db-password=vagrant \ + --admin-firstname=Magento \ + --admin-lastname=Admin \ + --admin-email=admin@admin.com \ + --admin-user=admin \ + --admin-password=password123 \ + --language=en_GB \ + --currency=GBP \ + --timezone=Europe/London \ + --use-rewrites=1 \ + --session-save=db +fi echo "Magento admin username = admin"; echo "Magento admin password = password123"; -echo "Magento installed at http://$domain/. Remember and set your hosts file."; \ No newline at end of file +echo "Magento installed at http://$domain/. Remember and set your hosts file."; diff --git a/provision/magestead.rb b/provision/magestead.rb index aac9e7f..5967b97 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -24,11 +24,15 @@ def Magestead.configure(config, settings) path = "/vagrant/symfony/web" end + # Sample Data (MAGENTO 2 ONLY) + sampledata = settings["sampledata"] ||= "false" + # Prevent TTY Errors config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" # Configure The Box - config.vm.box = "richdynamix/magestead" + #config.vm.box = "richdynamix/magestead" + config.vm.box = "magestead" config.vm.hostname = settings["hostname"] ||= "magestead" # Configure A Private Network IP @@ -144,7 +148,7 @@ def Magestead.configure(config, settings) if (bootstrap == "magento2") config.vm.provision "shell" do |s| s.path = scriptDir + "/magento2-bootstrap.sh" - s.args = [settings["databases"][0], domain] + s.args = [settings["databases"][0], domain, sampledata] end end From 994d533e6a6fbddb53d7f35f7b9b95cd7191a79e Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Mon, 3 Aug 2015 10:39:42 +0100 Subject: [PATCH 14/16] Remove Magento 2 sample data. Memory issues on loading. --- provision/Magestead.yaml | 3 -- provision/magento2-bootstrap.sh | 60 +++++++++------------------------ provision/magestead.rb | 5 +-- 3 files changed, 17 insertions(+), 51 deletions(-) diff --git a/provision/Magestead.yaml b/provision/Magestead.yaml index 36d1889..ce7b362 100644 --- a/provision/Magestead.yaml +++ b/provision/Magestead.yaml @@ -18,9 +18,6 @@ bootstrap: magento2 # bootstrap: laravel # bootstrap: symfony -# Install Sample Data (MAGENTO 2 ONLY) -sampledata: "true" - # blackfire: # - id: foo # token: bar diff --git a/provision/magento2-bootstrap.sh b/provision/magento2-bootstrap.sh index 1e22fca..c93ca01 100644 --- a/provision/magento2-bootstrap.sh +++ b/provision/magento2-bootstrap.sh @@ -2,7 +2,6 @@ DB=$1; domain=$2; -sampledata=$3; echo "--- Bootstrapping Magento 2 ---" @@ -132,49 +131,22 @@ sudo service nginx restart sudo service php-fpm restart echo "Installing Magento 2" - -# Install Sample Data -if [ $sampledata == "true" ]; then - echo "Setting Up Sample Data Install -- Please wait" - /usr/local/bin/composer config repositories.magento composer http://packages.magento.com - /usr/local/bin/composer require magento/sample-data:~1.0.0-beta - - echo "Installing Sample Data" - # Run the setup wizard from command line - magento setup:install --base-url=http://$domain/ \ - --db-host=localhost \ - --db-name=$DB \ - --db-user=root \ - --db-password=vagrant \ - --admin-firstname=Magento \ - --admin-lastname=Admin \ - --admin-email=admin@admin.com \ - --admin-user=admin \ - --admin-password=password123 \ - --language=en_GB \ - --currency=GBP \ - --timezone=Europe/London \ - --use-rewrites=1 \ - --use-sample-data \ - --session-save=db -else - # Run the setup wizard from command line - magento setup:install --base-url=http://$domain/ \ - --db-host=localhost \ - --db-name=$DB \ - --db-user=root \ - --db-password=vagrant \ - --admin-firstname=Magento \ - --admin-lastname=Admin \ - --admin-email=admin@admin.com \ - --admin-user=admin \ - --admin-password=password123 \ - --language=en_GB \ - --currency=GBP \ - --timezone=Europe/London \ - --use-rewrites=1 \ - --session-save=db -fi +# Run the setup wizard from command line +magento setup:install --base-url=http://$domain/ \ +--db-host=localhost \ +--db-name=$DB \ +--db-user=root \ +--db-password=vagrant \ +--admin-firstname=Magento \ +--admin-lastname=Admin \ +--admin-email=admin@admin.com \ +--admin-user=admin \ +--admin-password=password123 \ +--language=en_GB \ +--currency=GBP \ +--timezone=Europe/London \ +--use-rewrites=1 \ +--session-save=db echo "Magento admin username = admin"; echo "Magento admin password = password123"; diff --git a/provision/magestead.rb b/provision/magestead.rb index 5967b97..2a47cb5 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -24,9 +24,6 @@ def Magestead.configure(config, settings) path = "/vagrant/symfony/web" end - # Sample Data (MAGENTO 2 ONLY) - sampledata = settings["sampledata"] ||= "false" - # Prevent TTY Errors config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" @@ -148,7 +145,7 @@ def Magestead.configure(config, settings) if (bootstrap == "magento2") config.vm.provision "shell" do |s| s.path = scriptDir + "/magento2-bootstrap.sh" - s.args = [settings["databases"][0], domain, sampledata] + s.args = [settings["databases"][0], domain] end end From fa4b10a17806291b0f57a8026b229535f44e9e6b Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Mon, 3 Aug 2015 11:02:08 +0100 Subject: [PATCH 15/16] Update readme --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 44099b4..c68e989 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,13 @@ While there is no perfect vagrant box setup that will fit the needs of everyone, Magestead is designed to be configurable like Homestead using the YAML configuration while maintaining a much easier per project workflow that ScotchBox offers. The most obvious change in Magestead is the switch from an Ubuntu box to a CentOS box. This switch is to accommodate the developers who work in a Red Hat/CentOS environment everyday and prefer the package managers and comfort of a system they know. #### What's in the box? -With a CentOS 6.6 core server using NGINX, PHP 5.6, MySQL 5.5, Redis & Memcached, you know you have a development environment with performance! +With a CentOS 6.6 core server using NGINX, PHP 5.6, MySQL 5.6, Redis & Memcached, you know you have a development environment with performance! #### The Full Stack - CentOS 6.6 - NGINX - PHP 5.6 -- MySQL 5.5 +- MySQL 5.6 - Redis - Memcached - PHPUnit @@ -67,7 +67,11 @@ The `bootstrap:` setting is a new setting to magestead and has three different o `See https://github.com/colinmollenhour/Cm_Cache_Backend_Redis for documentation.` -The second `bootstrap:` option is `laravel`. When you choose this option laravel will be downloaded and installed into a laravel directory and a symbolic link is created to the web `public` directory from your laravel `public` directory. The key is already set using composer and the directories of storage and bootstrap/cache are made writable by the server. +New to version `v1.1` is Magento 2 using the option `magento2`. This will download the latest stable release from github, currently `1.0.0-beta`, setup database and install the Magento2 software. Please note that the admin url is left to autogenerate during installation, pay attention to the output when magestead finishes running. It will prompt you with admin login credentials. + +The third `bootstrap:` option is `laravel`. When you choose this option laravel will be downloaded and installed into a laravel directory and a symbolic link is created to the web `public` directory from your laravel `public` directory. The key is already set using composer and the directories of storage and bootstrap/cache are made writable by the server. + + #### Launching The Vagrant Box From 6252e1a32bffb34fa58e1071f92dd29fe96c7e9d Mon Sep 17 00:00:00 2001 From: Steven Richardson Date: Mon, 3 Aug 2015 11:37:50 +0100 Subject: [PATCH 16/16] Add real box --- provision/magestead.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provision/magestead.rb b/provision/magestead.rb index 2a47cb5..14d1dd4 100644 --- a/provision/magestead.rb +++ b/provision/magestead.rb @@ -28,8 +28,8 @@ def Magestead.configure(config, settings) config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" # Configure The Box - #config.vm.box = "richdynamix/magestead" - config.vm.box = "magestead" + config.vm.box = "richdynamix/magestead" +# config.vm.box = "magestead" config.vm.hostname = settings["hostname"] ||= "magestead" # Configure A Private Network IP