This repository has been archived by the owner on May 12, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tnw-install-nginx
executable file
·48 lines (39 loc) · 1.32 KB
/
tnw-install-nginx
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
#!/usr/bin/env bash
function tnw-tpl {
sed \
-e "s|{WP_CORE_DIR}|$WP_CORE_DIR|g" \
-e "s|{WP_PORT}|$WP_PORT|g" \
-e "s|{TNW_NGINX_DIR}|$TNW_NGINX_DIR|g" \
-e "s|{USER}|$USER|g" \
-e "s|{PHP_VERSION}|$PHP_VERSION|g" \
-e "s|{PORT}|$PORT|g" \
-e "s|{SERVER}|$SERVER|g" \
< $1 > $2
}
function tnw-install-nginx {
TNW_TPL_DIR=${TNW_TPL_DIR-$HOME/.composer/vendor/typisttech/travis-nginx-wordpress/tpl}
TNW_NGINX_DIR=${TNW_NGINX_DIR-$HOME/nginx}
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
WP_PORT=${WP_PORT-8080}
USER=$(whoami)
PHP_VERSION=$(phpenv version-name)
PORT=9000
SERVER="/tmp/php.sock"
# Make some working directories.
mkdir -p "$TNW_NGINX_DIR"
mkdir -p "$TNW_NGINX_DIR/sites-enabled"
mkdir -p "$TNW_NGINX_DIR/var"
PHP_FPM_BIN="$HOME/.phpenv/versions/$PHP_VERSION/sbin/php-fpm"
PHP_FPM_CONF="$TNW_NGINX_DIR/php-fpm.conf"
# Build the php-fpm.conf.
tnw-tpl "$TNW_TPL_DIR/php-fpm.tpl.conf" "$PHP_FPM_CONF"
# Start php-fpm
"$PHP_FPM_BIN" --fpm-config "$PHP_FPM_CONF"
# Build the default nginx config files.
tnw-tpl "$TNW_TPL_DIR/nginx.tpl.conf" "$TNW_NGINX_DIR/nginx.conf"
tnw-tpl "$TNW_TPL_DIR/fastcgi.tpl.conf" "$TNW_NGINX_DIR/fastcgi.conf"
tnw-tpl "$TNW_TPL_DIR/default-site.tpl.conf" "$TNW_NGINX_DIR/sites-enabled/default-site.conf"
# Start nginx.
nginx -c "$TNW_NGINX_DIR/nginx.conf"
}
tnw-install-nginx