Browse Source

Nginx Configurations Dirs

old-stable
Mitesh Shah 12 years ago
parent
commit
eb9cc68c8d
  1. 20
      conf/nginx/basic.conf
  2. 19
      conf/nginx/singlesite/basic.conf
  3. 48
      conf/nginx/singlesite/w3-total-cache.conf
  4. 64
      setup/engine

20
conf/nginx/basic.conf

@ -1,20 +0,0 @@
server {
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

19
conf/nginx/singlesite/basic.conf

@ -0,0 +1,19 @@
server {
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php index.htm index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}

48
conf/nginx/singlesite/w3-total-cache.conf

@ -0,0 +1,48 @@
server {
server_name example.com www.example.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/htdocs;
index index.php index.htm index.html;
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?$args ;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
location ~ .php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# Cache static files for as long as possible
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max; log_not_found off; access_log off;
}
}

64
setup/engine

@ -15,7 +15,7 @@ fi
# Capture Errors
OwnError()
{
echo -e "[ $0 ][ `date` ] \033[31m $@ \e[0m" | tee -ai $ERRORLOG
echo -e "[ `date` ] \033[31m $@ \e[0m" | tee -ai $ERRORLOG
exit 101
}
@ -30,11 +30,11 @@ EngineHelp()
{
echo
echo "Usage: `basename $0` [OPTION] [ARGUMENTS]..."
echo "Admin tools for Nginx based wordpress sites management."
echo "Usage: `basename $0` [OPTION] [ARGUMENT]..."
echo "Admin tools for nginx based wordpress sites management."
echo
echo "OPTIONS:"
echo "OPTION:"
echo " `basename $0` [system] [install|remove|purge] [nginx|php|mysql|postfix|--all]"
echo
@ -42,7 +42,6 @@ EngineHelp()
echo " `basename $0` [site] [create] [sitename] [--with-wordpress]"
echo " `basename $0` [site] [update] [sitename] []"
echo " `basename $0` [site] [delete] [sitename] [--with-data]"
#echo " `basename $0` [site] [read|craete|update|delete] [sitename]"
echo
echo " `basename $0` [config] [set|get] [memory|timeout]"
@ -54,6 +53,10 @@ EngineHelp()
echo " 101 command failed to execute,"
}
# GET Information Function
GETINFO()
{
@ -88,14 +91,25 @@ GETINFO()
}
NGINXRELOAD()
{
# Test & Reload Nginx
echo -e "\033[34m Reloading nginx, please wait... \e[0m"
nginx -t && service nginx reload || OwnError "Unable to reload nginx"
}
# Pre Checks To Avoid Later Screw Ups
# Checking Logs Directory
if [ ! -d $LOGDIR ]
then
echo -e "\033[34m Creating easyengine log directory... \e[0m"
mkdir -p $LOGDIR || OwnError "Unable to create log directory $LOGDIR"
#else
#echo -e "\033[34m Easyengine log directory found... \e[0m"
fi
# Checking Tee
@ -237,7 +251,7 @@ then
else
EngineHelp
fi
#fi
# Easy Engine Remove
elif [ "$2" = "remove" ]
@ -286,7 +300,7 @@ then
else
EngineHelp
fi
#fi
# Easy Engine Purge
elif [ "$2" = "purge" ]
@ -335,7 +349,7 @@ then
else
EngineHelp
fi
#fi
# Easy Engine Help
else
@ -384,7 +398,6 @@ then
fi
# Easy Engine Create
elif [ "$2" = "create" ]
@ -398,7 +411,7 @@ then
# Creating Site
echo -e "\033[34m Creating $DOMAIN, please wait... \e[0m"
sed "s/example.com/$DOMAIN/g" ../conf/nginx/basic.conf \
sed "s/example.com/$DOMAIN/g" ../conf/nginx/singlesite/basic.conf \
> /etc/nginx/sites-available/$DOMAIN \
|| OwnError "Unable to create configuration file for $DOMAIN"
@ -463,6 +476,8 @@ then
fi
# Reload Nginx Configuration
NGINXRELOAD
else
@ -473,7 +488,28 @@ then
# Easy Engine Update
elif [ "$2" = "update" ]
then
echo "Update"
if [ -n "$3" ]
then
# Remove http:// & www.
DOMAIN=$(echo $3 | sed "s'http://''" | sed "s'www.''")
if [ "$4" = "" ]
then
# Updating Site
else
EngineHelp
fi
else
EnginHelp
fi
# Easy Engine Delete
elif [ "$2" = "delete" ]
@ -487,11 +523,13 @@ then
#echo "Under Developments !!"
# Easy Engine Config Settings
elif [ "$1" = "config" ]
then
echo "Under Developments !!"
# Easy Engine Help
else
EngineHelp
fi

Loading…
Cancel
Save