Commit e786d6ec authored by Edi Septriyanto's avatar Edi Septriyanto Committed by GitHub

Merge pull request #22 from joglomedia/1.2.0

1.2.0 several bugs fix and enhancements
parents 43f0a7e6 16629565
......@@ -6,6 +6,9 @@
# Server IP address, leave blank for auto detection.
IP_SERVER=""
# Default account username.
LEMPER_USERNAME="lemper"
# Password for default lemper account,
# leave blank for auto generated secure password.
LEMPER_PASSWORD=""
......@@ -24,6 +27,9 @@ FORCE_REMOVE=false
# Dry run install, true for testing only.
DRYRUN=false
# Build directorty.
BUILD_DIR="/usr/local/src/lemper"
# Logging for installation process.
LOGGING=true
......@@ -73,9 +79,12 @@ NGX_HEADERS_MORE=true
NGX_HTTP_AUTH_PAM=false
NGX_HTTP_GEOIP2=false
NGX_HTTP_SUBS_FILTER=false
NGX_MEMCACHED=true
NGX_NAXSI=true
NGX_NCHAN=false
NGX_PAGESPEED=true
NGX_REDIS2=true
NGX_RTMP=false
NGX_UPSTREAM_FAIR=false
NGX_VTS=true
NGX_WEB_DAV_EXT=false
......@@ -94,6 +103,7 @@ PHP_VERSION="7.3"
PHP_LOADER="ioncube"
PHP_IMAGEMAGICK=false
PHP_PHALCON_INSTALLER="repo"
[mysql]
INSTALL_MYSQL=true
......@@ -101,7 +111,7 @@ MYSQL_SERVER="mariadb"
MYSQL_VERSION="10.4"
#MYSQL_ROOT_PASS=""
#MARIABACKUP_USER="lempersh"
#MARIABACKUP_USER="lemperdb"
#MARIABACKUP_PASS=""
[memcached]
......
......@@ -54,7 +54,7 @@ if ($http_cookie ~* "(comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_n
}
# Skip cache on WooCommerce pages
if ($request_uri ~* "(/cart*|/my-account*|/checkout*|/addons*)") {
if ($request_uri ~* "(/addons.*|/basket.*|/cart.*|/checkout.*|/my-account.*|/shop.*)") {
set $skip_cache 1;
}
......
-----BEGIN CERTIFICATE-----
MIIFIjCCBAqgAwIBAgIRAPTSpmfYKQriz3U34Q9umCwwDQYJKoZIhvcNAQEFBQA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lYXtHo10d8AQUkaS0xUhAoGAOI8FpRk+NVJwGckeOkWc
h3Z0tOMcL08mUeJrGK0OsqALpJIOY96Ieic+TiwXmiEcptefkPmQzRyMZaarWvld
hrMcv4f4QXAVTtqeonfJyv+a1DVdrnOadNukNZcdyoy4kvaecNP0x6hKf0rCZhL/
FXZU+CQ730C9zN3kU91kNO8=
-----END PRIVATE KEY-----
......@@ -87,13 +87,13 @@ case "${1}" in
### Clean-up server ###
echo ""
if [ -f scripts/cleanup_server.sh ]; then
./scripts/cleanup_server.sh
. ./scripts/cleanup_server.sh
fi
### Install dependencies packages ###
echo ""
if [ -f scripts/install_dependencies.sh ]; then
./scripts/install_dependencies.sh
. ./scripts/install_dependencies.sh
fi
### Check and enable swap ###
......@@ -102,72 +102,72 @@ case "${1}" in
### Create default account ###
echo ""
create_account "lemper"
create_account "${LEMPER_USERNAME}"
### Nginx installation ###
echo ""
if [ -f scripts/install_nginx.sh ]; then
./scripts/install_nginx.sh
. ./scripts/install_nginx.sh
fi
### PHP installation ###
echo ""
if [ -f scripts/install_php.sh ]; then
./scripts/install_php.sh
. ./scripts/install_php.sh
fi
### Imagick installation ###
echo ""
if [ -f scripts/install_imagemagick.sh ]; then
./scripts/install_imagemagick.sh
. ./scripts/install_imagemagick.sh
fi
### Memcached installation ###
echo ""
if [ -f scripts/install_memcached.sh ]; then
./scripts/install_memcached.sh
. ./scripts/install_memcached.sh
fi
### MySQL database installation ###
echo ""
if [ -f scripts/install_mariadb.sh ]; then
./scripts/install_mariadb.sh
. ./scripts/install_mariadb.sh
fi
### Redis database installation ###
echo ""
if [ -f scripts/install_redis.sh ]; then
./scripts/install_redis.sh
. ./scripts/install_redis.sh
fi
### MongoDB database installation ###
echo ""
if [ -f scripts/install_mongodb.sh ]; then
./scripts/install_mongodb.sh
. ./scripts/install_mongodb.sh
fi
### Certbot Let's Encrypt SSL installation ###
echo ""
if [ -f scripts/install_certbotle.sh ]; then
./scripts/install_certbotle.sh
. ./scripts/install_certbotle.sh
fi
### Mail server installation ###
echo ""
if [ -f scripts/install_mailer.sh ]; then
./scripts/install_mailer.sh
. ./scripts/install_mailer.sh
fi
### Addon-tools installation ###
echo ""
if [ -f scripts/install_tools.sh ]; then
./scripts/install_tools.sh
. ./scripts/install_tools.sh
fi
### Basic server security ###
echo ""
if [ -f scripts/secure_server.sh ]; then
./scripts/secure_server.sh
. ./scripts/secure_server.sh
fi
### FINAL STEP ###
......@@ -227,37 +227,37 @@ Now, you can reboot your server and enjoy it!"
### Remove Nginx ###
echo ""
if [ -f scripts/remove_nginx.sh ]; then
./scripts/remove_nginx.sh
. ./scripts/remove_nginx.sh
fi
### Remove PHP & FPM ###
echo ""
if [ -f scripts/remove_php.sh ]; then
./scripts/remove_php.sh
. ./scripts/remove_php.sh
fi
### Remove PHP & FPM ###
echo ""
if [ -f scripts/remove_memcached.sh ]; then
./scripts/remove_memcached.sh
. ./scripts/remove_memcached.sh
fi
### Remove MySQL ###
echo ""
if [ -f scripts/remove_mariadb.sh ]; then
./scripts/remove_mariadb.sh
. ./scripts/remove_mariadb.sh
fi
### Remove Redis ###
echo ""
if [ -f scripts/remove_redis.sh ]; then
./scripts/remove_redis.sh
. ./scripts/remove_redis.sh
fi
### Remove Certbot LE ###
echo ""
if [ -f scripts/remove_certbotle.sh ]; then
./scripts/remove_certbotle.sh
. ./scripts/remove_certbotle.sh
fi
# Remove default user account.
......
This diff is collapsed.
......@@ -165,7 +165,7 @@ function enable_vhost() {
reload_nginx
else
fail -e "${1} couldn't be enabled. Probably, it has been enabled or not created yet."
fail "${1} couldn't be enabled. Probably, it has been enabled or not created yet."
exit 1
fi
}
......@@ -185,7 +185,7 @@ function disable_vhost() {
reload_nginx
else
fail -e "${1} couldn't be disabled. Probably, it has been disabled or removed."
fail "${1} couldn't be disabled. Probably, it has been disabled or removed."
exit 1
fi
}
......@@ -195,9 +195,13 @@ function remove_vhost() {
# Verify user input hostname (domain name)
verify_host "${1}"
echo -e "Removing virtual host is not reversible."
echo "Removing virtual host is not reversible."
read -t 30 -rp "Press [Enter] to continue..." </dev/tty
# Get web root path from vhost config.
# shellcheck disable=SC2154
WEBROOT=$(grep -wE "set\ $root_path" "/etc/nginx/sites-available/${1}.conf" | awk '{print $3}' | cut -d"'" -f2)
# Remove Nginx's vhost config.
if [ -f "/etc/nginx/sites-enabled/${1}.conf" ]; then
run unlink "/etc/nginx/sites-enabled/${1}.conf"
......@@ -205,24 +209,25 @@ function remove_vhost() {
run rm -f "/etc/nginx/sites-available/${1}.conf"
status -e "\nVirtual host configuration file removed."
status "Virtual host configuration file removed."
# Remove vhost root directory.
echo ""
read -rp "Do you want to delete website root directory? [y/n]: " -e DELETE_DIR
if [[ "${DELETE_DIR}" == Y* || "${DELETE_DIR}" == y* ]]; then
read -rp "Enter the real path to website root directory: " -e WEBROOT
if [[ ! -d "${WEBROOT}" ]]; then
read -rp "Enter real path to website root directory: " -e WEBROOT
fi
if [ -d "${WEBROOT}" ]; then
run rm -fr "${WEBROOT}"
status -e "\nVirtual host root directory removed."
status "Virtual host root directory removed."
else
warning -e "\nSorry, directory couldn't be found. Skipped..."
warning "Sorry, directory couldn't be found. Skipped..."
fi
fi
# Drop MySQL database.
echo ""
read -rp "Do you want to Drop database associated with this vhost? [y/n]: " -e DROP_DB
if [[ "${DROP_DB}" == Y* || "${DROP_DB}" == y* ]]; then
until [[ "$MYSQLUSER" != "" ]]; do
......@@ -247,15 +252,15 @@ function remove_vhost() {
done
if [ -d "/var/lib/mysql/${DBNAME}" ]; then
echo -e "Dropping database..."
echo "Dropping database..."
run mysql -u "$MYSQLUSER" -p"$MYSQLPSWD" -e "DROP DATABASE $DBNAME"
status -e "Database [${DBNAME}] dropped."
status "Database [${DBNAME}] dropped."
else
warning -e "\nSorry, database ${DBNAME} not found. Skipped..."
warning "Sorry, database ${DBNAME} not found. Skipped..."
fi
fi
status -e "\nYour virtual host ${1} has been removed."
echo "Virtual host ${1} has been removed."
# Reload Nginx.
reload_nginx
......@@ -516,6 +521,11 @@ function verify_host() {
exit 1
fi
if [[ "${1}" == "default" ]]; then
error "Modify/delete default virtual host is prohibitted."
exit 1
fi
if [ ! -f "/etc/nginx/sites-available/${1}.conf" ]; then
error "Sorry, we couldn't find NGiNX virtual host: ${1}..."
exit 1
......
......@@ -33,7 +33,7 @@ run apt-get --fix-broken install
# Remove Apache2 service if exists.
if [[ -n $(command -v apache2) ]]; then
warning "It seems Apache web server installed on this server."
warning -e "\nIt seems Apache web server installed on this server."
echo "Any other HTTP web server will be removed, otherwise they will conflict."
read -t 15 -rp "Press [Enter] to continue..." </dev/tty
echo -e "\nUninstall existing Apache web server..."
......@@ -50,25 +50,56 @@ fi
# Remove NGiNX service if exists.
if [[ -n $(command -v nginx) ]]; then
warning "NGiNX HTTP server already installed on this server. Should we remove it?"
echo -e "Backup your config and data before continue!\n"
warning -e "\nNGiNX HTTP server already installed on this server. Should we remove it?"
echo "Backup your config and data before continue!"
# shellchechk source=scripts/remove_nginx.sh
# shellcheck disable=SC1090
"${SCRIPTS_DIR}/remove_nginx.sh"
fi
# Remove PHP & FPM service if exists.
if [[ -n $(command -v php5.6) || \
-n $(command -v php7.0) || \
-n $(command -v php7.1) || \
-n $(command -v php7.2) || \
-n $(command -v php7.3) ]]; then
warning -e "\nPHP & FPM already installed on this server. Should we remove it?"
echo "Backup your config and data before continue!"
# shellchechk source=scripts/remove_php.sh
# shellcheck disable=SC1090
"${SCRIPTS_DIR}/remove_php.sh"
fi
# Remove Mysql service if exists.
if [[ -n $(command -v mysql) ]]; then
warning "MySQL database server already installed on this server. Should we remove it?"
echo -e "Backup your database before continue!\n"
warning -e "\nMySQL database server already installed on this server. Should we remove it?"
echo "Backup your database before continue!"
# shellchechk source=scripts/remove_mariadb.sh
# shellcheck disable=SC1090
"${SCRIPTS_DIR}/remove_mariadb.sh"
fi
# Autoremove packages.
# Remove default lemper account if exists.
USERNAME=${LEMPER_USERNAME:-"lemper"}
if [[ -n $(getent passwd "${USERNAME}") ]]; then
warning -e "\nDefault lemper account already exists. Should we remove it?"
echo "Backup your data before continue!"
while [[ "${REMOVE_ACCOUNT}" != "y" && "${REMOVE_ACCOUNT}" != "n" && "${AUTO_REMOVE}" != true ]]; do
read -rp "Are you sure to remove PHP & FPM? [y/n]: " -e REMOVE_ACCOUNT
done
if [[ "${REMOVE_ACCOUNT}" == Y* || "${REMOVE_ACCOUNT}" == y* || "${AUTO_REMOVE}" == true ]]; then
delete_account "${USERNAME}"
else
echo "Found default lemper account, but not removed."
fi
fi
# Autoremove unused packages.
echo -e "\nClean up unused packages."
run apt autoremove -y
......
......@@ -379,12 +379,15 @@ function create_swap() {
local RAM_SIZE && \
RAM_SIZE=$(get_ram_size)
if [[ ${RAM_SIZE} -lt 8192 ]]; then
# If machine RAM less than 8GiB, set swap to half of it.
local SWAP_SIZE=$((RAM_SIZE / 2))
if [[ ${RAM_SIZE} -le 2048 ]]; then
# If machine RAM less than / equal 2GiB, set swap to 2x of RAM size.
local SWAP_SIZE=$((RAM_SIZE * 2))
elif [[ ${RAM_SIZE} -gt 2048 && ${RAM_SIZE} -le 8192 ]]; then
# If machine RAM less than / equal 8GiB and greater than 2GiB, set swap equal to RAM size.
local SWAP_SIZE="${RAM_SIZE}"
else
# Otherwise, set swap to max of 4GiB.
local SWAP_SIZE=4096
# Otherwise, set swap to max of 8GiB.
local SWAP_SIZE=8192
fi
echo "Creating ${SWAP_SIZE}MiB swap..."
......@@ -407,11 +410,10 @@ function create_swap() {
# meaning that the swap file will be used fairly often if the memory usage is
# around half RAM, for production servers you may need to set a lower value.
if [[ $(cat /proc/sys/vm/swappiness) -gt 15 ]]; then
run sysctl vm.swappiness=15
if "${DRYRUN}"; then
echo "Update swappiness value in dryrun mode."
else
run sysctl vm.swappiness=15
run echo "vm.swappiness=15" >> /etc/sysctl.conf
fi
fi
......@@ -419,10 +421,10 @@ function create_swap() {
# Remove created Swap.
function remove_swap() {
echo "Disabling swap..."
local SWAP_FILE="/root/lemper-swapfile"
echo "Disabling swap..."
run swapoff -v ${SWAP_FILE} && \
run sed -i "s/${SWAP_FILE}/#\ ${SWAP_FILE}/g" /etc/fstab && \
run rm -f ${SWAP_FILE}
......@@ -446,7 +448,7 @@ function enable_swap() {
# Create system account.
function create_account() {
export USERNAME=${1:-"lemper"}
PASSWORD=$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
PASSWORD=${LEMPER_PASSWORD:-$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)}
export PASSWORD
echo "Creating default LEMPer account..."
......
......@@ -2,7 +2,7 @@
# MariaDB (MySQL) Installer
# Min. Requirement : GNU/Linux Ubuntu 14.04 & 16.04
# Last Build : 17/07/2019
# Last Build : 24/08/2019
# Author : ESLabs.ID (eslabs.id@gmail.com)
# Since Version : 1.0.0
......@@ -25,17 +25,20 @@ function add_mariadb_repo() {
case "${DISTRIB_REPO}" in
trusty)
# Only support 10.3 and lesser.
local MARIADB_VERSION="10.3"
local MARIADB_ARCH="amd64,i386,ppc64el"
;;
xenial)
local MARIADB_VERSION="10.4"
# Support 10.3 & 10.4.
local MARIADB_VERSION=${MYSQL_VERSION:-"10.4"}
local MARIADB_ARCH="amd64,arm64,i386,ppc64el"
;;
bionic)
local MARIADB_VERSION="10.4"
# Support 10.3 & 10.4.
local MARIADB_VERSION=${MYSQL_VERSION:-"10.4"}
local MARIADB_ARCH="amd64,arm64,ppc64el"
;;
......@@ -92,7 +95,7 @@ function init_mariadb_install() {
#mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bak
#mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bak
#service mysql start
# Installation status.
if "${DRYRUN}"; then
status "MariaDB (MySQL) installed in dryrun mode."
......@@ -137,7 +140,7 @@ function init_mariadb_install() {
# Trying to reload daemon.
run systemctl daemon-reload
# Restart MariaDB
run systemctl restart mariadb.service
......@@ -147,7 +150,7 @@ function init_mariadb_install() {
# MySQL Secure Install
run mysql_secure_installation
fi
if [[ $(pgrep -c mysql) -gt 0 ]]; then
status -e "\nMariaDB (MySQL) installed successfully."
......@@ -166,20 +169,19 @@ function enable_mariabackup() {
echo ""
sleep 1
export MARIABACKUP_USER=${MARIABACKUP_USER:-"lempersh"}
export MARIABACKUP_USER=${MARIABACKUP_USER:-"lemperdb"}
export MARIABACKUP_PASS && \
MARIABACKUP_PASS=$(openssl rand -base64 64 | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
export MARIABACKUP_PASS
echo "Please enter your current MySQL root password to process!"
export MYSQL_ROOT_PASS
until [[ "${MYSQL_ROOT_PASS}" != "" ]]; do
echo -n "MySQL root password: "; stty -echo; read -r MYSQL_ROOT_PASS; stty echo; echo
#echo -n "MySQL root password: "; stty echo; read -rp MYSQL_ROOT_PASS; stty echo; echo
read -s -rp "MySQL root password: " -e MYSQL_ROOT_PASS
done
export MYSQL_ROOT_PASS
# Check user exists.
MYSQL_USER=$(mysql -u root -p"${MYSQL_ROOT_PASS}" -e "SELECT User FROM mysql.user" | grep "${MARIABACKUP_USER}")
if [[ -z "${MYSQL_USER}" ]]; then
# Chreate user if not exists.
if [[ -z $(mysql -u root -p"${MYSQL_ROOT_PASS}" -e "SELECT User FROM mysql.user;" | grep "${MARIABACKUP_USER}") ]]; then
# Create mariabackup user.
SQL_QUERY="CREATE USER '${MARIABACKUP_USER}'@'localhost' IDENTIFIED BY '${MARIABACKUP_PASS}';
GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT ON *.* TO '${MARIABACKUP_USER}'@'localhost';"
......
......@@ -117,8 +117,29 @@ function init_nginx_install() {
"${SCRIPTS_DIR}/install_nginx_from_source.sh" -v latest-stable \
-n stable --dynamic-module --extra-modules -y --dryrun
else
"${SCRIPTS_DIR}/install_nginx_from_source.sh" -v latest-stable \
-n stable --dynamic-module --extra-modules -y
# Additional configure arguments.
NGX_CONFIGURE_ARGS=""
# Build directory.
BUILD_DIR=${BUILD_DIR:-"/usr/local/src/lemper"}
if [ ! -d "${BUILD_DIR}" ]; then
run mkdir -p "${BUILD_DIR}"
fi
# Custom OpenSSL.
OPENSSL_VERSION="openssl-1.1.1c"
if [[ -n "${OPENSSL_VERSION}" ]]; then
run wget -q -O "${BUILD_DIR}/${OPENSSL_VERSION}.tar.gz" \
"https://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz"
run tar -C "${BUILD_DIR}/" -xf "${BUILD_DIR}/${OPENSSL_VERSION}.tar.gz"
run rm -f "${BUILD_DIR}/${OPENSSL_VERSION}.tar.gz"
NGX_CONFIGURE_ARGS="--with-openssl=${BUILD_DIR}/${OPENSSL_VERSION} ${NGX_CONFIGURE_ARGS}"
fi
# Execute nginx from source installer.
"${SCRIPTS_DIR}/install_nginx_from_source.sh" -v latest-stable -n stable --dynamic-module \
--extra-modules -b "${BUILD_DIR}" -a "${NGX_CONFIGURE_ARGS}" -y
fi
echo ""
......@@ -273,7 +294,7 @@ function init_nginx_install() {
run cp etc/systemd/nginx.service /lib/systemd/system/
fi
if [ ! -f /etc/systemd/system/nginx.service ]; then
if [ ! -f /etc/systemd/system/multi-user.target.wants/nginx.service ]; then
run ln -s /lib/systemd/system/nginx.service \
/etc/systemd/system/multi-user.target.wants/nginx.service
fi
......
......@@ -362,8 +362,7 @@ function build_ngx_pagespeed() {
NPS_VERSION="DEFAULT"
NGINX_VERSION=""
# Current working directory as default build dir
BUILDDIR="$HOME/lemper_nginx_build"
#BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/lemper_nginx_build"
BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )/nginx_build"
DO_DEPS_CHECK=true
PSOL_FROM_SOURCE=false
DEVEL=false
......@@ -374,19 +373,23 @@ function build_ngx_pagespeed() {
NGINX_EXTRA_MODULES=false
# Extra Modules
NGX_BROTLI=true
NGX_CACHE_PURGE=true
NGX_HEADERS_MORE=true
NGX_HTTP_GEOIP2=false
NGX_ECHO=false
NGX_HTTP_AUTH_PAM=false
NGX_WEB_DAV_EXT=false
NGX_UPSTREAM_FAIR=false
NGX_HTTP_SUBS_FILTER=false
NGX_NCHAN=false
NGX_NAXSI=true
NGX_FANCYINDEX=true
NGX_VTS=true
NGX_BROTLI=${NGX_BROTLI:-true}
NGX_CACHE_PURGE=${NGX_CACHE_PURGE:-true}
NGX_ECHO=${NGX_ECHO:-false}
NGX_FANCYINDEX=${NGX_FANCYINDEX:-false}
NGX_HEADERS_MORE=${NGX_HEADERS_MORE:-true}
NGX_HTTP_AUTH_PAM=${NGX_HTTP_AUTH_PAM:-false}
NGX_HTTP_GEOIP2=${NGX_HTTP_GEOIP2:-false}
NGX_HTTP_SUBS_FILTER=${NGX_HTTP_SUBS_FILTER:-false}
NGX_MEMCACHED=${NGX_MEMCACHED:-false}
NGX_NAXSI=${NGX_NAXSI:-true}
NGX_NCHAN=${NGX_NCHAN:-false}
NGX_PAGESPEED=${NGX_PAGESPEED:-true}
NGX_REDIS2=${NGX_REDIS2:-false}
NGX_RTMP=${NGX_RTMP:-false}
NGX_UPSTREAM_FAIR=${NGX_UPSTREAM_FAIR:-false}
NGX_VTS=${NGX_VTS:-true}
NGX_WEB_DAV_EXT=${NGX_WEB_DAV_EXT:-false}
while true; do
case "$1" in
......@@ -973,8 +976,43 @@ with --no-deps-check."
fi
fi
configure_args=("${add_extra_modules[@]}"
"${configure_args[@]}")
# Nginx Memc - An extended version of the standard memcached module.
if "$NGX_MEMCACHED"; then
echo "Downloading extended Memcached module..."
run git clone -q https://github.com/openresty/memc-nginx-module.git
if "$NGINX_DYNAMIC_MODULE"; then
add_extra_modules=("--add-dynamic-module=$extra_module_dir/memc-nginx-module" "${add_extra_modules[@]}")
else
add_extra_modules=("--add-module=$extra_module_dir/memc-nginx-module" "${add_extra_modules[@]}")
fi
fi
# Nginx upstream module for the Redis 2.0 protocol.
if "$NGX_REDIS2"; then
echo "Downloading Redis 2.0 protocol module..."
run git clone -q https://github.com/openresty/redis2-nginx-module.git
if "$NGINX_DYNAMIC_MODULE"; then
add_extra_modules=("--add-dynamic-module=$extra_module_dir/redis2-nginx-module" "${add_extra_modules[@]}")
else
add_extra_modules=("--add-module=$extra_module_dir/redis2-nginx-module" "${add_extra_modules[@]}")
fi
fi
# NGINX-based Media Streaming Server.
if "$NGX_RTMP"; then
echo "Downloading RTMP Media Streaming Server module..."
run git clone -q https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git
if "$NGINX_DYNAMIC_MODULE"; then
add_extra_modules=("--add-dynamic-module=$extra_module_dir/nginx-rtmp-module" "${add_extra_modules[@]}")
else
add_extra_modules=("--add-module=$extra_module_dir/nginx-rtmp-module" "${add_extra_modules[@]}")
fi
fi
configure_args=("${add_extra_modules[@]}" "${configure_args[@]}")
fi
if "$DEVEL"; then
......@@ -992,7 +1030,6 @@ with --no-deps-check."
fi
configure_args=("${configure_args[@]}"
"--prefix=$install_dir/nginx"
#"--with-ipv6"
"--with-http_v2_module"
"${add_modules[@]}")
if [ "$BUILD_TYPE" = "Debug" ]; then
......@@ -1030,7 +1067,6 @@ with --no-deps-check."
"--with-http_sub_module"
"--with-http_v2_module"
"--with-http_xslt_module=dynamic"
#"--with-ipv6"
"--with-mail=dynamic"
"--with-mail_ssl_module"
"--with-stream=dynamic"
......
#!/usr/bin/env bash
# Phalcon & Zephir Installer
# Min. Requirement : GNU/Linux Ubuntu 14.04
# Last Build : 23/08/2019
# Author : ESLabs.ID (eslabs.id@gmail.com)
# Since Version : 1.2.0
# Include helper functions.
if [ "$(type -t run)" != "function" ]; then
BASEDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
# shellchechk source=scripts/helper.sh
# shellcheck disable=SC1090