-
Notifications
You must be signed in to change notification settings - Fork 0
/
LAMPInstaller
84 lines (59 loc) · 2.32 KB
/
LAMPInstaller
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
#!/bin/bash
# LAMP installer script
# 0 - update the repositories
echo "$(tput setaf 2) updating repositories"
sudo apt update
# 1 - install Apache
echo "$(tput setaf 2)installing Apache ..."
sudo apt install apache2
echo "$(tput setaf 2) apache installation completed"
# create a firewall rule for apache
sudo ufw allow in "Apache"
# 2 - install db server
echo "$(tput setaf 2) database installation ..."
PS3='Please select wich database you want to install: '
options=("MySQL" "MongoDb")
select opt in "${options[@]}"
do
case $opt in
"MySQL")
echo "$(tput setaf 2) installing MySQL ..."
sudo apt install mysql-server
echo "$(tput setaf 2) MySQL installation completed"
break
;;
"MongoDb")
echo "$(tput setaf 2) installing MongoDb ..."
sudo apt install -y mongodb
# Create a list file for MongoDB
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
# Reload packages
sudo apt-get update
# install
sudo apt-get install -y mongodb-org
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
echo "$(tput setaf 2) MongoDB installation completed"
# check mongodb instance
mongo --eval 'db.runCommand({ connectionStatus: 1 })'
# start and enable mongodb
echo "$(tput setaf 2) starting and enable MongoDB"
sudo systemctl start mongodb
sudo systemctl enable mongodb
break
;;
*) echo "invalid option $REPLY";;
esac
done
# 3 - install php
echo "$(tput setaf 2) installing PHP ..."
sudo apt install php libapache2-mod-php php-mysql
echo "$(tput setaf 2) PHP installation completed"
# check installed version
echo "$(tput setaf 2) checking PHP version ..."
php -v
# finsih
echo "$(tput setaf 2) script complete"