-
Notifications
You must be signed in to change notification settings - Fork 29
/
domain-add.sh
executable file
·53 lines (38 loc) · 1.47 KB
/
domain-add.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
#!/usr/bin/env bash
echo "Insert your domain address..."
read domain
echo "Insert directory path where the domain is pointed..."
read root_path
echo "Insert your SSL keys file name (collected from certbot)..."
read ssl_key_name
echo "Select the active PHP version..."
php_versions=( 8.1 8.2 8.3 8.4 )
select php_version in "${php_versions[@]}"; do
echo "You have chosen $php_version"
break
done
echo "Select a configuration..."
configurations=( domain-with-www domain-without-www www-domain-with-cloudflare non-www-domain-with-cloudflare )
select config in "${configurations[@]}"; do
echo "You have chosen $config"
break
done
echo "Creating nginx virtual host file..."
sudo cp ${PWD}/nginx/${config}.conf /etc/nginx/sites-available/${domain}.conf
sudo sed -i "s%version%${php_version}%g" /etc/nginx/sites-available/${domain}.conf
echo "PHP version set..."
sudo sed -i "s%domain%${domain}%g" /etc/nginx/sites-available/${domain}.conf
echo "Domain name set..."
sudo sed -i "s%root_path%${root_path}%g" /etc/nginx/sites-available/${domain}.conf
echo "Root path set..."
sudo sed -i "s%ssl_key_name%${ssl_key_name}%g" /etc/nginx/sites-available/${domain}.conf
echo "SSL set..."
if [[ ! -e /etc/nginx/sites-enabled/${domain}.conf ]]
then
sudo ln -s /etc/nginx/sites-available/${domain}.conf /etc/nginx/sites-enabled/${domain}.conf
echo "Symbolic link created..."
fi
echo "Checking configuration..."
sudo nginx -t
echo "Restarting nginx server..."
sudo service nginx restart