forked from andreapollastri/cipi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo.sh
195 lines (174 loc) · 4.89 KB
/
go.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
#!/bin/bash
DBPASS=$(openssl rand -base64 32)
clear
echo "Wait..."
sleep 3s
echo -e "\n"
sudo apt-get -y install dnsutils
#VARS
IP=$(dig +short myip.opendns.com @resolver1.opendns.com)
#START
sudo mkdir /cipi/
sudo mkdir /cipi/
sudo chmod o-r /cipi
clear
echo "Installation has been started... It may takes some time! Hold on :)"
sleep 6s
echo -e "\n"
#PHP7 PPA
sudo apt-get -y install python-software-properties
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y universe
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
clear
echo "Repositories: OK!"
sleep 3s
echo -e "\n"
#REPO UPDATES
sudo apt-get update
#LAMP INSTALLATION
sudo apt -y purge libzip4
wget http://ftp.it.debian.org/debian/pool/main/libz/libzip/libzip4_1.5.1-4_amd64.deb
sudo dpkg -i libzip4_1.5.1-4_amd64.deb
sudo apt-get -y install rpl dos2unix fail2ban openssl apache2 php7.3 php7.3-common php7.3-intl php7.3-cli php7.3-fpm php-pear php7.3-curl php7.3-dev php7.3-gd php7.3-mbstring php-gettext php7.3-zip php7.3-mysql php7.3-xml libmcrypt-dev zip unzip mysql-client
clear
echo "Base installation: OK!"
sleep 3s
echo -e "\n"
#FIREWALL
sudo ufw --force-enable reset
clear
echo "Firewall rules: OK!"
sleep 3s
echo -e "\n"
#MYSQL INSTALLATION AND PASSWORD SET
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password $DBPASS"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $DBPASS"
sudo apt-get -y install mysql-server
clear
echo "MySql service: OK!"
sleep 3s
echo -e "\n"
#SERVICE RESTART AND CONFIGURATION FIXING
echo -e "\n"
sudo a2enmod rewrite
echo -e "\n"
sudo a2enmod proxy_fcgi setenvif
echo -e "\n"
sudo a2enconf php7.3-fpm
echo -e "\n"
sudo rpl -i -w "AllowOverride None" "AllowOverride All" /etc/apache2/apache2.conf
echo -e "\n"
sudo service apache2 restart && apache2 reload && service mysql restart > /dev/null
echo -e "\n"
php -v
if [ $? -ne 0 ]; then
echo "Please Check the Install Services, There is some $(tput bold)$(tput setaf 1)Problem$(tput sgr0)"
else
echo "Installed Services run $(tput bold)$(tput setaf 2)Sucessfully$(tput sgr0)"
fi
clear
echo "PHP-FPM configuration: OK!"
sleep 3s
echo -e "\n"
sudo unlink /etc/apache2/sites-available/000-default.conf
CONF=/etc/apache2/sites-available/000-default.conf
sudo touch $CONF
sudo cat > "$CONF" <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /cipi/public/
<Directory />
Order allow,deny
Options FollowSymLinks
Allow from all
AllowOverRide All
Require all granted
SetOutputFilter DEFLATE
</Directory>
<Directory /cipi/public>
Order allow,deny
Options FollowSymLinks
Allow from all
AllowOverRide All
Require all granted
SetOutputFilter DEFLATE
</Directory>
</VirtualHost>
EOF
#RESTART
sudo a2ensite 000-default.conf
sudo service apache2 reload
clear
echo "Default virtualhost: OK!"
sleep 3s
echo -e "\n"
#COMPOSER INSTALLATION
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
clear
echo "Composer installation: OK!"
sleep 3s
echo -e "\n"
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
PHPINI=/etc/php/7.3/fpm/conf.d/cipi.ini
sudo touch $PHPINI
sudo cat > "$PHPINI" <<EOF
memory_limit = 256M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 180
max_input_time = 180
EOF
sudo service php7.3-fpm restart
sudo service apache2 restart
sudo systemctl restart apache2.service
clear
echo "Optimization: OK!"
sleep 3s
echo -e "\n"
#APPLICATION INSTALLATION
/usr/bin/mysql -u root -p$DBPASS <<EOF
CREATE DATABASE IF NOT EXISTS cipi;
EOF
composer create-project andreapollastri/cipi /cipi/
cd /cipi/ && sudo cp .env.example .env
sudo rpl -i -w "DB_USERNAME=dbuser" "DB_USERNAME=root" /cipi/.env
sudo rpl -i -w "DB_PASSWORD=dbpass" "DB_PASSWORD=$DBPASS" /cipi/.env
sudo rpl -i -w "DB_DATABASE=dbname" "DB_DATABASE=cipi" /cipi/.env
sudo rpl -i -w "APP_URL=http://localhost" "APP_URL=http://$IP" /cipi/.env
cd /cipi/ && php artisan key:generate
cd /cipi/ && php artisan storage:link
cd /cipi/ && php artisan migrate --seed --force
sudo chmod -R o+rx /cipi/
sudo chmod -R 777 /cipi/storage/
sudo chmod -R 777 /cipi/public/storage/
clear
echo "Application installation: OK!"
sleep 3s
echo -e "\n"
#FINAL MESSAGGE
clear
echo ""
echo " _____ _ _ "
echo " / ____(_) (_)"
echo "| | _ _ __ _ "
echo "| | | | _ \| |"
echo "| |____| | |_) | |"
echo " \_____|_| .__/|_|"
echo " | | "
echo " |_| "
echo ""
echo "<\ SETUP COMPLETE >"
echo ""
echo "URL: http://$IP"
echo "USER: [email protected]"
echo "PASS: 12345678"
echo ""
echo "Enjoy Cipi :)"
echo ""