Skip to content

Commit

Permalink
Merge pull request #6 from richdynamix/feature/magento2
Browse files Browse the repository at this point in the history
feature/Adding Magento2 to bootstrap options.
  • Loading branch information
richdynamix committed Aug 3, 2015
2 parents 36fc1cd + 6252e1a commit e0b0b02
Show file tree
Hide file tree
Showing 11 changed files with 368 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.idea
.vagrant
vendor/
composer.lock
composer.lock
magento/
laravel/
symfony/
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion provision/Magestead.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa

domain: magento.dev

databases:
- magestead

# bootstrap: magento
#bootstrap: magento
bootstrap: magento2
# bootstrap: laravel
# bootstrap: symfony

Expand Down
Empty file modified provision/blackfire.sh
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion provision/create-mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";
34 changes: 31 additions & 3 deletions provision/magento-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
#!/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/magento/app/etc/services.xml;

cd /vagrant/public;
echo "--- Installing Magento ---"

/usr/local/bin/modgit init;
/usr/local/bin/modgit add Cm_Cache_Backend_Redis git://github.com/colinmollenhour/Cm_Cache_Backend_Redis.git;
cd /vagrant/magento;

php -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" \
--session_save "db" \
--url "$domain" \
--use_rewrites "yes" \
--skip_url_validation "yes" \
--use_secure "no" \
--use_secure_admin "no" \
--secure_base_url "$domain" \
--admin_firstname "RichDynamix" \
--admin_lastname "Magestead" \
--admin_email "[email protected]" \
--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.";
153 changes: 153 additions & 0 deletions provision/magento2-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/usr/bin/env bash

DB=$1;
domain=$2;

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;
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;
}
}
"
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

echo "Installing Magento 2"
# 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 \
[email protected] \
--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.";
49 changes: 45 additions & 4 deletions provision/magestead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@ def Magestead.configure(config, settings)
# Bootstrap type
bootstrap = settings["bootstrap"] ||= nil

# 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'"

# Configure The Box
config.vm.box = "richdynamix/magestead"
# config.vm.box = "magestead"
config.vm.hostname = settings["hostname"] ||= "magestead"

# Configure A Private Network IP
Expand Down Expand Up @@ -115,22 +131,47 @@ 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]]
end
s.args = [settings["databases"][0], domain]
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

config.vm.provision "shell" do |s|
s.path = scriptDir + "/server.sh"
s.args = [domain, path]
end
end

end
Expand Down
Loading

0 comments on commit e0b0b02

Please sign in to comment.