Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 73494cd

Browse files
committed
Implemented simplified installation flow for *nix hosts
1 parent f63a8dc commit 73494cd

6 files changed

+70
-41
lines changed

README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# Vagrant for Magento, optimized for Windows hosts
1+
# Vagrant project for Magento 2 developers (optimized for Mac, Windows and \*nix hosts)
22

33
## What You get
44

5-
The current Vagrant configuration aims to solve performance issues of Magento installed on Virtual Box, when the host is Windows.
6-
See [explanation of the proposed solution](docs/performance-issue-on-windows-hosts.md).
5+
It is expected that Magento 2 project source code will be located on the host and managed using [Composer](https://getcomposer.org/doc/00-intro.md).
6+
This is necessary to allow IDE index project files quickly. All other infrastructure infrastructure is deployed on the guest machine.
7+
8+
Current Vagrant configuration aims to solve performance issues of Magento installed on Virtual Box **for development**.
9+
Custom solution is implemented for Windows hosts. See [explanation of the proposed solution](docs/performance-issue-on-windows-hosts.md).
710

811
With current configuration Vagrant will:
912

1013
1. Run Ubuntu box
1114
1. Install and configure all software necessary for Magento 2
12-
1. Install all necessary libraries
1315
1. Install the Magento 2 application
1416

1517
## Environment set up workflow
@@ -38,7 +40,7 @@ If you never used Vagrant before, read [Vagrant Docs](https://docs.vagrantup.com
3840
cd ..
3941
```
4042
41-
1. Download project with Vagrant configuration and install Magento (~ 5 minutes):
43+
1. Download project with Vagrant configuration and install Magento (may take some time to download Ubuntu box for the first time, then ~ 5 minutes):
4244
4345
```
4446
git clone git@github.com:paliarush/vagrant-magento.git vagrant-magento
@@ -50,7 +52,7 @@ If you never used Vagrant before, read [Vagrant Docs](https://docs.vagrantup.com
5052
```
5153
192.168.10.11 magento2.vagrant
5254
```
53-
1. After the installation is complete, [set up synchronization with PHP Storm](docs/phpstorm-configuration.md)
55+
1. For **Windows hosts only**: after the installation is complete, [set up synchronization with PHP Storm](docs/phpstorm-configuration-windows-hosts.md)
5456
5557
### After installation
5658
@@ -83,7 +85,7 @@ For the Vagrant configuration you may specify your token in `local.config/github
8385
Installing GitHub OAuth token from /vagrant/local.config/github.oauth.token
8486
```
8587
86-
## Magento development workflow
88+
## Day-to-day development scenarios
8789
8890
### Reinstall Magento
8991
To save some time and get clear Magento installation, you can skip installation of software like web server or php.

Vagrantfile

+30-16
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,44 @@
11
# -*- mode: ruby -*-
22
# vi: set ft=ruby :
33

4+
module OS
5+
def OS.is_windows
6+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
7+
end
8+
end
9+
410
# All Vagrant configuration is done below. The "2" in Vagrant.configure
511
# configures the configuration version (we support older styles for
612
# backwards compatibility). Please don't change it unless you know what
713
# you're doing.
814
Vagrant.configure(2) do |config|
9-
config.vm.box = "ubuntu/trusty64"
15+
config.vm.box = "ubuntu/trusty64"
1016

11-
config.vm.provider "virtualbox" do |vb|
12-
vb.memory = 2048
13-
end
14-
config.vm.network :private_network, ip: '192.168.10.11'
15-
config.vm.hostname = "magento2.vagrant"
17+
config.vm.provider "virtualbox" do |vb|
18+
vb.memory = 2048
19+
end
20+
config.vm.network :private_network, ip: '192.168.10.11'
21+
config.vm.hostname = "magento2.vagrant"
1622

17-
config.vm.synced_folder '.', '/vagrant'
18-
config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2ce/var/generation'
19-
config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2ce/app/etc'
23+
config.vm.synced_folder '.', '/vagrant'
24+
if OS.is_windows
25+
config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2ce/var/generation'
26+
config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2ce/app/etc'
27+
else
28+
config.vm.synced_folder '../magento2ce', '/var/www/magento2ce', type: "nfs"
29+
end
2030

21-
config.vm.provision "install_environment", type: "shell" do |s|
22-
s.path = "install_environment.sh"
23-
end
31+
config.vm.provision "install_environment", type: "shell" do |s|
32+
s.path = "install_environment.sh"
33+
s.args = [OS.is_windows ? "1" : "0"]
34+
end
2435

25-
config.vm.provision "deploy_magento_code", type: "file", source: '../magento2ce', destination: '/var/www'
36+
if OS.is_windows
37+
config.vm.provision "deploy_magento_code", type: "file", source: '../magento2ce', destination: '/var/www'
38+
end
2639

27-
config.vm.provision "install_magento", type: "shell" do |s|
28-
s.path = "install_magento.sh"
29-
end
40+
config.vm.provision "install_magento", type: "shell" do |s|
41+
s.path = "install_magento.sh"
42+
s.args = [OS.is_windows ? "1" : "0"]
43+
end
3044
end

docs/developer-use-cases.md

-6
This file was deleted.

docs/phpstorm-configuration.md docs/phpstorm-configuration-windows-hosts.md

+8
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ This solution is applicable to any Vagrant configuration for Magento instance, s
4141
1. Go to Tools -> Deployment -> Options... and enable automatic upload to default server and check "Upload external changes"
4242
4343
![](images/automatic-upload.png)
44+
45+
46+
Day-to-day development scenarios
47+
-----------------
48+
49+
1. You can upload full Magento code base to the virtual machine from the host machine using context menu on the root of the project in PhpStorm.
50+
51+
![](images/upload-magento-codebase.png)

install_environment.sh

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Enable trace printing and exit on the first error
44
set -ex
55

6+
is_windows_host=$1
7+
68
apt-get update
79

810
# Determine external IP address
@@ -73,10 +75,12 @@ if [ ! -f /usr/local/bin/composer ]; then
7375
mv composer.phar /usr/local/bin/composer
7476
fi
7577

76-
# Set permissions to allow Magento codebase upload by Vagrant provision script
77-
chown -R vagrant:vagrant /var/www
78-
chmod -R 755 /var/www
79-
8078
# Declare path to scripts supplied with vagrant and Magento
8179
magento_dir="/var/www/magento2ce"
8280
echo "export PATH=\$PATH:/vagrant/bin:${magento_dir}/bin" >> /etc/profile
81+
82+
# Set permissions to allow Magento codebase upload by Vagrant provision script
83+
if [ ${is_windows_host} -eq 1 ]; then
84+
chown -R vagrant:vagrant /var/www
85+
chmod -R 755 /var/www
86+
fi

install_magento.sh

+15-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
# Enable trace printing and exit on the first error
66
set -ex
77

8+
is_windows_host=$1
9+
810
# Determine external IP address
911
set +x
1012
IP=`ifconfig eth1 | grep inet | awk '{print $2}' | sed 's/addr://'`
@@ -70,22 +72,27 @@ install_cmd="./bin/magento setup:install \
7072
chmod +x bin/magento
7173
php ${install_cmd}
7274

73-
chown -R vagrant:vagrant ${magento_dir}
74-
7575
# Enable Magento cron jobs
7676
echo "* * * * * php ${magento_dir}/bin/magento cron:run &" | crontab -u vagrant -
7777

78+
if [ ${is_windows_host} -eq 1 ]; then
79+
chown -R vagrant:vagrant ${magento_dir}
80+
fi
81+
7882
set +x
7983
echo "
8084
Magento application was deployed in ${magento_dir} and installed successfully
8185
Access storefront at http://${HOST}/
8286
Access admin panel at http://${HOST}/${admin_frontame}/
8387
84-
Don't forget to update your 'hosts' file with '${IP} ${HOST}'
88+
Don't forget to update your 'hosts' file with '${IP} ${HOST}'"
8589

86-
[Optional] To finish developer environment set up:
87-
1. Please create new PhpStorm project using 'magento2ce' directory on your host
88-
(this directory should already contain Magento repository cloned earlier)
90+
if [ ${is_windows_host} -eq 1 ]; then
91+
echo "
92+
[Optional] To finish developer environment set up:
93+
1. Please create new PhpStorm project using 'magento2ce' directory on your host
94+
(this directory should already contain Magento repository cloned earlier)
8995
90-
2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration.md
91-
to set up synchronization in PhpStorm (or using rsync) with ${magento_dir} directory"
96+
2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration-windows-hosts.md
97+
to set up synchronization in PhpStorm (or using rsync) with ${magento_dir} directory"
98+
fi

0 commit comments

Comments
 (0)