-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_deb.sh
65 lines (48 loc) · 1.7 KB
/
server_deb.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
#!/usr/bin/env bash
set -e
## Install Basics
apt-get update &> /dev/null
apt-get install -y -qq nginx php7.0-fpm php7.0-cli php7.0-mysql php7.0-curl php7.0-xml php7.0-gd php7.0-intl php7.0-imap &> /dev/null
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password root"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password root"
apt-get install -y -qq mysql-server &> /dev/null
## Configure MySQL
! read -d '' MYSQLTEMPLATE << EOF
[client]
host=localhost
user=root
password=root
EOF
echo "$MYSQLTEMPLATE" > /root/.my.cnf
if [ ! -z "$HOME" ]; then
echo "$MYSQLTEMPLATE" > $HOME/.my.cnf
fi
mysql -e "CREATE DATABASE IF NOT EXISTS helpspot_db CHARSET utf8mb4 collate utf8mb4_unicode_ci;"
## Configure Nginx
## TODO: php-fpm parameters include file different per version
## debian/ubuntu/nginx installed
! read -d '' NGINXTEMPLATE << EOF
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/helpspot;
index index.html index.htm index.php;
server_name _;
location / {
try_files \$uri \$uri/ /index.php\$is_args\$args;
}
location ~ \\.php\$ {
# nginx 1.10.* / ubuntu 16.04 default
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# debian 8 default
## include snippets/fastcgi-php.conf;
## fastcgi_pass unix:/var/run/php7.0-fpm.sock;
}
}
EOF
rm /etc/nginx/sites-enabled/default
echo "$NGINXTEMPLATE" > /etc/nginx/sites-available/helpspot
ln -s /etc/nginx/sites-available/helpspot /etc/nginx/sites-enabled/helpspot
service nginx reload &> /dev/null
echo "Complete!"