Commits

Jon Langevin committed f26e375

Adding vhost shell script, and vhost skeleton

Comments (0)

Files changed (10)

.skel/vhost-default/conf/_common.conf

+        # Wildcard is for accepting all requests to domain
+        #server_name DOMAIN *.DOMAIN;
+        server_name DOMAIN;
+
+        root   /var/www/DOMAIN/public/;
+        index  index.php index.html;
+        fastcgi_index  index.php;
+
+        # BLOCKS ACCESS TO . FILES (.svn, .htaccess, ...)
+        location ~ /\. {
+                deny  all;
+        }
+
+        # Basic PHP config
+        #include /var/www/DOMAIN/conf/php.conf;
+
+        # Uncomment the appropriate conf file below
+        # Each file is intended for a different application
+        #include /var/www/DOMAIN/conf/apps/moodle.conf;
+        #include /var/www/DOMAIN/conf/apps/dokuwiki.conf;
+        #include /var/www/DOMAIN/conf/apps/kohanaphp.conf;
+

.skel/vhost-default/conf/_http.conf

+        listen   SERVERIP:80;
+
+        access_log /var/www/DOMAIN/log/access.log;
+        error_log /var/www/DOMAIN/log/error.log warn;

.skel/vhost-default/conf/_https.conf

+        listen   SERVERIP:443;
+
+        ssl	on;
+
+        access_log /var/www/DOMAIN/log/access_ssl.log;
+        error_log /var/www/DOMAIN/log/error_ssl.log warn;

.skel/vhost-default/conf/_php.conf

+        fastcgi_index  index.php;
+
+        # if the request starts with our frontcontroller, pass it on to fastcgi
+        location ~ \.php$
+        {
+                fastcgi_pass 127.0.0.1:9000;
+                include /etc/nginx/fastcgi_params;
+        }

.skel/vhost-default/conf/_status.conf

+        location ~ ^/status$ {
+                include fastcgi_params;
+                fastcgi_pass 127.0.0.1:9000;
+                fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
+                allow 127.0.0.1;
+                # Buenaspace
+                allow 98.101.176.192;
+                deny all;
+        }
+

.skel/vhost-default/conf/apps/dokuwiki.conf

+        location /
+        {
+                # If the file exists as a static file serve it
+                # directly without running all
+                # the other rewite tests on it
+                if ($request_filename ~ "favicon\.ico$") {
+                        break;
+                }
+
+                if (!-f $request_filename) {
+                        rewrite ^(/)_media/(.*) $1lib/exe/fetch.php?media=$2 last;
+                        rewrite ^(/)_detail/(.*) $1lib/exe/detail.php?media=$2 last;
+                        rewrite ^(/)_export/([^/]+)/(.*) $1doku.php?do=export_$2&id=$3 last;
+
+                        rewrite ^(/)(.*)?(.*)  $1doku.php?id=$2&$3 last;
+                        rewrite ^(/)$ $1doku.php last;
+                }
+        }
+
+        # if the request is for doku, pass it on to fastcgi
+        location ~ doku\.php/.*$
+        {
+                include /etc/nginx/fastcgi_params;
+                fastcgi_pass 127.0.0.1:9000;
+        }
+

.skel/vhost-default/conf/apps/kohanaphp.conf

+        location /
+        {
+                location ~* ^/(?:modules|application|system) {
+                        return 403;
+                }
+
+                if (!-e $request_filename)
+                {
+                        rewrite ^/(.*)$ /index.php/$1 last;
+                }
+        }
+
+        # if the request is for kohana, pass it on to fastcgi
+        location ~ index\.php/.*$
+        {
+                include /etc/nginx/fastcgi_params;
+                fastcgi_pass 127.0.0.1:9000;
+        }
+

.skel/vhost-default/conf/apps/moodle.conf

+        location /
+        {
+                # If the file exists as a static file serve it
+                # directly without running all
+                # the other rewite tests on it
+                if ($request_filename ~ "favicon\.ico$") {
+                        break;
+                }
+
+                if (-e $request_filename) {
+                        expires 30d;
+                        break;
+                }
+
+                # If file isn't found
+                if (!-e $request_filename) {
+                        set $filephp 1;
+                }
+
+                # If the missing file is a php folder URL
+                if ($request_filename ~ "\.php/") {
+                        set $filephp "${filephp}1";
+                }
+
+                # Non-existing URL based on PHP script
+                # Rewrite the URL to the base PHP script requesting
+                if ($filephp = 11) {
+                        rewrite  ^(.*)\.php/.*$  /$1.php  last;
+                        break;
+                }
+
+                #if ($filephp = 1) {
+                #       break;
+                #}
+        }

.skel/vhost-default/conf/nginx.conf

+server {
+        include /var/www/DOMAIN/conf/http.conf;
+        include /var/www/DOMAIN/conf/common.conf;
+}
+
+server {
+        include /var/www/DOMAIN/conf/https.conf;
+        include /var/www/DOMAIN/conf/common.conf;
+}
+
+#!/bin/bash
+set -e
+VHOSTDIR=/var/www/
+VHOSTSKEL=/var/www/.skel/vhost-default/
+
+echo -e "Specify the vhost domain name:"
+read VHOST
+
+if [ "$VHOST" = "" ] ; then
+	echo "Invalid domain!"
+	exit 1;
+fi
+
+echo "\nYou typed: $VHOST \n"
+
+IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | grep -v '192.*' | grep -v '10.*' | cut -d: -f2 | awk '{ print $1}'`;
+
+echo -e "Specify the vhost IP from the list of available Public IPs:\n$IP"
+read VHOSTIP
+
+if [ "$VHOSTIP" = "" ] ; then
+        echo "Invalid IP!"
+        exit 1;
+fi
+
+echo "\nYou typed: $VHOSTIP \n"
+
+VHOSTPATH="$VHOSTDIR$VHOST"
+sudo -u www-data cp -Rf "$VHOSTSKEL" "$VHOSTPATH"
+sudo -u www-data ack-grep -l DOMAIN $VHOSTPATH/conf/* | xargs -t -n 1 sed -i -e "s/DOMAIN/$VHOST/g"
+sudo -u www-data ack-grep -l SERVERIP $VHOSTPATH/conf/* | xargs -t -n 1 sed -i -e "s/SERVERIP/$VHOSTIP/g"
+echo "Skeleton copied to \"$VHOSTPATH\""
+