forked from unkn0w/noobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chce_LEMP.sh
executable file
·67 lines (48 loc) · 1.72 KB
/
chce_LEMP.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
#!/bin/bash
# LEMP = Linux + Nginx + MySQL (MariaDB) + PHP
# Autor: Jakub Rolecki
# Sprawdz uprawnienia przed wykonaniem skryptu instalacyjnego
if [[ $EUID -ne 0 ]]; then
echo -e "W celu instalacji tego pakietu potrzebujesz wyzszych uprawnien! Uzyj polecenia \033[1;31msudo ./chce_LEMP.sh\033[0m lub zaloguj sie na konto roota i wywolaj skrypt ponownie."
exit 1
fi
apt update
apt install -y software-properties-common
# Repozytoria zewnętrzne z PHP i najnowszymi wydaniami nginx
add-apt-repository -y ppa:ondrej/php
add-apt-repository -y ppa:nginx/stable
# Aktualizacja repozytoriow
apt update
# nginx + najpopularniejsze moduły do PHP
apt install -y nginx php php-fpm php-zip php-xml php-sqlite3 php-pgsql php-mysql php-mcrypt php-mbstring php-intl php-gd php-curl php-cli php-bcmath
# dodanie MariaDB (klient i serwer)
apt install -y mariadb-server mariadb-client
# utworzenie konfiguracji wspierającej PHP w nginx
config=$(cat <<EOF
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
server_name _;
location / {
try_files \$uri \$uri/ =404;
}
location ~ \.php\$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
}
EOF
)
# aktualizacja konfiguracji
echo "$config" >/etc/nginx/sites-available/default
# Dowód na działanie PHP
echo '<?php echo "2 + 2 = ".(2+2); ' >/var/www/html/index.php
# Serwer będzie się przedstawiał jako "Nginx" - bez wersji serwera
sed -e 's/# server_tokens off;/server_tokens off;/' -i /etc/nginx/nginx.conf
# Dodanie nginxa do autostartu
systemctl enable --now nginx
# Przeładowanie nginxa
systemctl reload nginx
systemctl status nginx