-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbootstrap.sh
202 lines (172 loc) · 6.52 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env bash
# This script can be used to perform any sort of command line actions to setup your box.
# This includes installing software, importing databases, enabling new sites, pulling from
# remote servers, etc.
# update
echo "########################"
echo "##### UPDATING APT #####"
echo "########################"
apt-get update
# Install Apache
echo "#############################"
echo "##### INSTALLING APACHE #####"
echo "#############################"
apt-get -y install apache2
# Creating folder
echo "#######################################"
echo "##### MAGENTO2 FOLDER PERMISSIONS #####"
echo "#######################################"
chmod 0777 -R /var/www/html/magento
# enable modrewrite
echo "#######################################"
echo "##### ENABLING APACHE MOD-REWRITE #####"
echo "#######################################"
a2enmod rewrite
# append AllowOverride to Apache Config File
echo "#######################################"
echo "##### CREATING APACHE CONFIG FILE #####"
echo "#######################################"
echo "
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/magento2
ServerName magento2.dev
ServerAlias www.magento2.dev
<Directory '/var/www/html/magento2'>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
" > /etc/apache2/sites-available/magento2.conf
echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Enabling Site
echo "##################################"
echo "##### Enabling Magento2 Site #####"
echo "##################################"
a2ensite magento2.conf
# Setting Locales
echo "###########################"
echo "##### Setting Locales #####"
echo "###########################"
locale-gen en_US en_US.UTF-8 pl_PL pl_PL.UTF-8
dpkg-reconfigure locales
# Install MySQL 5.6
echo "############################"
echo "##### INSTALLING MYSQL #####"
echo "############################"
export DEBIAN_FRONTEND=noninteractive
apt-get -q -y install mysql-server-5.6 mysql-client-5.6
# Create Database instance
echo "#############################"
echo "##### CREATING DATABASE #####"
echo "#############################"
mysql -u root -e "create database magento;"
# Install PHP 7.0
echo "##########################"
echo "#### INSTALLING PHP 7.0 ##"
echo "##########################"
apt-get -q -y install python-software-properties
add-apt-repository ppa:ondrej/php
apt-get -q -y update
apt-get -q -y purge php5-fpm
apt-get -q -y install php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-gd php7.0-mysql php7.0-bz2 php7.0-dev
echo "################################"
echo "#INSTALLING phpMyAdmin 4.5.3.1 #"
echo "################################"
wget https://files.phpmyadmin.net/phpMyAdmin/4.5.3.1/phpMyAdmin-4.5.3.1-all-languages.zip -P /var/www/html/
apt-get -q -y install unzip
unzip /var/www/html/phpMyAdmin-4.5.3.1-all-languages.zip -d /var/www/html/
mv /var/www/html/phpMyAdmin-4.5.3.1-all-languages/ /var/www/html/phpmyadmin/
echo "################################"
echo "#### CONFIGURING phpMyAdmin ####"
echo "################################"
cp /var/www/html/phpmyadmin/config.sample.inc.php /var/www/html/phpmyadmin/config.inc.php
sed -i "s/\['AllowNoPassword'\] = false;/\['AllowNoPassword'\] = true;/g" /var/www/html/phpmyadmin/config.inc.php
/etc/init.d/apache2 restart
# PHP extensions
echo "########################"
echo "##### PHP EXTENSIONS ###"
echo "########################"
apt-get -q -y install php7.0-xml
apt-get -q -y install php7.0-mcrypt
apt-get -q -y install php7.0-intl
apt-get -q -y install php7.0-mbstring
apt-get -q -y install php7.0-zip
apt-get -q -y install php-pear
apt-get -q -y install libcurl3-openssl-dev
pecl install pecl_http
/etc/init.d/apache2 restart
# Set PHP Timezone
echo "########################"
echo "##### PHP TIMEZONE #####"
echo "########################"
echo "date.timezone = America/New_York" >> /etc/php/7.0/cli/php.ini
# Set Pecl php_ini location
echo "##########################"
echo "##### CONFIGURE PECL #####"
echo "##########################"
pear config-set php_ini /etc/php/7.0/apache2/php.ini
# Install Xdebug
echo "##########################"
echo "##### INSTALL XDEBUG #####"
echo "##########################"
pecl install xdebug
# Install Pecl Config variables
echo "############################"
echo "##### CONFIGURE XDEBUG #####"
echo "############################"
echo "xdebug.remote_enable = 1" >> /etc/php/7.0/apache2/php.ini
echo "xdebug.remote_connect_back = 1" >> /etc/php/7.0/apache2/php.ini
# Install Git
echo "##########################"
echo "##### INSTALLING GIT #####"
echo "##########################"
apt-get -y install git
# Composer Installation
echo "###############################"
echo "##### INSTALLING COMPOSER #####"
echo "###############################"
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# Set Ownership and Permissions
echo "#############################################"
echo "##### SETTING OWNERSHIP AND PERMISSIONS #####"
echo "#############################################"
chown -R www-data /var/www/html/magento2/
find /var/www/html/magento2/ -type d -exec chmod 700 {} \;
find /var/www/html/magento2/ -type f -exec chmod 600 {} \;
# Magento 2 Installation from composer
echo "############################################"
echo "##### INSTALLING COMPOSER DEPENDENDIES #####"
echo "############################################"
if [ -z "$1" ]
then
echo "################################################################"
echo "##### NO GITHUB API TOKEN. SKIPPING COMPOSER INSTALLATION #####"
echo "################################################################"
else
composer config -g github-oauth.github.com $1
cd /var/www/html/magento2/
composer config repositories.magento composer http://packages.magento.com
composer require magento/sample-bundle-all:1.0.0
fi
# Restart apache
echo "#############################"
echo "##### RESTARTING APACHE #####"
echo "#############################"
service apache2 restart
# Post Up Message
echo "Magento2 Vagrant Box ready!"
if [ -z "$1" ]
then
echo "Final installation instructions:"
echo "run 'vagrant ssh'"
echo "run 'cd /var/www/html/magento2/'"
echo "run 'composer install'"
echo "When prompted, enter your github API credentials"
echo "Afterward finish installation."
fi
echo "Go to http://192.168.33.10/magento2/setup/ to finish installation."
echo "If you configured your hosts file, go to http://www.magento2.dev/setup/"