-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
118 lines (103 loc) · 2.79 KB
/
install.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
#!/bin/bash
# Define variable
ROOT_DIR=$(pwd)
VHOST='magento2.conf'
DOMAIN='magento2.local'
MAGENTO_COMPOSER_USER='magento_public_key'
MAGENTO_COMPOSER_PASS='magento_private_key'
FIRSTNAME='Firstname'
LASTNAME='Lastname'
EMAIL='[email protected]'
DB_HOST='localhost'
DB_NAME='magento2'
DB_USER='root'
DB_PASSWORD='root'
ENDC=`tput setaf 7`
RED=`tput setaf 1`
GREEN=`tput setaf 2`
BLUE=`tput setaf 3`
init() {
echo $GREEN 'Install and setup magento 2 project' $ENDC
echo $BLUE 'Prerequires: \nNginx \nMySQL 5.6 \nPHP 7.0 \nNodejs 0.10.x' $ENDC
echo $GREEN'Are you sure to continue (y/n)?'$ENDC
read -e TERM
if [[ $TERM = 'n' || $TERM = 'N' ]]; then
exit
fi
git config core.fileMode false
}
setupComposer()
{
echo $GREEN 'Setup Composer' $ENDC
composer config --global --auth http-basic.repo.magento.com $MAGENTO_COMPOSER_USER $MAGENTO_COMPOSER_PASS
composer install
}
setupAcl() {
echo $GREEN 'Setup ownership and permissions for' $ROOT_DIR $ENDC
HTTPDUSER='www-data'
sudo chown -R `whoami`:"$HTTPDUSER" .
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var pub/static pub/media app/etc
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var pub/static pub/media app/etc
find . -type d -exec chmod 775 {} \; && find . -type f -exec chmod 664 {} \;
chmod u+x bin/magento install.sh
}
setupMagento() {
echo $GREEN 'Install Magento 2' $ENDC
php bin/magento setup:install \
--admin-firstname=$FIRSTNAME \
--admin-lastname=$LASTNAME \
--admin-email=$EMAIL \
--admin-user=admin \
--admin-password='admin123' \
--base-url='http://'$DOMAIN \
--backend-frontname=admin \
--db-host=$DB_HOST \
--db-name=$DB_NAME \
--db-user=$DB_USER \
--db-password=$DB_PASSWORD \
--language=en_US \
--currency=USD \
--timezone='Asia/Ho_Chi_Minh' \
--admin-use-security-key=0 \
--session-save=files
}
setupVhost()
{
echo $GREEN 'Setup Nginx virtual host' $ENDC
if [ -s /etc/nginx/conf.d/$VHOST ]; then
sudo rm -rf /etc/nginx/conf.d/$VHOST
fi
sudo cp nginx.conf.sample /etc/nginx/conf.d/$VHOST
sudo sh -c -- "echo '127.0.0.1 ${DOMAIN}' >> /etc/hosts"
}
setupNode() {
echo $GREEN 'Setup Grunt & Nodejs dev dependencies' $ENDC
cp Gruntfile.js.sample Gruntfile.js
cp package.json.sample package.json
npm install -g grunt-cli
npm install --save-dev grunt
npm install
}
setupTask() {
php bin/magento deploy:mode:set developer
php bin/magento module:enable --all
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
}
finish() {
echo $GREEN 'Restart Nginx and PHP service' $ENDC
sudo service php7.0-fpm restart
sudo service nginx restart
echo $GREEN 'Go to' http://$DOMAIN $ENDC
}
init
setupComposer
setupAcl
setupMagento
setupVhost
setupNode
setupTask
finish