Update Nginx config

This commit is contained in:
joglomedia
2019-07-16 13:40:34 +07:00
parent 315eac4eb2
commit 715d0a090f
10 changed files with 205 additions and 167 deletions

View File

@@ -1 +0,0 @@
## Don't touch this file !

View File

@@ -1 +0,0 @@
## Don't touch this file !

View File

@@ -13,7 +13,7 @@
server {
listen 80;
#listen [::]:80 default ipv6only=on;
listen [::]:80;
# Make site accessible from http://localhost/
server_name localhost.localdomain;
@@ -37,12 +37,16 @@ server {
autoindex on;
}
location /status {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
# PHP-FPM status monitoring
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
location /ping {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
allow all;
auth_basic "Denied";
auth_basic_user_file /srv/.htpasswd;
}
# Default PHP set to 7.3
@@ -97,7 +101,7 @@ server {
## Database Administration
server {
listen 8082;
#listen [::]:80 default ipv6only=on;
listen [::]:8082;
# Make site accessible from http://localhost.localdomain/
server_name localhost.localdomain;
@@ -148,8 +152,8 @@ server {
## File Administration
server {
listen 8083; ## listen for ipv4;
#listen [::]:80 default ipv6only=on;
listen 8083;
listen [::]:8083;
# Make site accessible from http://localhost.localdomain/
server_name localhost.localdomain;
@@ -201,7 +205,7 @@ server {
# HTTPS server
#
#server {
# listen 443;
# listen 443 ssl http2;
# server_name localhost;
#
# root html;

View File

@@ -1,14 +1,14 @@
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:8080 default ipv6only=on; ## listen for ipv6
listen 80;
listen [::]:8080;
## Make site accessible from the universe.
server_name www.sample-site-cached.dev;
## Log Settings.
access_log /var/log/nginx/sample-site-cached.dev_access.log;
error_log /var/log/nginx/sample-site-cached.dev_error.log;
access_log /var/log/nginx/sample-site-cached.dev_access.log;
error_log /var/log/nginx/sample-site-cached.dev_error.log;
## Vhost root directory
set $root_path '/home/masedi/Webs/sample-site.dev';
root $root_path;
@@ -20,12 +20,10 @@ server {
include /etc/nginx/includes/rules_restriction.conf;
## Default vhost directives configuration, use only one config.
#include /etc/nginx/vhost/site_default.conf;
include /etc/nginx/vhost/site_default_cached.conf;
#include /etc/nginx/vhost/site_wordpress.conf;
#include /etc/nginx/vhost/site_wordpress_cached.conf;
include /etc/nginx/includes/rules_fastcgi_cache.conf;
include /etc/nginx/vhost/site_default.conf;
## Uncomment to enable custom rules (requires server restart),
## Uncomment to enable custom rules (requires server restart),
# setting per-site basis like .htaccess
#include '$root_path/.ngxaccess';
@@ -50,8 +48,8 @@ server {
include /etc/nginx/fastcgi_params;
# Overwrite FastCGI Params here.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Include FastCGI Configs.
include /etc/nginx/includes/fastcgi.conf;

View File

@@ -2,15 +2,15 @@
# include it on every vhost server config.
server {
listen 8082; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 8082;
#listen [::]:8082; ## listen for ipv6
server_name localhost.localdomain;
# Global configuration.
include /etc/nginx/includes/rules_staticfiles.conf;
include /etc/nginx/includes/rules_restriction.conf;
location / {}
location /phpmyadmin {
@@ -19,21 +19,21 @@ server {
location ~ ^/phpmyadmin/(.+\.php)$ {
root /usr/share/nginx/html/phpmyadmin/;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
# Include FastCGI Params.
include /etc/nginx/fastcgi_params;
# Overwrite FastCGI Params here.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Include FastCGI Configs.
include /etc/nginx/includes/fastcgi.conf;
@@ -45,7 +45,7 @@ server {
root /usr/share/nginx/html/phpmyadmin/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}

View File

@@ -1,13 +1,13 @@
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:8080 default ipv6only=on; ## listen for ipv6
listen 80;
listen [::]:8080;
## Make site accessible from the universe.
server_name www.sample-site.dev;
server_name sample-site.dev;
## Log Settings.
access_log /var/log/nginx/sample-site.dev_access.log;
error_log /var/log/nginx/sample-site.dev_error.log error;
access_log /var/log/nginx/sample-site.dev_access.log;
error_log /var/log/nginx/sample-site.dev_error.log error;
## Vhost root directory
set $root_path '/home/masedi/Webs/sample-site.dev';
@@ -21,11 +21,8 @@ server {
## Default vhost directives configuration, use only one config.
include /etc/nginx/vhost/site_default.conf;
#include /etc/nginx/vhost/site_default_cached.conf;
#include /etc/nginx/vhost/site_wordpress.conf;
#include /etc/nginx/vhost/site_wordpress_cached.conf;
## Uncomment to enable custom rules (requires server restart),
## Uncomment to enable custom rules (requires server reload/restart),
# setting per-site basis like .htaccess
#include '$root_path/.ngxaccess';
@@ -49,8 +46,8 @@ server {
include /etc/nginx/fastcgi_params;
# Overwrite FastCGI Params here. Development only, params should be added to fastcgi_params.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAM $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Include FastCGI Configs.
include /etc/nginx/includes/fastcgi.conf;

View File

@@ -1,28 +1,29 @@
## Wordpress Multisite Mapping for Nginx (Requires Nginx Helper plugin).
map $http_host $blogid {
default 0;
include /home/masedi/Webs/sample-wordpress-ms.dev/wp-content/plugins/nginx-helper/map.conf;
default 0;
include /home/masedi/Webs/sample-wordpress-ms.dev/wp-content/plugins/nginx-helper/map.conf;
}
server {
listen 80; ## listen for ipv4; this line is default and implied
listen 80;
#listen [::]:80; ## listen for ipv6
# Make site accessible from world wide
server_name www.sample-wordpress-ms.dev;
server_name sample-wordpress-ms.dev *.sample-wordpress-ms.dev;
set $root_path '/home/masedi/Webs/sample-wordpress-ms.dev';
root $root_path;
index index.php index.html index.htm;
# Log
access_log /var/log/nginx/sample-wordpress-ms.dev_access.log;
error_log /var/log/nginx/sample-wordpress-ms.dev_error.log;
access_log /var/log/nginx/sample-wordpress-ms.dev_access.log;
error_log /var/log/nginx/sample-wordpress-ms.dev_error.log;
# Global directives configuration.
include /etc/nginx/includes/rules_security.conf;
include /etc/nginx/includes/rules_staticfiles.conf;
include /etc/nginx/includes/rules_restriction.conf;
# Custom Nginx directives
#include $root_path/.ngxaccess;
@@ -36,20 +37,20 @@ server {
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php5.6-fpm.masedi.sock;
# Include FastCGI Params.
include /etc/nginx/fastcgi_params;
# Overwrite FastCGI Params here.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Include FastCGI Configs.
include /etc/nginx/includes/fastcgi.conf;

View File

@@ -1,14 +1,14 @@
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:8080 default ipv6only=on; ## listen for ipv6
listen 80;
#listen [::]:80; ## listen for ipv6
## Make site accessible from the universe.
server_name www.sample-wordpress.dev;
server_name sample-wordpress.dev;
## Log Settings.
access_log /var/log/nginx/sample-wordpress.dev_access.log;
error_log /var/log/nginx/sample-wordpress.dev_error.log;
access_log /var/log/nginx/sample-wordpress.dev_access.log;
error_log /var/log/nginx/sample-wordpress.dev_error.log;
## Vhost root directory
set $root_path '/home/masedi/Webs/sample-wordpress.dev';
root $root_path;
@@ -22,12 +22,6 @@ server {
## Default vhost directives configuration, use only one config.
include /etc/nginx/vhost/site_wordpress.conf;
## Uncomment to enable custom rules (requires server restart), setting per-site basis like .htaccess
#include '$root_path/.ngxaccess';
## Default WordPress directives.
# The default site directive for '/' location has been pre-defined in the Default vhost directive config file.
## Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
# Zero-day exploit defense.
@@ -46,8 +40,8 @@ server {
include /etc/nginx/fastcgi_params;
# Overwrite FastCGI Params here.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# Include FastCGI Configs.
include /etc/nginx/includes/fastcgi.conf;
@@ -58,11 +52,14 @@ server {
# FastCGI socket, change to fits your own socket!
fastcgi_pass unix:/run/php/php5.6-fpm.masedi.sock;
}
## Uncomment to enable error page directives configuration.
#include /etc/nginx/includes/error_pages.conf;
## Add your custom site directives here.
# Uncomment to enable custom rules (requires server reload/restart),
# setting per-site basis like Apache .htaccess
#include '$root_path/.ngxaccess';
}
## Legacy www

View File

@@ -1,8 +1,8 @@
## Sample server {} block directives for SSL/HTTPS
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
listen 80;
listen [::]:80;
## Make site accessible from world wide.
server_name ssl.sample-site.dev;
@@ -15,8 +15,8 @@ server {
### HTTPS/SSL configuration ###
server {
listen 443 ssl http2 default_server;
#listen [::]:443 ssl http2 default_server;
listen 443 ssl http2;
listen [::]:443 ssl http2;
## Make site accessible from world wide.
server_name ssl.sample-site.dev;

View File

@@ -140,10 +140,10 @@ Options:
-u, --username <virtual-host username>
Use username added from adduser/useradd. Do not use root user.
-w, --webroot <web root>
Web root is an absolute path to the website root directory, i.e. /home/username/Webs/example.test.
Web root is an absolute path to the website root directory, i.e. /home/lemper/webapps/example.test.
Example:
${APP_NAME} -u username -d example.com -f default -w /home/username/Webs/example.dev
${APP_NAME} -u lemper -d example.com -f default -w /home/lemper/webapps/example.test
For more details visit https://ngxtools.eslabs.id!
Mail bug reports and suggestions to <eslabs.id@gmail.com>
@@ -158,7 +158,7 @@ function create_vhost_default() {
cat <<- _EOF_
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen [::]:80;
## Make site accessible from world web.
server_name ${SERVERNAME};
@@ -215,6 +215,17 @@ server {
## Uncomment to enable error page directives configuration.
#include /etc/nginx/includes/error_pages.conf;
## PHP-FPM status monitoring
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php${PHP_VERSION}-fpm.${USERNAME}.sock;
allow all;
auth_basic "Denied";
auth_basic_user_file /srv/.htpasswd;
}
## Add your custom site directives here.
}
_EOF_
@@ -227,7 +238,7 @@ function create_vhost_drupal() {
cat <<- _EOF_
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen [::]:80;
## Make site accessible from world web.
server_name ${SERVERNAME};
@@ -289,6 +300,17 @@ server {
## Uncomment to enable error page directives configuration.
#include /etc/nginx/includes/error_pages.conf;
## PHP-FPM status monitoring
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php${PHP_VERSION}-fpm.${USERNAME}.sock;
allow all;
auth_basic "Denied";
auth_basic_user_file /srv/.htpasswd;
}
## Add your custom site directives here.
}
_EOF_
@@ -301,7 +323,7 @@ function create_vhost_laravel() {
cat <<- _EOF_
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen [::]:80;
## Make site accessible from world web.
server_name ${SERVERNAME};
@@ -359,6 +381,17 @@ server {
## Uncomment to enable error page directives configuration.
#include /etc/nginx/includes/error_pages.conf;
## PHP-FPM status monitoring
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php${PHP_VERSION}-fpm.${USERNAME}.sock;
allow all;
auth_basic "Denied";
auth_basic_user_file /srv/.htpasswd;
}
## Add your custom site directives here.
}
_EOF_
@@ -371,7 +404,7 @@ function create_vhost_phalcon() {
cat <<- _EOF_
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen [::]:80;
## Make site accessible from world web.
server_name ${SERVERNAME};
@@ -434,6 +467,17 @@ server {
## Uncomment to enable error page directives configuration.
#include /etc/nginx/includes/error_pages.conf;
## PHP-FPM status monitoring
location ~ ^/(status|ping)$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php${PHP_VERSION}-fpm.${USERNAME}.sock;
allow all;
auth_basic "Denied";
auth_basic_user_file /srv/.htpasswd;
}
## Add your custom site directives here.
}
_EOF_
@@ -460,7 +504,7 @@ cat <<- _EOF_
# HTTP to HTTPS redirection
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
listen [::]:80;
## Make site accessible from world web.
server_name ${SERVERNAME};
@@ -470,6 +514,7 @@ server {
return 301 https://$server_name$request_uri;
}
}
_EOF_
}
@@ -532,6 +577,8 @@ pm.max_spare_servers = 3
pm.process_idle_timeout = 30s
pm.max_requests = 500
; PHP-FPM monitoring
; Do Not change this two lines
pm.status_path = /status
ping.path = /ping
@@ -555,7 +602,7 @@ _EOF_
#
function install_wordpress() {
# Clone new WordPress skeleton files
if [ $CLONE_SKELETON == true ]; then
if [ ${CLONE_SKELETON} == true ]; then
# Check WordPress install directory
if [ ! -d ${WEBROOT}/wp-admin ]; then
status "Copying WordPress skeleton files..."
@@ -621,29 +668,29 @@ function init_app() {
CLONE_SKELETON=false
DRYRUN=false
COUNT_ARGS=0
MAIN_ARGS=0
# Parse flags
while true; do
case $1 in
-u | --username) shift
USERNAME="$1"
COUNT_ARGS=$(($COUNT_ARGS + 1))
MAIN_ARGS=$(($MAIN_ARGS + 1))
shift
;;
-d | --domain-name) shift
SERVERNAME="$1"
COUNT_ARGS=$(($COUNT_ARGS + 1))
MAIN_ARGS=$(($MAIN_ARGS + 1))
shift
;;
-w | --webroot) shift
WEBROOT="${1%%+(/)}"
COUNT_ARGS=$(($COUNT_ARGS + 1))
MAIN_ARGS=$(($MAIN_ARGS + 1))
shift
;;
-f | --framework) shift
FRAMEWORK="$1"
COUNT_ARGS=$(($COUNT_ARGS + 1))
MAIN_ARGS=$(($MAIN_ARGS + 1))
shift
;;
-p | --php-version) shift
@@ -661,7 +708,7 @@ function init_app() {
exit 0
;;
-v | --version) shift
echo "$APP_NAME version $APP_VERSION"
echo "${APP_NAME} version ${APP_VERSION}"
exit 1
;;
--) shift
@@ -674,14 +721,14 @@ function init_app() {
esac
done
if [ $COUNT_ARGS -ge 4 ]; then
if [ ${MAIN_ARGS} -ge 4 ]; then
# Additional Check - are user already exist?
if [[ -z $(getent passwd $USERNAME) ]]; then
if [[ -z $(getent passwd ${USERNAME}) ]]; then
fail -e "\nError: The user ${USERNAME} does not exist, please add new user first! Aborting...
Help: useradd username, try ${APP_NAME} -h for more helps"
fi
# Check PHP fpm version is exists?
# Check PHP fpm version is exists.
if [[ -n $(which php-fpm${PHP_VERSION}) && -d /etc/php/${PHP_VERSION}/fpm ]]; then
# Additional check - is FPM user's pool already exist
if [ ! -f "/etc/php/${PHP_VERSION}/fpm/pool.d/${USERNAME}.conf" ]; then
@@ -693,27 +740,28 @@ function init_app() {
# Restart PHP FPM
echo "Restart php${PHP_VERSION}-fpm configuration..."
run service "php${PHP_VERSION}-fpm" restart
status "New PHP-FPM pool [${USERNAME}] has been created."
fi
else
fail "There is no PHP${PHP_VERSION} version installed, please install it first! Aborting..."
fail "There is no PHP & FPM version ${PHP_VERSION} installed, please install it first! Aborting..."
fi
# Additional Check - ensure that Nginx's configuration meets the requirement
# Additional Check - ensure that Nginx's configuration meets the requirements.
if [ ! -d /etc/nginx/sites-available ]; then
fail "It seems that your Nginx installation doesn't meet ${APP_NAME} requirements. Aborting..."
fi
# Vhost file
vhost_file="/etc/nginx/sites-available/${SERVERNAME}.conf"
# Define vhost file.
VHOST_FILE="/etc/nginx/sites-available/${SERVERNAME}.conf"
# Check if vhost not exists.
if [ ! -f "${vhost_file}" ]; then
if [ ! -f ${VHOST_FILE} ]; then
echo "Adding domain ${SERVERNAME} to virtual host..."
# Creates document root
# Creates document root.
if [ ! -d ${WEBROOT} ]; then
echo "Creating web root directory: ${WEBROOT}..."
@@ -725,37 +773,36 @@ function init_app() {
echo "Selecting ${FRAMEWORK^} framewrok..."
# Ugly hacks for custom framework-specific configs + Skeleton auto installer.
case $FRAMEWORK in
case ${FRAMEWORK} in
drupal)
echo "Setting up Drupal virtual host..."
# Clone new Drupal skeleton files
if [ $CLONE_SKELETON == true ]; then
# Check Drupal install directory
# Clone new Drupal skeleton files.
if [ ${CLONE_SKELETON} == true ]; then
# Check Drupal install directory.
if [ ! -d ${WEBROOT}/core/lib/Drupal ]; then
status "Copying Drupal latest skeleton files..."
run wget --no-check-certificate -O drupal.zip -q \
https://www.drupal.org/download-latest/zip
run unzip -q drupal.zip
run rsync -r drupal-*/ ${WEBROOT}
run rsync -rq drupal-*/ ${WEBROOT}
run rm -f drupal.zip
run rm -fr drupal-*/
else
warning "It seems that Drupal files already exists."
fi
else
# Create default index file
# Create default index file.
status "Creating default index file..."
create_index_file > ${WEBROOT}/index.html
run chown ${USERNAME}:${USERNAME} ${WEBROOT}/index.html
fi
# Create vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_drupal > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_drupal > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
@@ -763,9 +810,9 @@ function init_app() {
echo "Setting up Laravel framework virtual host..."
# Install Laravel framework skeleton
# Clone new Laravel files
if [ $CLONE_SKELETON == true ]; then
# Check Laravel install
# clone new Laravel files.
if [ ${CLONE_SKELETON} == true ]; then
# Check Laravel install.
if [ ! -f ${WEBROOT}/server.php ]; then
status "Copying Laravel skeleton files..."
@@ -774,17 +821,16 @@ function init_app() {
warning "It seems that Laravel skeleton files already exists."
fi
else
# Create default index file
# Create default index file.
status "Creating default index file..."
create_index_file > ${WEBROOT}/index.html
run chown ${USERNAME}:${USERNAME} ${WEBROOT}/index.html
fi
# Create vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_laravel > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_laravel > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
@@ -793,10 +839,9 @@ function init_app() {
# TODO: Auto install Phalcon PHP framework skeleton
# Create vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_phalcon > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_phalcon > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
@@ -805,33 +850,31 @@ function init_app() {
# TODO: Auto install Symfony PHP framework skeleton
# Create vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_default > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_default > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
wordpress)
echo "Setting up WordPress virtual host..."
# Install WordPress
# Install WordPress skeleton.
install_wordpress
# Create vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_default > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_default > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
wordpress-ms)
echo "Setting up WordPress Multi-site virtual host..."
# Install WordPress
# Install WordPress.
install_wordpress
# Pre-populate blog id mapping, used by Nginx vhost conf
# Pre-populate blog id mapping, used by Nginx vhost conf.
if [ ! -d ${WEBROOT}/wp-content/uploads ]; then
run mkdir ${WEBROOT}/wp-content/uploads
fi
@@ -840,15 +883,17 @@ function init_app() {
run mkdir ${WEBROOT}/wp-content/uploads/nginx-helper
fi
run touch ${WEBROOT}/wp-content/uploads/nginx-helper/map.conf
if [ ! -f ${WEBROOT}/wp-content/uploads/nginx-helper/map.conf ]; then
run touch ${WEBROOT}/wp-content/uploads/nginx-helper/map.conf
fi
echo "Creating virtual host file: ${vhost_file}..."
echo "Creating virtual host file: ${VHOST_FILE}..."
# Prepare vhost specific rule for WordPress Multisite
prepare_vhost_wpms > ${vhost_file}
# Prepare vhost specific rule for WordPress Multisite.
prepare_vhost_wpms > ${VHOST_FILE}
# Create vhost
create_vhost_default >> ${vhost_file}
# Create vhost.
create_vhost_default >> ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
@@ -856,16 +901,16 @@ function init_app() {
filerun)
echo "Setting up FileRun virtual host..."
# Install FileRun skeleton
# Install FileRun skeleton.
if [ ! -f ${WEBROOT}/system/classes/filerun.php ]; then
# Clone new Filerun files
if [ $CLONE_SKELETON == true ]; then
# Clone new Filerun files.
if [ ${CLONE_SKELETON} == true ]; then
echo "Copying FileRun skeleton files..."
run wget -q -O FileRun.zip http://www.filerun.com/download-latest
run unzip -q FileRun.zip -d ${WEBROOT}
run rm -f FileRun.zip
else
# Create default index file
# Create default index file.
echo "Creating default index files..."
create_index_file > ${WEBROOT}/index.html
run chown ${USERNAME}:${USERNAME} ${WEBROOT}/index.html
@@ -874,22 +919,20 @@ function init_app() {
warning "FileRun skeleton files already exists."
fi
# Create default vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_default > ${vhost_file}
# Create vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_default > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
codeigniter|mautic|default)
# Create default index file
# Create default index file.
create_index_file > ${WEBROOT}/index.html
run chown ${USERNAME}:${USERNAME} ${WEBROOT}/index.html
# Create default vhost
echo "Creating virtual host file: ${vhost_file}..."
create_vhost_default > ${vhost_file}
# Create default vhost.
echo "Creating virtual host file: ${VHOST_FILE}..."
create_vhost_default > ${VHOST_FILE}
status "New domain ${SERVERNAME} has been added to virtual host."
;;
@@ -901,29 +944,29 @@ function init_app() {
esac
# Enable FastCGI cache?
if [ $ENABLE_FASTCGI_CACHE == true ]; then
if [ ${ENABLE_FASTCGI_CACHE} == true ]; then
echo "Enable FastCGI cache for ${SERVERNAME}..."
if [ -f /etc/nginx/includes/rules_fastcgi_cache.conf; ]; then
# enable cached directives
run sed -i "s|#include\ /etc/nginx/includes/rules_fastcgi_cache.conf|include\ /etc/nginx/includes/rules_fastcgi_cache.conf|g" ${vhost_file}
run sed -i "s|#include\ /etc/nginx/includes/rules_fastcgi_cache.conf|include\ /etc/nginx/includes/rules_fastcgi_cache.conf|g" ${VHOST_FILE}
# enable fastcgi_cache conf
run sed -i "s|#include\ /etc/nginx/includes/fastcgi_cache.conf|include\ /etc/nginx/includes/fastcgi_cache.conf|g" ${vhost_file}
run sed -i "s|#include\ /etc/nginx/includes/fastcgi_cache.conf|include\ /etc/nginx/includes/fastcgi_cache.conf|g" ${VHOST_FILE}
else
warning "FastCGI cache is not enabled. There is no cached version of ${FRAMEWORK^} directives."
warning "FastCGI cache is not enabled. There is no cached version of ${FRAMEWORK^} directive."
fi
fi
# Enable PageSpeed?
if [ $ENABLE_PAGESPEED == true ]; then
if [ ${ENABLE_PAGESPEED} == true ]; then
echo "Enable Mod PageSpeed for ${SERVERNAME}..."
if [[ -f /etc/nginx/includes/mod_pagespeed.conf && -f /etc/nginx/modules-enabled/50-mod-pagespeed.conf ]]; then
# enable mod pagespeed
run sed -i "s|#include\ /etc/nginx/includes/mod_pagespeed.conf|include\ /etc/nginx/includes/mod_pagespeed.conf|g" ${vhost_file}
run sed -i "s|#include\ /etc/nginx/includes/mod_pagespeed.conf|include\ /etc/nginx/includes/mod_pagespeed.conf|g" ${VHOST_FILE}
else
warning "Mod PageSpeed is not enabled. Nginx must be installed with PageSpeed module enabled."
warning "PageSpeed is not enabled. Nginx must be installed with Mod_PageSpeed module enabled."
fi
fi
@@ -963,8 +1006,8 @@ function init_app() {
error "Virtual host config file for ${SERVERNAME} is already exists. Aborting..."
fi
else
echo "$APP_NAME: missing optstring argument."
echo "Try '$APP_NAME --help' for more information."
echo "${APP_NAME}: missing optstring argument."
echo "Try '${APP_NAME} --help' for more information."
fi
}