forked from elkarte/Elkarte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-nginx.sh
executable file
·61 lines (48 loc) · 1.43 KB
/
setup-nginx.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
#!/bin/bash
set -e
set -x
DIR=$(dirname "$0")
USER=$(whoami)
ELKARTE_ROOT_PATH=$(realpath "$DIR/../elkarte")
APP_SOCK=$(realpath "$DIR")/php-fpm.sock
# Create and set the php-fpm app sock file with user:group
sudo touch "$APP_SOCK"
sudo chown "$USER:$USER" "$APP_SOCK"
# Nginx config file locations
NGINX_SITE_CONF="/etc/nginx/sites-enabled/default"
NGINX_CONF="/etc/nginx/nginx.conf"
# Install Nginx
sudo apt-get install nginx -qq > /dev/null
sudo service nginx stop
# PHP-FPM file locations
PHP_FPM_BIN="/usr/sbin/php-fpm$PHP_VERSION"
PHP_FPM_CONF="$DIR/php-fpm.conf"
# Create a basic PHP-FPM conf
echo "
[global]
[ci]
user = $USER
group = $USER
listen = $APP_SOCK
listen.mode = 0666
listen.owner = $USER
listen.group = $USER
pm = static
pm.max_children = 2
security.limit_extensions = .php
php_admin_value[memory_limit] = 128M
" > "$PHP_FPM_CONF"
# Add our pool config to PHP-FPM
sudo "$PHP_FPM_BIN" --fpm-config "$DIR/php-fpm.conf"
# Default Nginx conf needs to be updated with correct user
sudo sed -i "s/user www-data;/user $USER;/g" $NGINX_CONF
# Nginx sites enabled conf, we update the one from the repo with correct site, sock, root
sudo cp "$DIR/../.github/nginx.conf" "$NGINX_SITE_CONF"
sudo sed -i \
-e "s/example\.com/127.0.0.1/g" \
-e "s|root /path/to/elkarte;|root $ELKARTE_ROOT_PATH;|g" \
-e "s|/path/to/socket|$APP_SOCK|g" \
$NGINX_SITE_CONF
# Test for debug output and start
sudo nginx -t
sudo service nginx start