-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall
executable file
·83 lines (66 loc) · 3.17 KB
/
install
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
#!/usr/bin/env bash
set -e
read -p "Which PHP version should be installed? " -i "8.1" -e PHP_VERSION
function msg {
echo -e "\e[32m$1\e[39m"
}
if [ ! -L /usr/local/bin/site-manager ]; then
msg "Making site-manager globally accessible"
echo "sudo ln -s $(pwd)/site-manager /usr/local/bin/site-manager"
sudo ln -s $(pwd)/site-manager /usr/local/bin/site-manager
fi
if ! which add-apt-repository > /dev/null; then
sudo apt-get install software-properties-common -y
fi
if ! ls /etc/apt/sources.list.d/ | grep nginx | grep stable > /dev/null; then
msg "Adding ppa for nginx"
sudo add-apt-repository ppa:ondrej/nginx -y
fi
if ! ls /etc/apt/sources.list.d/ | grep ondrej | grep php > /dev/null; then
msg "Adding ppa for php"
LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php -y
fi
sudo apt-get update
msg "Installing nginx"
sudo apt-get install -y nginx
msg "Installing certbot"
sudo apt-get install -y certbot python3-certbot-nginx
msg "Installing php"
sudo apt-get install -y php${PHP_VERSION}-fpm php${PHP_VERSION}-cli php${PHP_VERSION}-mysql php${PHP_VERSION}-pgsql php${PHP_VERSION}-curl php${PHP_VERSION}-redis php${PHP_VERSION}-mbstring php${PHP_VERSION}-gd php${PHP_VERSION}-xml php${PHP_VERSION}-zip php${PHP_VERSION}-intl php${PHP_VERSION}-readline php${PHP_VERSION}-opcache
msg "Setting up nginx"
if [ -f /etc/nginx/sites-enabled/default ]; then
sudo rm /etc/nginx/sites-enabled/default
fi
if [ -f /etc/nginx/sites-available/default ]; then
sudo rm /etc/nginx/sites-available/default
fi
if ! grep 'fastcgi_param HTTP_PROXY "";' /etc/nginx/fastcgi.conf > /dev/null; then
echo 'fastcgi_param HTTP_PROXY "";' | sudo tee -a /etc/nginx/fastcgi.conf 1> /dev/null
fi
if ! grep 'fastcgi_param HTTP_PROXY "";' /etc/nginx/fastcgi_params > /dev/null; then
echo 'fastcgi_param HTTP_PROXY "";' | sudo tee -a /etc/nginx/fastcgi_params 1> /dev/null
fi
if ! grep 'proxy_set_header Proxy "";' /etc/nginx/proxy_params > /dev/null; then
echo 'proxy_set_header Proxy "";' | sudo tee -a /etc/nginx/proxy_params 1> /dev/null
fi
msg "Setting up php"
sudo sed -i "s/log_errors = .*/log_errors = On/" /etc/php/${PHP_VERSION}/cli/php.ini
sudo sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/${PHP_VERSION}/cli/php.ini
sudo sed -i "s/display_errors = .*/display_errors = Off/" /etc/php/${PHP_VERSION}/cli/php.ini
sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/${PHP_VERSION}/cli/php.ini
sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/${PHP_VERSION}/cli/php.ini
sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/${PHP_VERSION}/fpm/php.ini
sudo sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/${PHP_VERSION}/fpm/php.ini
sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/${PHP_VERSION}/fpm/php.ini
if [ ! -d /var/log/sites ]; then
sudo mkdir /var/log/sites
fi
sudo chown www-data:www-data /var/log/sites
# Install composer
msg "Installing composer"
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# Restart services
msg "Restarting nginx and php${PHP_VERSION}-fpm"
sudo service nginx restart
sudo service php${PHP_VERSION}-fpm restart