-
Notifications
You must be signed in to change notification settings - Fork 3
/
start-wordpress.sh
56 lines (39 loc) · 1.6 KB
/
start-wordpress.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
#!/bin/bash
if [[ $(which docker) && $(docker --version) ]]; then
echo "Docker already installed"
else
echo "Docker not found and installing it"
#Install pre-requisites
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
#Add Docker’s official GPG key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
#Add the Docker repository to APT sources
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
#Update the package database with the Docker packages from the newly added repo
sudo apt-get update
#Install Docker CE
sudo apt-get install -y docker-ce
fi
echo "Docker installed successfully"
#Post Install
sudo groupadd docker
sudo usermod -aG docker "$USER"
sudo systemctl enable docker
if [[ $(which docker-compose) && $(docker-compose --version) ]]; then
echo "Docker Compose already Installed"
else
echo "Docker Compose not there and installing it"
#Install Docker Compose
sudo apt-get install docker-compose
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.28.5/docker-compose-$(uname -s)-$(uname -m)"
#Set Permissions
sudo chmod +x /usr/local/bin/docker-compose
fi
echo "Docker Compose installed successfully"
#Create docker network
#sudo docker network create web
# Add the hostname to /etc/hosts
sudo /bin/sh -c 'echo "127.0.0.1 example.com" >> /etc/hosts'
#Install WordPress using Docker Compose
docker-compose up -d
echo "WordPress installed successfully; Browse example.com to proceed further"