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

Commit ec7a8b9

Browse files
author
Alexander Paliarush
committedOct 13, 2015
- Simplified installation flow
- Renamed magento2 => magento2ce on the guest machine - Fixed max_nesting_level issue with XDebug enabled - Apache is run by 'vagrant' user
1 parent 838d56a commit ec7a8b9

8 files changed

+116
-142
lines changed
 

Diff for: ‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/.vagrant
2-
/.idea
2+
/.idea
3+
/local.config

Diff for: ‎README.md

+21-19
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,26 @@ If you never used Vagrant before, read [Vagrant Docs](https://docs.vagrantup.com
2626
### To install the whole image from scratch
2727

2828
1. Run in command line from the directory which contains your projects:
29-
30-
:information_source: To have 'composer install' here work faster, remove 'prefer-source' option and follow the instructions provided in [Gighub limitations section](README.md#github-limitations)
31-
32-
```
33-
git clone git@github.com:paliarush/vagrant-magento.git vagrant-magento
34-
git clone git@github.com:magento/magento2.git magento2ce
35-
cd magento2ce
36-
mkdir -p var/generation
37-
composer install --prefer-source
38-
cd ../vagrant-magento
39-
vagrant up
40-
```
29+
1. Prepare Magento codebase. This step is optional, just ensure you have 'magento2ce' directory with Magento code available.
30+
31+
:information_source: To have 'composer install' here work faster, remove 'prefer-source' option and follow the instructions provided in [Gighub limitations section](README.md#github-limitations)
32+
33+
```
34+
git clone git@github.com:magento/magento2.git magento2ce
35+
cd magento2ce
36+
mkdir -p var/generation
37+
composer install --prefer-source
38+
cd ..
39+
```
40+
41+
1. Download project with Vagrant configuration and install Magento (~ 5 minutes):
42+
43+
```
44+
git clone git@github.com:paliarush/vagrant-magento.git vagrant-magento
45+
cd vagrant-magento
46+
vagrant up
47+
```
4148
1. At some point you will be prompted to [set up synchronization with PHP Storm](docs/phpstorm-configuration.md)
42-
and install Magento using:
43-
44-
```
45-
vagrant provision --provision-with install_magento
46-
```
4749
4850
###To reinstall Magento
4951
To save some time and get clear Magento installation, you can skip installation of software like web server or php.
@@ -59,12 +61,12 @@ vagrant provision --provision-with install_magento
5961
6062
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application:
6163
```
62-
Magento application was deployed in /var/www/magento2 and installed
64+
Magento application was deployed in /var/www/magento2ce and installed
6365
Access front store at http://${HOST}/
6466
Access admin panel at http://${HOST}/${admin_frontame}/
6567
```
6668
67-
`/var/www/magento2` is a path to your Magento installation on the VM.
69+
`/var/www/magento2ce` is a path to your Magento installation on the VM.
6870
6971
### Default credentials
7072

Diff for: ‎Vagrantfile

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ Vagrant.configure(2) do |config|
1515
config.vm.hostname = "magento2.vagrant"
1616

1717
config.vm.synced_folder '.', '/vagrant'
18-
config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2/var/generation', owner: "www-data", group: "www-data", mount_options: ["dmode=775", "fmode=775"]
19-
config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2/app/etc', owner: "www-data", group: "www-data", mount_options: ["dmode=775", "fmode=775"]
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'
2020

2121
config.vm.provision "install_environment", type: "shell" do |s|
22-
s.path = "bootstrap.sh"
22+
s.path = "install_environment.sh"
2323
end
2424

25+
config.vm.provision "deploy_magento_code", type: "file", source: '../magento2ce', destination: '/var/www'
26+
2527
config.vm.provision "install_magento", type: "shell" do |s|
2628
s.path = "install_magento.sh"
2729
end

Diff for: ‎docs/developer-use-cases.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Synchronization with local PHP Storm
2+
-----------------
3+
4+
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.
5+
6+
![](images/upload-magento-codebase.png)

Diff for: ‎docs/phpstorm-configuration.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ This solution is applicable to any Vagrant configuration for Magento instance, s
77

88
```
99
Vagrant.configure(2) do |config|
10-
config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2/var/generation'
11-
config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2/app/etc'
10+
config.vm.synced_folder '../magento2ce/var/generation', '/var/www/magento2ce/var/generation'
11+
config.vm.synced_folder '../magento2ce/app/etc', '/var/www/magento2ce/app/etc'
1212
end
1313
```
1414
@@ -30,7 +30,7 @@ This solution is applicable to any Vagrant configuration for Magento instance, s
3030
3131
![](images/private-key-auth-type.png)
3232
33-
1. Set up mapping between your local and remote versions of the project, for remote project use '/var/www/magento2'
33+
1. Set up mapping between your local and remote versions of the project, for remote project use '/var/www/magento2ce'
3434
3535
![](images/projects-mapping.png)
3636
@@ -41,7 +41,3 @@ 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-
1. Upload Magento code base to the virtual machine from the host machine using context menu on the root of the project in PHPStorm
46-
47-
![](images/upload-magento-codebase.png)

Diff for: ‎bootstrap.sh renamed to ‎install_environment.sh

+13-21
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,6 @@ set -ex
44

55
apt-get update
66

7-
# Check arguments
8-
#
9-
# Default values
10-
reinstall='';
11-
with_sample_data='';
12-
deploy_static_view_files='';
13-
for var in "$@"
14-
do
15-
if [ "${var}" == "reinstall" ]; then
16-
reinstall=true;
17-
fi
18-
if [ "${var}" == "with_sample_data" ]; then
19-
with_sample_data=true;
20-
fi
21-
if [ "${var}" == "deploy_static_view_files" ]; then
22-
deploy_static_view_files=true;
23-
fi
24-
done
25-
267
# Determine external IP address
278
set +x
289
IP=`ifconfig eth1 | grep inet | awk '{print $2}' | sed 's/addr://'`
@@ -42,11 +23,16 @@ fi
4223
# Setup Apache
4324
apt-get install -y apache2
4425
a2enmod rewrite
26+
27+
# Make suer Apache is run from 'vagrant' user to avoid permission issues
28+
sed -i 's/www-data/vagrant/g' /etc/apache2/envvars
29+
30+
# Enable Magento virtual host
4531
apache_config="/etc/apache2/sites-available/magento2.conf"
4632
cp /vagrant/magento2.vhost.conf ${apache_config}
4733
sed -i "s/<host>/${HOST}/g" ${apache_config}
48-
# Enable Magento virtual host
4934
a2ensite magento2.conf
35+
5036
# Disable default virtual host
5137
sudo a2dissite 000-default
5238

@@ -60,6 +46,9 @@ if [ ! -f /etc/php5/cli/conf.d/20-mcrypt.ini ]; then
6046
fi
6147
echo "date.timezone = America/Chicago" >> /etc/php5/cli/php.ini
6248

49+
# Configure XDebug
50+
echo "xdebug.max_nesting_level=200" >> /etc/php5/cli/conf.d/20-xdebug.ini
51+
6352
# Restart Apache
6453
service apache2 restart
6554

@@ -69,9 +58,12 @@ debconf-set-selections <<< 'mysql-server mysql-server/root_password_again passwo
6958
apt-get install -q -y mysql-server-5.6 mysql-client-5.6
7059

7160
# Setup Composer
72-
apt-get install -y git
7361
if [ ! -f /usr/local/bin/composer ]; then
7462
cd /tmp
7563
curl -sS https://getcomposer.org/installer | php
7664
mv composer.phar /usr/local/bin/composer
7765
fi
66+
67+
# Set permissions to allow Magento codebase upload by Vagrant provision script
68+
chown -R vagrant:vagrant /var/www
69+
chmod -R 755 /var/www

Diff for: ‎install_magento.sh

+64-89
Original file line numberDiff line numberDiff line change
@@ -20,99 +20,74 @@ if [ -z ${HOST} ]; then
2020
set -x
2121
fi
2222

23-
# Install Magento code base
24-
# Create Magento root dir
25-
magento_dir="/var/www/magento2"
23+
magento_dir="/var/www/magento2ce"
24+
cd ${magento_dir}
25+
26+
# Clear cache
27+
mv var/.htaccess .var_htaccess.back && rm -rf var/* && mv .var_htaccess.back var/.htaccess
28+
mv pub/static/.htaccess pub/static_htaccess.back && rm -rf pub/static/* && mv pub/static_htaccess.back pub/static/.htaccess
29+
cd "${magento_dir}/dev/tests/integration" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp/* && mv tmp_gitignore.back tmp/.gitignore
30+
cd "${magento_dir}/dev/tests/unit" && rm -rf tmp/*
31+
32+
# Remove configuration files
33+
rm -f "${magento_dir}/app/etc/config.php"
34+
rm -f "${magento_dir}/app/etc/env.php"
2635

2736
# Create DB
2837
db_name="magento"
38+
mysql -u root -ppassword -e "drop database if exists ${db_name}; create database ${db_name};"
39+
mysql -u root -ppassword -e "GRANT ALL ON ${db_name}.* TO magento@localhost IDENTIFIED BY 'magento';"
2940

30-
# Install Magento code base
31-
# Create Magento root dir
32-
magento_dir="/var/www/magento2"
33-
if [ ! -d "${magento_dir}/app/code/Magento" ]; then
34-
if [ ! -d ${magento_dir} ]; then
35-
mkdir ${magento_dir}
36-
fi
37-
chown -R www-data:www-data ${magento_dir}
38-
chmod -R 775 ${magento_dir}
39-
usermod -a -G www-data vagrant #required to allow files modification via SSH
40-
echo "
41-
1. To finish Magento installation, please create new PHPStorm project using 'magento2ce' directory on your host
42-
(this directory should already contain Magento repository cloned earlier)
41+
# Install Magento application
42+
cd ${magento_dir}
43+
github_token="/vagrant/local.config/github.oauth.token"
44+
if [ -f ${github_token} ]; then
45+
set +x
46+
echo "Installing GitHub OAuth token from ${github_token}..."
47+
composer config -g github-oauth.github.com `cat ${github_token}`
48+
set -x
49+
composer install
50+
else
51+
composer install --prefer-source
52+
fi
4353

44-
2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration.md
45-
to set up synchronization in PHPStorm (or using rsync) with ${magento_dir} directory and upload your project
54+
admin_frontame="admin"
55+
install_cmd="./bin/magento setup:install \
56+
--db-host=localhost \
57+
--db-name=magento \
58+
--db-user=magento \
59+
--db-password=magento \
60+
--backend-frontname=${admin_frontame} \
61+
--base-url=http://${HOST}/ \
62+
--language=en_US \
63+
--timezone=America/Chicago \
64+
--currency=USD \
65+
--admin-lastname=Admin \
66+
--admin-firstname=Admin \
67+
--admin-email=admin@example.com \
68+
--admin-user=admin \
69+
--admin-password=123123q \
70+
--cleanup-database \
71+
--use-rewrites=1"
72+
chmod +x bin/magento
73+
php ${install_cmd}
74+
75+
chown -R vagrant:vagrant ${magento_dir}
76+
77+
# Enable Magento cron jobs
78+
echo "*/1 * * * * php ${magento_dir}/bin/magento cron:run &" | crontab -u vagrant -
4679

47-
3. Then go to 'vagrant-magento' directory on the host (created earlier)
48-
and run 'vagrant provision --provision-with install_magento' in command line"
49-
else
50-
# Clear cache
51-
cd ${magento_dir}
52-
# Clear var
53-
mv var/.htaccess .var_htaccess.back && rm -rf var/* && mv .var_htaccess.back var/.htaccess
54-
# Clear pub/statics
55-
mv pub/static/.htaccess pub/static_htaccess.back && rm -rf pub/static/* && mv pub/static_htaccess.back pub/static/.htaccess
56-
# Clear integration tests tmp
57-
cd "${magento_dir}/dev/tests/integration" && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp/* && mv tmp_gitignore.back tmp/.gitignore
58-
# Clear unit tests tmp
59-
cd "${magento_dir}/dev/tests/unit" && rm -rf tmp/*
60-
61-
# Remove configuration files
62-
rm -f "${magento_dir}/app/etc/config.php"
63-
rm -f "${magento_dir}/app/etc/env.php"
64-
65-
66-
mysql -u root -ppassword -e "drop database if exists ${db_name}; create database ${db_name};"
67-
mysql -u root -ppassword -e "GRANT ALL ON ${db_name}.* TO magento@localhost IDENTIFIED BY 'magento';"
68-
69-
cd ${magento_dir}
70-
usermod -a -G vagrant www-data #required to allow files modification by Apache, if they were uploaded from the host
71-
72-
# Install Magento application
73-
github_token="/vagrant/local.config/github.oauth.token"
74-
if [ -f ${github_token} ]; then
75-
set +x
76-
echo "Installing GitHub OAuth token from ${github_token}..."
77-
composer config -g github-oauth.github.com `cat ${github_token}`
78-
set -x
79-
composer install
80-
else
81-
composer install --prefer-source
82-
fi
83-
84-
admin_frontame="admin"
85-
install_cmd="./bin/magento setup:install \
86-
--db-host=localhost \
87-
--db-name=magento \
88-
--db-user=magento \
89-
--db-password=magento \
90-
--backend-frontname=${admin_frontame} \
91-
--base-url=http://${HOST}/ \
92-
--language=en_US \
93-
--timezone=America/Chicago \
94-
--currency=USD \
95-
--admin-lastname=Admin \
96-
--admin-firstname=Admin \
97-
--admin-email=admin@example.com \
98-
--admin-user=admin \
99-
--admin-password=123123q \
100-
--cleanup-database \
101-
--use-rewrites=1"
102-
chmod +x bin/magento
103-
php ${install_cmd}
104-
105-
chown -R www-data:www-data .
106-
usermod -a -G www-data vagrant #required to allow files modification via SSH
107-
108-
# Enable Magento cron jobs
109-
echo "*/1 * * * * php ${magento_dir}/bin/magento cron:run &" | crontab -u www-data -
80+
set +x
81+
echo "
82+
Magento application was deployed in ${magento_dir} and installed successfully
83+
Access storefront at http://${HOST}/
84+
Access admin panel at http://${HOST}/${admin_frontame}/
11085
111-
set +x
112-
echo "Magento application was deployed in ${magento_dir} and installed"
113-
echo "Access front store at http://${HOST}/"
114-
echo "Access admin panel at http://${HOST}/${admin_frontame}/"
115-
if [ ${HOST} != ${IP} ]; then
116-
echo "Don't forget to update your 'hosts' file with '${IP} ${HOST}'"
117-
fi
118-
fi
86+
Don't forget to update your 'hosts' file with '${IP} ${HOST}'
87+
88+
[Optional] To finish developer environment set up:
89+
1. Please create new PHPStorm project using 'magento2ce' directory on your host
90+
(this directory should already contain Magento repository cloned earlier)
91+
92+
2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration.md
93+
to set up synchronization in PHPStorm (or using rsync) with ${magento_dir} directory"

Diff for: ‎magento2.vhost.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<VirtualHost *:80>
2-
DocumentRoot "/var/www/magento2"
2+
DocumentRoot "/var/www/magento2ce"
33
ServerName magento2.vagrant
4-
<Directory /var/www/magento2>
4+
<Directory /var/www/magento2ce>
55
Options Indexes FollowSymLinks
66
AllowOverride All
77
Order allow,deny

0 commit comments

Comments
 (0)
This repository has been archived.