From efbe476ea3c7086d9b2084efced97ff113ba6c74 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 13:58:50 -0500 Subject: [PATCH 001/143] trying to add support for Drupal --- setup-debian.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 48d32eb..215b6d1 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -299,6 +299,7 @@ function install_wordpress { # Setting up the MySQL database dbname=`echo $1 | tr . _` + echo Database Name = 'echo $1 | tr . _' userid=`get_domain_name $1` # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" @@ -327,6 +328,50 @@ END invoke-rc.d nginx reload } +function install_drupal { + check_install wget php5-gd + if [ -z "$1" ] + then + die "Usage: `basename $0` drupal " + fi + + # Downloading the Drupal' latest and greatest distribution. + mkdir /tmp/drupal.$$ + wget -O - http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz | \ + tar zxf - -C /tmp/drupal.$$/ + mkdir /var/www/$1 + cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" + rm -rf /tmp/drupal* + chown root:root -R "/var/www/$1" + + # Setting up the MySQL database + dbname=`echo $1 | tr . _` + userid=`get_domain_name $1` + # MySQL userid cannot be more than 15 characters long + userid="${userid:0:15}" + passwd=`get_password "$userid@mysql"` + cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" + mysqladmin create "$dbname" + echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ + mysql + + # Setting up Nginx mapping + cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Fri, 3 Feb 2012 14:07:02 -0500 Subject: [PATCH 002/143] wrong syntax on install start for Drupal --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 215b6d1..a8fea44 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -442,7 +442,7 @@ system) install_dropbear ;; drupal) - install_drupal + install_drupal $2 ;; wordpress) install_wordpress $2 From 673af070532c5d0012dedce0b7d3e0d4dc5c2f09 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 14:49:48 -0500 Subject: [PATCH 003/143] trying to fix /var/run disappearing act --- setup-debian.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index a8fea44..d5b340c 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -167,9 +167,9 @@ function install_php { PATH=/sbin:/bin:/usr/sbin:/usr/bin NAME="php-cgi" DESC="php-cgi" -PIDFILE="/var/run/www/php.pid" +PIDFILE="/var/lib/www/php.pid" FCGIPROGRAM="/usr/bin/php-cgi" -FCGISOCKET="/var/run/www/php.sock" +FCGISOCKET="/var/lib/www/php.sock" FCGIUSER="www-data" FCGIGROUP="www-data" @@ -222,8 +222,8 @@ esac exit 0 END chmod 755 /etc/init.d/php-cgi - mkdir -p /var/run/www - chown www-data:www-data /var/run/www + mkdir -p /var/lib/www + chown www-data:www-data /var/lib/www cat > /etc/nginx/fastcgi_php <" From 78ff5606c53e3844123f35ce07279ae1e3bdeada Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:01:47 -0500 Subject: [PATCH 004/143] trying to pring DB name, user, pass to screen --- setup-debian.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/setup-debian.sh b/setup-debian.sh index d5b340c..4c37356 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -346,10 +346,18 @@ function install_drupal { # Setting up the MySQL database dbname=`echo $1 | tr . _` + #Echo DB Name + COL_BLUE="\x1b[34;01m" + COL_RESET="\x1b[39;49;00m" + echo -e $COL_BLUE"Database Name: "$COL_RESET"echo $1 | tr . _" userid=`get_domain_name $1` + # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" + # Echo DB USer value + echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" passwd=`get_password "$userid@mysql"` + echo -e $COL_BLUE"Database User: "$COL_RESET"$userid@mysql" cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" mysqladmin create "$dbname" echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ From b7d487bae00125a59db0f35d3c76ce315c4f1aea Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:09:27 -0500 Subject: [PATCH 005/143] fixing syntax on echo for DB name, user, pass --- setup-debian.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 4c37356..e5dc4fc 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -346,10 +346,14 @@ function install_drupal { # Setting up the MySQL database dbname=`echo $1 | tr . _` + + # MySQL dbname cannot be more than 15 characters long + dbname="${dbname:0:15}" + #Echo DB Name COL_BLUE="\x1b[34;01m" COL_RESET="\x1b[39;49;00m" - echo -e $COL_BLUE"Database Name: "$COL_RESET"echo $1 | tr . _" + echo -e $COL_BLUE"Database Name: "$COL_RESET"$(dbname:0:15)" userid=`get_domain_name $1` # MySQL userid cannot be more than 15 characters long @@ -357,7 +361,7 @@ function install_drupal { # Echo DB USer value echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" passwd=`get_password "$userid@mysql"` - echo -e $COL_BLUE"Database User: "$COL_RESET"$userid@mysql" + echo -e $COL_BLUE"Database Password: "$COL_RESET"$userid@mysql" cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" mysqladmin create "$dbname" echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ From c24a57dbe5e49b6f38909f7f901401bc2291904c Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:11:40 -0500 Subject: [PATCH 006/143] fixing syntax on echo for DB name, user, pass --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index e5dc4fc..26c0d72 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -353,7 +353,7 @@ function install_drupal { #Echo DB Name COL_BLUE="\x1b[34;01m" COL_RESET="\x1b[39;49;00m" - echo -e $COL_BLUE"Database Name: "$COL_RESET"$(dbname:0:15)" + echo -e $COL_BLUE"Database Name: "$COL_RESET"$dbname" userid=`get_domain_name $1` # MySQL userid cannot be more than 15 characters long From 85bbfd0ad105566b2a9014905d518baf537235d3 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:16:09 -0500 Subject: [PATCH 007/143] adding php5-gd install --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 26c0d72..31ab448 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -329,7 +329,7 @@ END } function install_drupal { - check_install wget + check_install wget php5-gd if [ -z "$1" ] then die "Usage: `basename $0` drupal " From fea5f04da1e96271caadce40e5dcad39dde6afa3 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:18:55 -0500 Subject: [PATCH 008/143] said it was already installed, so trying apt-get instead --- setup-debian.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 31ab448..57436d7 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -329,11 +329,14 @@ END } function install_drupal { - check_install wget php5-gd + check_install wget if [ -z "$1" ] then die "Usage: `basename $0` drupal " fi + + #Download PHP5-gd package + apt-get -q -y install php5-gd # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ From 5acd8039f723e6c474fc613f190ff5af250cd563 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:22:31 -0500 Subject: [PATCH 009/143] have to restart php-cgi after installing GD --- setup-debian.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 57436d7..5f53683 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -337,7 +337,8 @@ function install_drupal { #Download PHP5-gd package apt-get -q -y install php5-gd - + /etc/init.d/php-cgi restart + # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ wget -O - http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz | \ From e88ec1886959ed440d560d47794e990ba462c587 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:27:34 -0500 Subject: [PATCH 010/143] setting up proper file permissions for settings.php and files dir --- setup-debian.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup-debian.sh b/setup-debian.sh index 5f53683..9eae865 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -367,6 +367,9 @@ function install_drupal { passwd=`get_password "$userid@mysql"` echo -e $COL_BLUE"Database Password: "$COL_RESET"$userid@mysql" cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" + chmod 777 settings.php + mkdir /var/www/$1/sites/default/files + chmod -R 775 /var/www/$1/sites/default/files mysqladmin create "$dbname" echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ mysql From 7aec43bd38053b81f37e36b791a36a9a82419345 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:28:37 -0500 Subject: [PATCH 011/143] fixed typo --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 9eae865..2feed60 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -367,7 +367,7 @@ function install_drupal { passwd=`get_password "$userid@mysql"` echo -e $COL_BLUE"Database Password: "$COL_RESET"$userid@mysql" cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" - chmod 777 settings.php + chmod 777 /var/www/$1/sites/default/settings.php mkdir /var/www/$1/sites/default/files chmod -R 775 /var/www/$1/sites/default/files mysqladmin create "$dbname" From 753d7817df5c98ce45c12400ba323f01507c4351 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:29:53 -0500 Subject: [PATCH 012/143] fixed typo --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 2feed60..5da2833 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -369,7 +369,7 @@ function install_drupal { cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" chmod 777 /var/www/$1/sites/default/settings.php mkdir /var/www/$1/sites/default/files - chmod -R 775 /var/www/$1/sites/default/files + chmod -R 777 /var/www/$1/sites/default/files mysqladmin create "$dbname" echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ mysql From 15057e6ef7e2eb2908d677bbfebbac696901f8f7 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 15:33:17 -0500 Subject: [PATCH 013/143] fixing password echo --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 5da2833..87fd854 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -365,7 +365,7 @@ function install_drupal { # Echo DB USer value echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" passwd=`get_password "$userid@mysql"` - echo -e $COL_BLUE"Database Password: "$COL_RESET"$userid@mysql" + echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" chmod 777 /var/www/$1/sites/default/settings.php mkdir /var/www/$1/sites/default/files From fedf3c81cdf12ffaec27c2af4bd78fb20c81bcac Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 16:03:38 -0500 Subject: [PATCH 014/143] updated readme --- README | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/README b/README index fb2b7bc..2b72a7b 100644 --- a/README +++ b/README @@ -1 +1,44 @@ -FIXME the README! +A simple bash shell script to optimize your Debian or Ubuntu server for serving PHP and MySQL driven website platforms like Drupal and Wordpress. + +Tested on +Ubuntu 10.04 +Debian 5 + +Installation +Download setup-debian.sh. +git clone git://github.com/sk33lz/lowendscript.git + +or + +wget --no-check-certificate https://github.com/sk33lz/lowendscript/raw/master/setup-debian.sh + +Usage +Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) +bash setup-debian.sh system + +Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. +bash setup-debian.sh exim4 + +Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. +bash setup-debian.sh nginx + +Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. +bash setup-debian.sh mysql + +Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. +bash setup-debian.sh php + +Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. +bash setup-debian.sh wordpress blog.example.com + +Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. +bash setup-debian.sh drupal cms.example.com + +Software Stack +dropbear - Replaces openssh. Invoked from xinetd. +inetutils-syslogd - Replaces resyslog. +exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. +cron - Schedule tasks on your server. +nginx - Lightweight httpd replacement for Apache httpd. +mysql - Optimized with innodb and query caching removed. Also a reduced key buffer size. +php - Built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file From f73ab7e0f2e58bcf6eec2ca25848283065e210bb Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 16:06:32 -0500 Subject: [PATCH 015/143] fixing readme to point to lowendbox repo --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 2b72a7b..38a0b47 100644 --- a/README +++ b/README @@ -5,12 +5,12 @@ Ubuntu 10.04 Debian 5 Installation -Download setup-debian.sh. -git clone git://github.com/sk33lz/lowendscript.git +Download setup-debian.sh using one of the following commands. +git clone git://github.com/lowendbox/lowendscript.git or -wget --no-check-certificate https://github.com/sk33lz/lowendscript/raw/master/setup-debian.sh +wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh Usage Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) From a871cfdddde8ad285a5b12bc7b612a18a8156cdb Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 16:11:16 -0500 Subject: [PATCH 016/143] making readme easier to read --- README | 62 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/README b/README index 38a0b47..aca964c 100644 --- a/README +++ b/README @@ -1,10 +1,10 @@ A simple bash shell script to optimize your Debian or Ubuntu server for serving PHP and MySQL driven website platforms like Drupal and Wordpress. -Tested on -Ubuntu 10.04 -Debian 5 +#TESTED ON +* Ubuntu 10.04 +* Debian 5 -Installation +#INSTALLATION Download setup-debian.sh using one of the following commands. git clone git://github.com/lowendbox/lowendscript.git @@ -12,33 +12,27 @@ or wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh -Usage -Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) -bash setup-debian.sh system - -Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. -bash setup-debian.sh exim4 - -Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. -bash setup-debian.sh nginx - -Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. -bash setup-debian.sh mysql - -Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. -bash setup-debian.sh php - -Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. -bash setup-debian.sh wordpress blog.example.com - -Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. -bash setup-debian.sh drupal cms.example.com - -Software Stack -dropbear - Replaces openssh. Invoked from xinetd. -inetutils-syslogd - Replaces resyslog. -exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. -cron - Schedule tasks on your server. -nginx - Lightweight httpd replacement for Apache httpd. -mysql - Optimized with innodb and query caching removed. Also a reduced key buffer size. -php - Built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file +#USAGE +* Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) + bash setup-debian.sh system +* Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. + bash setup-debian.sh exim4 +* Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. + bash setup-debian.sh nginx +* Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. + bash setup-debian.sh mysql +* Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. + bash setup-debian.sh php +* Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. + bash setup-debian.sh wordpress blog.example.com +* Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. + bash setup-debian.sh drupal cms.example.com + +#SOFTWARE STACK +* Dropbear - Replaces openssh. Invoked from xinetd. +* Inetutils-syslogd - Replaces resyslog. +* Exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. +* Cron - Schedule tasks on your server. +* Nginx - Lightweight httpd replacement for Apache httpd. +* MySQL - Optimized with innodb and query caching removed. Also a reduced key buffer size. +* PHP - Optimized PHP built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file From 93777ac546d22a748ba6c383547d58695e93018e Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 16:13:47 -0500 Subject: [PATCH 017/143] making readme easier to read --- README | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/README b/README index aca964c..0619e62 100644 --- a/README +++ b/README @@ -5,7 +5,8 @@ A simple bash shell script to optimize your Debian or Ubuntu server for serving * Debian 5 #INSTALLATION -Download setup-debian.sh using one of the following commands. +Download setup-debian.sh using one of the following commands: + git clone git://github.com/lowendbox/lowendscript.git or @@ -14,19 +15,31 @@ wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master #USAGE * Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) - bash setup-debian.sh system + + bash setup-debian.sh system + * Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. bash setup-debian.sh exim4 + * Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. - bash setup-debian.sh nginx + + bash setup-debian.sh nginx + * Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. - bash setup-debian.sh mysql + + bash setup-debian.sh mysql + * Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. - bash setup-debian.sh php + + bash setup-debian.sh php + * Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. - bash setup-debian.sh wordpress blog.example.com + + bash setup-debian.sh wordpress blog.example.com + * Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. - bash setup-debian.sh drupal cms.example.com + + bash setup-debian.sh drupal cms.example.com #SOFTWARE STACK * Dropbear - Replaces openssh. Invoked from xinetd. @@ -34,5 +47,5 @@ wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master * Exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. * Cron - Schedule tasks on your server. * Nginx - Lightweight httpd replacement for Apache httpd. -* MySQL - Optimized with innodb and query caching removed. Also a reduced key buffer size. +* MySQL - Optimized with innodb and query caching removed with reduced key buffer size. * PHP - Optimized PHP built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file From e3347519e23ec3e11313ee92fda1adac2ad36098 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 16:14:51 -0500 Subject: [PATCH 018/143] making readme easier to read --- README | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README b/README index 0619e62..35ef914 100644 --- a/README +++ b/README @@ -16,30 +16,31 @@ wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master #USAGE * Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) - bash setup-debian.sh system + bash setup-debian.sh system * Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. - bash setup-debian.sh exim4 + + bash setup-debian.sh exim4 * Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. - bash setup-debian.sh nginx + bash setup-debian.sh nginx * Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. - bash setup-debian.sh mysql + bash setup-debian.sh mysql * Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. - bash setup-debian.sh php + bash setup-debian.sh php * Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. - bash setup-debian.sh wordpress blog.example.com + bash setup-debian.sh wordpress blog.example.com * Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. - bash setup-debian.sh drupal cms.example.com + bash setup-debian.sh drupal cms.example.com #SOFTWARE STACK * Dropbear - Replaces openssh. Invoked from xinetd. From 5ff34f0a504abf3b9f2c43b2600260feed452fe0 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 17:53:34 -0500 Subject: [PATCH 019/143] broke out drupal6 and drupal7 installations individually --- setup-debian.sh | 72 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 87fd854..d2d19d4 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -328,7 +328,70 @@ END invoke-rc.d nginx reload } -function install_drupal { +function install_drupal6 { + check_install wget + if [ -z "$1" ] + then + die "Usage: `basename $0` drupal " + fi + + #Download PHP5-gd package + apt-get -q -y install php5-gd + /etc/init.d/php-cgi restart + + # Downloading the Drupal' latest and greatest distribution. + mkdir /tmp/drupal.$$ + wget -O - http://ftp.drupal.org/files/projects/drupal-6.24.tar.gz | \ + tar zxf - -C /tmp/drupal.$$/ + mkdir /var/www/$1 + cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" + rm -rf /tmp/drupal* + chown root:root -R "/var/www/$1" + + # Setting up the MySQL database + dbname=`echo $1 | tr . _` + + # MySQL dbname cannot be more than 15 characters long + dbname="${dbname:0:15}" + + #Echo DB Name + COL_BLUE="\x1b[34;01m" + COL_RESET="\x1b[39;49;00m" + echo -e $COL_BLUE"Database Name: "$COL_RESET"$dbname" + userid=`get_domain_name $1` + + # MySQL userid cannot be more than 15 characters long + userid="${userid:0:15}" + # Echo DB USer value + echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" + passwd=`get_password "$userid@mysql"` + echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" + cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" + chmod 777 /var/www/$1/sites/default/settings.php + mkdir /var/www/$1/sites/default/files + chmod -R 777 /var/www/$1/sites/default/files + mysqladmin create "$dbname" + echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ + mysql + + # Setting up Nginx mapping + cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Fri, 3 Feb 2012 17:54:18 -0500 Subject: [PATCH 020/143] updated readme for d6 and d7 commands --- README | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README b/README index 35ef914..f20bffa 100644 --- a/README +++ b/README @@ -38,9 +38,13 @@ wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master bash setup-debian.sh wordpress blog.example.com -* Install Drupal - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. +* Install Drupal 6 - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. - bash setup-debian.sh drupal cms.example.com + bash setup-debian.sh drupal6 cms.example.com + +* Install Drupal 7 - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. + + bash setup-debian.sh drupal7 cms.example.com #SOFTWARE STACK * Dropbear - Replaces openssh. Invoked from xinetd. From 7c78012fd369ca8bb3e8d0320475c062e639bde7 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 18:32:48 -0500 Subject: [PATCH 021/143] fixed rewrite rule for Drupal for Nginx --- setup-debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index d2d19d4..337c89f 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -383,7 +383,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php last; + rewrite ^(.*)$ /index.php?q=$1 last; } } } @@ -446,7 +446,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php last; + rewrite ^(.*)$ /index.php?q=$1 last; } } } From 335113335003d8920f65f10174f01bca7436a2e5 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 18:41:23 -0500 Subject: [PATCH 022/143] actually fixed rewrite rule for Drupal for Nginx --- setup-debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 337c89f..b619c6c 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -383,7 +383,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=$1 last; + rewrite ^(.*)$ /index.php?q=$request_uri last; } } } @@ -446,7 +446,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=$1 last; + rewrite ^(.*)$ /index.php?q=$request_uri last; } } } From e1338099a556071308969b72bd0c78061f42aafe Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 18:46:16 -0500 Subject: [PATCH 023/143] trying to escape rewrite rule --- setup-debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index b619c6c..57fb171 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -383,7 +383,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=$request_uri last; + rewrite ^(.*)$ /index.php?q=\$1 last; } } } @@ -446,7 +446,7 @@ server { location / { index index.php; if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=$request_uri last; + rewrite ^(.*)$ /index.php?q=\$1 last; } } } From 5ebce168fa19156c9fd3c83f13a24ba1031e3cda Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 18:57:07 -0500 Subject: [PATCH 024/143] updated readme to read easier and with my fork URL for now. --- README | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/README b/README index f20bffa..5464399 100644 --- a/README +++ b/README @@ -7,50 +7,65 @@ A simple bash shell script to optimize your Debian or Ubuntu server for serving #INSTALLATION Download setup-debian.sh using one of the following commands: -git clone git://github.com/lowendbox/lowendscript.git +git clone git://github.com/sk33lz/lowendscript.git or -wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh +wget --no-check-certificate https://github.com/sk33lz/lowendscript/raw/master/setup-debian.sh #USAGE -* Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) +* Install System Tools + - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) bash setup-debian.sh system -* Install Exim4 - Replacement for sendmail - Re-configured to allow Internet delivery. +* Install Exim4 - Replacement for sendmail + - Re-configured to allow Internet delivery. bash setup-debian.sh exim4 -* Install Nginx for HTTP - Low memory footprint httpd replacement for Apache. +* Install Nginx for HTTP + - Low memory footprint httpd replacement for Apache. bash setup-debian.sh nginx -* Install MySQL for Database - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. +* Install MySQL for Database + - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. bash setup-debian.sh mysql -* Install PHP - Built-in FastCGI running only 1 child process with respawn after 5,000 request. +* Install PHP + - Built-in FastCGI running only 1 child process with respawn after 5,000 request. bash setup-debian.sh php -* Install Wordpress - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. +* Install Wordpress + - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. bash setup-debian.sh wordpress blog.example.com -* Install Drupal 6 - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. +* Install Drupal 6 + - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. bash setup-debian.sh drupal6 cms.example.com -* Install Drupal 7 - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. +* Install Drupal 7 + - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. bash setup-debian.sh drupal7 cms.example.com #SOFTWARE STACK -* Dropbear - Replaces openssh. Invoked from xinetd. -* Inetutils-syslogd - Replaces resyslog. -* Exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. -* Cron - Schedule tasks on your server. -* Nginx - Lightweight httpd replacement for Apache httpd. -* MySQL - Optimized with innodb and query caching removed with reduced key buffer size. -* PHP - Optimized PHP built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file +* Dropbear + - Replaces openssh. Invoked from xinetd. +* Inetutils-syslogd + - Replaces resyslog. +* Exim4 + - Replaces sendmail (if installed). Re-configured to allow Internet delivery. +* Cron + - Schedule tasks on your server. +* Nginx + - Lightweight httpd replacement for Apache httpd. +* MySQL + - Optimized with innodb and query caching removed with reduced key buffer size. +* PHP + - Optimized PHP built with FastCGI and only running 1 child process which respawns ever 5,000 requests. \ No newline at end of file From 776645ed2acde289b7e8a1ada5779a20931ac1ec Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 3 Feb 2012 19:00:29 -0500 Subject: [PATCH 025/143] added note to Readme about running as root user --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index 5464399..46f5162 100644 --- a/README +++ b/README @@ -14,6 +14,8 @@ or wget --no-check-certificate https://github.com/sk33lz/lowendscript/raw/master/setup-debian.sh #USAGE +This script should be run by the root user for maximum compatibility. + * Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) From 2857ce059a7b051b2b668cb8dd9960dfad6b09bd Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 13:54:52 -0500 Subject: [PATCH 026/143] trying to use sed to setup settings.php --- setup-debian.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 57fb171..4b4265f 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -362,7 +362,7 @@ function install_drupal6 { # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" - # Echo DB USer value + # Echo DB User value echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" passwd=`get_password "$userid@mysql"` echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" @@ -374,6 +374,11 @@ function install_drupal6 { echo "GRANT ALL PRIVILEGES ON \`$dbname\`.* TO \`$userid\`@localhost IDENTIFIED BY '$passwd';" | \ mysql + #Copy DB Name, User, and Pass to settings.php and set to read only. + sed '90,s/\/username/$userid' /var/www/$1/sites/default/settings.php + sed '90,s/\:password/$passwd' /var/www/$1/sites/default/settings.php + sed '90,s/\databasename/$dbname' /var/www/$1/sites/default/settings.php + # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:00:58 -0500 Subject: [PATCH 027/143] changed syntax on sed command --- setup-debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 4b4265f..a00200d 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,9 +375,9 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed '90,s/\/username/$userid' /var/www/$1/sites/default/settings.php - sed '90,s/\:password/$passwd' /var/www/$1/sites/default/settings.php - sed '90,s/\databasename/$dbname' /var/www/$1/sites/default/settings.php + sed '90,93 s/\/username/$userid' /var/www/$1/sites/default/settings.php + sed '90,93 s/\:password/$passwd' /var/www/$1/sites/default/settings.php + sed '90,93 s/\databasename/$dbname' /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:04:30 -0500 Subject: [PATCH 028/143] needed to terminate substitute command --- setup-debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index a00200d..101a5a7 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,9 +375,9 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed '90,93 s/\/username/$userid' /var/www/$1/sites/default/settings.php - sed '90,93 s/\:password/$passwd' /var/www/$1/sites/default/settings.php - sed '90,93 s/\databasename/$dbname' /var/www/$1/sites/default/settings.php + sed '90,93 s/\/username/$userid/g' /var/www/$1/sites/default/settings.php + sed '90,93 s/\:password/$passwd/g' /var/www/$1/sites/default/settings.php + sed '90,93 s/\databasename/$dbname/g' /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:17:09 -0500 Subject: [PATCH 029/143] wrong syntax for sed --- setup-debian.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 101a5a7..cc8ba47 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,9 +375,9 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed '90,93 s/\/username/$userid/g' /var/www/$1/sites/default/settings.php - sed '90,93 s/\:password/$passwd/g' /var/www/$1/sites/default/settings.php - sed '90,93 s/\databasename/$dbname/g' /var/www/$1/sites/default/settings.php + sed '91 s/\/username/$userid/g' '/var/www/$1/sites/default/settings.php' + sed '91 s/\:password/$passwd/g' '/var/www/$1/sites/default/settings.php' + sed '91 s/\databasename/$dbname/g' '/var/www/$1/sites/default/settings.php' # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:22:54 -0500 Subject: [PATCH 030/143] trying to get sed on one line --- setup-debian.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index cc8ba47..375af17 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,9 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed '91 s/\/username/$userid/g' '/var/www/$1/sites/default/settings.php' - sed '91 s/\:password/$passwd/g' '/var/www/$1/sites/default/settings.php' - sed '91 s/\databasename/$dbname/g' '/var/www/$1/sites/default/settings.php' + sed "91 s/\/username/$userid/g; s/\:password/$passwd/g; s/\databasename/$dbname/g" /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:25:14 -0500 Subject: [PATCH 031/143] typo in db pass --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 375af17..4fc31c5 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed "91 s/\/username/$userid/g; s/\:password/$passwd/g; s/\databasename/$dbname/g" /var/www/$1/sites/default/settings.php + sed "91 s/\/username/$userid/g; s/\:password/\:$passwd/g; s/\databasename/$dbname/g" /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:28:01 -0500 Subject: [PATCH 032/143] fixed a couple syntax errors to get the full db_url to print properly in settings.php --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 4fc31c5..8a54ef0 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed "91 s/\/username/$userid/g; s/\:password/\:$passwd/g; s/\databasename/$dbname/g" /var/www/$1/sites/default/settings.php + sed "91 s/username/$userid/g; 91 s/password/$passwd/g; 91 s/databasename/$dbname/g" /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:30:51 -0500 Subject: [PATCH 033/143] isn't printing to file, trying different syntax for file location --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 8a54ef0..ac210e0 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed "91 s/username/$userid/g; 91 s/password/$passwd/g; 91 s/databasename/$dbname/g" /var/www/$1/sites/default/settings.php + sed "91 s/username/$userid/g; 91 s/password/$passwd/g; 91 s/databasename/$dbname/g" "/var/www/$1/sites/default/settings.php" # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:38:15 -0500 Subject: [PATCH 034/143] removed global flag --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index ac210e0..bcefa5c 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed "91 s/username/$userid/g; 91 s/password/$passwd/g; 91 s/databasename/$dbname/g" "/var/www/$1/sites/default/settings.php" + sed -e "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" "/var/www/$1/sites/default/settings.php" # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:40:54 -0500 Subject: [PATCH 035/143] escaping quotes on file location --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index bcefa5c..e2e8aa8 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed -e "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" "/var/www/$1/sites/default/settings.php" + sed -e "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" \ "/var/www/$1/sites/default/settings.php" # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:50:17 -0500 Subject: [PATCH 036/143] trying to get syntax right to write to file actually --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index e2e8aa8..a74abea 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -375,7 +375,7 @@ function install_drupal6 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed -e "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" \ "/var/www/$1/sites/default/settings.php" + sed -i "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" "/var/www/$1/sites/default/settings.php" # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 14:59:53 -0500 Subject: [PATCH 037/143] added some help echoes --- setup-debian.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index a74abea..e2667be 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -354,18 +354,14 @@ function install_drupal6 { # MySQL dbname cannot be more than 15 characters long dbname="${dbname:0:15}" - #Echo DB Name - COL_BLUE="\x1b[34;01m" - COL_RESET="\x1b[39;49;00m" - echo -e $COL_BLUE"Database Name: "$COL_RESET"$dbname" + userid=`get_domain_name $1` # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" - # Echo DB User value - echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" + passwd=`get_password "$userid@mysql"` - echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" + cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" chmod 777 /var/www/$1/sites/default/settings.php mkdir /var/www/$1/sites/default/files @@ -392,6 +388,22 @@ server { } END invoke-rc.d nginx reload + + + #Echo DB Name + echo -e $COL_BLUE"*** COPY FOR SAFE KEEPING ***" + COL_BLUE="\x1b[34;01m" + COL_RESET="\x1b[39;49;00m" + echo -e $COL_BLUE"Database Name: "$COL_RESET"$dbname" + + #Echo DB User value + echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" + + #Echo DB Password + echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" + + #Echo Install URL + echo -e $COL_BLUE"Visit: http://$1/install.php to finalize your Drupal 6 installation." } function install_drupal7 { From 514733b95fc2360165be42bb9f72c2d37153a980 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 15:04:06 -0500 Subject: [PATCH 038/143] set chmod 644 on settings.php after writing DB info --- setup-debian.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index e2667be..8a820b7 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -353,15 +353,10 @@ function install_drupal6 { # MySQL dbname cannot be more than 15 characters long dbname="${dbname:0:15}" - - userid=`get_domain_name $1` - # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" - passwd=`get_password "$userid@mysql"` - cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" chmod 777 /var/www/$1/sites/default/settings.php mkdir /var/www/$1/sites/default/files @@ -372,7 +367,7 @@ function install_drupal6 { #Copy DB Name, User, and Pass to settings.php and set to read only. sed -i "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" "/var/www/$1/sites/default/settings.php" - + chmod 644 /var/www/$1/sites/default/settings.php # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 15:06:15 -0500 Subject: [PATCH 039/143] fixing color on output for help text --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 8a820b7..7d9b680 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -398,7 +398,7 @@ END echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" #Echo Install URL - echo -e $COL_BLUE"Visit: http://$1/install.php to finalize your Drupal 6 installation." + echo -e $COL_BLUE"Visit to finalize installation: http://$1/install.php" } function install_drupal7 { From 6d9f5f09693d810245610e732d33582ad122637a Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 15:07:02 -0500 Subject: [PATCH 040/143] fixing color on output for help text --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 7d9b680..82e9ad0 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -398,7 +398,7 @@ END echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" #Echo Install URL - echo -e $COL_BLUE"Visit to finalize installation: http://$1/install.php" + echo -e $COL_BLUE"Visit to finalize installation: "$COL_RESET"http://$1/install.php" } function install_drupal7 { From 124aeae1882da1bd3b02bbc94ec2836ded8769c6 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 22:01:31 -0500 Subject: [PATCH 041/143] updated options for drupal6 and drupal7 commands --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 82e9ad0..9da5a28 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -545,7 +545,7 @@ wordpress) *) echo 'Usage:' `basename $0` '[option]' echo 'Available option:' - for option in system exim4 mysql nginx php wordpress drupal + for option in system exim4 mysql nginx php wordpress drupal6 drupal7 do echo ' -' $option done From 9ba6a2867e44dcdeeedd5150abc7c48d77f342c1 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 22:25:29 -0500 Subject: [PATCH 042/143] added d7 settings.php functionality --- setup-debian.sh | 51 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 9da5a28..4454e60 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -353,8 +353,10 @@ function install_drupal6 { # MySQL dbname cannot be more than 15 characters long dbname="${dbname:0:15}" - userid=`get_domain_name $1` - # MySQL userid cannot be more than 15 characters long + + userid=`get_domain_name $1` + + # MySQL userid cannot be more than 15 characters long userid="${userid:0:15}" passwd=`get_password "$userid@mysql"` cp "/var/www/$1/sites/default/default.settings.php" "/var/www/$1/sites/default/settings.php" @@ -368,7 +370,8 @@ function install_drupal6 { #Copy DB Name, User, and Pass to settings.php and set to read only. sed -i "91 s/username/$userid/; 91 s/password/$passwd/; 91 s/databasename/$dbname/" "/var/www/$1/sites/default/settings.php" chmod 644 /var/www/$1/sites/default/settings.php - # Setting up Nginx mapping + + # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < "/var/www/$1/sites/default/settings.php" < 'mysql', + 'database' => '$dbname', + 'username' => '$userid', + 'password' => '$passwd', + 'host' => 'localhost', +); +END + chmod 644 /var/www/$1/sites/default/settings.php + + #Echo DB Name + echo -e $COL_BLUE"*** COPY FOR SAFE KEEPING ***" + COL_BLUE="\x1b[34;01m" + COL_RESET="\x1b[39;49;00m" + echo -e $COL_BLUE"Database Name: "$COL_RESET"$dbname" + + #Echo DB User value + echo -e $COL_BLUE"Database User: "$COL_RESET"${userid:0:15}" + + #Echo DB Password + echo -e $COL_BLUE"Database Password: "$COL_RESET"$passwd" + + #Echo Install URL + echo -e $COL_BLUE"Visit to finalize installation: "$COL_RESET"http://$1/install.php" + +} # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 22:29:56 -0500 Subject: [PATCH 043/143] fixing typo --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 4454e60..f825d9f 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -474,7 +474,7 @@ END #Echo Install URL echo -e $COL_BLUE"Visit to finalize installation: "$COL_RESET"http://$1/install.php" -} + # Setting up Nginx mapping cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Mon, 6 Feb 2012 22:47:41 -0500 Subject: [PATCH 044/143] changing from cat to sed --- setup-debian.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index f825d9f..59612ba 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -448,15 +448,12 @@ function install_drupal7 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - cat > "/var/www/$1/sites/default/settings.php" < 'mysql', 'database' => '$dbname', 'username' => '$userid', 'password' => '$passwd', - 'host' => 'localhost', -); -END + 'host' => 'localhost'," "/var/www/$1/sites/default/settings.php" chmod 644 /var/www/$1/sites/default/settings.php #Echo DB Name From 8be7b4ee2e5b9372c777b923cb7c21897f1c2e1b Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 22:56:07 -0500 Subject: [PATCH 045/143] changing from sed to echo --- setup-debian.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 59612ba..9fca17c 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -448,12 +448,12 @@ function install_drupal7 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - sed -i "1i $databases['default']['default'] = array( - 'driver' => 'mysql', - 'database' => '$dbname', - 'username' => '$userid', - 'password' => '$passwd', - 'host' => 'localhost'," "/var/www/$1/sites/default/settings.php" + echo "$databases['default']['default'] = array(" /var/www/$1/sites/default/settings.php + echo "'driver' => 'mysql'," /var/www/$1/sites/default/settings.php + echo "'database' => '$dbname'," /var/www/$1/sites/default/settings.php + echo "'username' => '$userid'," /var/www/$1/sites/default/settings.php + echo "'password' => '$passwd'," /var/www/$1/sites/default/settings.php + echo "'host' => 'localhost'," /var/www/$1/sites/default/settings.php chmod 644 /var/www/$1/sites/default/settings.php #Echo DB Name From f5d6f68fcdb3eaf9be729472ce1544f92cdf2cd5 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 22:58:58 -0500 Subject: [PATCH 046/143] wrong syntax for echo --- setup-debian.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 9fca17c..1193ad5 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -448,12 +448,12 @@ function install_drupal7 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - echo "$databases['default']['default'] = array(" /var/www/$1/sites/default/settings.php - echo "'driver' => 'mysql'," /var/www/$1/sites/default/settings.php - echo "'database' => '$dbname'," /var/www/$1/sites/default/settings.php - echo "'username' => '$userid'," /var/www/$1/sites/default/settings.php - echo "'password' => '$passwd'," /var/www/$1/sites/default/settings.php - echo "'host' => 'localhost'," /var/www/$1/sites/default/settings.php + echo "$databases['default']['default'] = array(" > /var/www/$1/sites/default/settings.php + echo "'driver' => 'mysql'," > /var/www/$1/sites/default/settings.php + echo "'database' => '$dbname'," > /var/www/$1/sites/default/settings.php + echo "'username' => '$userid'," > /var/www/$1/sites/default/settings.php + echo "'password' => '$passwd'," > /var/www/$1/sites/default/settings.php + echo "'host' => 'localhost'," > /var/www/$1/sites/default/settings.php chmod 644 /var/www/$1/sites/default/settings.php #Echo DB Name From 87a108f4868184ec4d7a75ec445c7444790f337a Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 23:01:21 -0500 Subject: [PATCH 047/143] wrong syntax for echo --- setup-debian.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 1193ad5..583fdeb 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -448,12 +448,12 @@ function install_drupal7 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - echo "$databases['default']['default'] = array(" > /var/www/$1/sites/default/settings.php - echo "'driver' => 'mysql'," > /var/www/$1/sites/default/settings.php - echo "'database' => '$dbname'," > /var/www/$1/sites/default/settings.php - echo "'username' => '$userid'," > /var/www/$1/sites/default/settings.php - echo "'password' => '$passwd'," > /var/www/$1/sites/default/settings.php - echo "'host' => 'localhost'," > /var/www/$1/sites/default/settings.php + echo "$databases['default']['default'] = array(" >> /var/www/$1/sites/default/settings.php + echo "'driver' => 'mysql'," >> /var/www/$1/sites/default/settings.php + echo "'database' => '$dbname'," >> /var/www/$1/sites/default/settings.php + echo "'username' => '$userid'," >> /var/www/$1/sites/default/settings.php + echo "'password' => '$passwd'," >> /var/www/$1/sites/default/settings.php + echo "'host' => 'localhost'," >> /var/www/$1/sites/default/settings.php chmod 644 /var/www/$1/sites/default/settings.php #Echo DB Name From cd2a494facef18eaa1b447095cd6bb22d3d3518e Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 23:04:34 -0500 Subject: [PATCH 048/143] trying to escape variable --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 583fdeb..82e48f0 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -448,7 +448,7 @@ function install_drupal7 { mysql #Copy DB Name, User, and Pass to settings.php and set to read only. - echo "$databases['default']['default'] = array(" >> /var/www/$1/sites/default/settings.php + echo "\$databases['default']['default'] = array(" >> /var/www/$1/sites/default/settings.php echo "'driver' => 'mysql'," >> /var/www/$1/sites/default/settings.php echo "'database' => '$dbname'," >> /var/www/$1/sites/default/settings.php echo "'username' => '$userid'," >> /var/www/$1/sites/default/settings.php From 3ee9a0030d4fb9b571bfa2fea4da3021a7da1b1f Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 6 Feb 2012 23:08:07 -0500 Subject: [PATCH 049/143] closing databases variable in echo --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 82e48f0..604ba5d 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -453,7 +453,7 @@ function install_drupal7 { echo "'database' => '$dbname'," >> /var/www/$1/sites/default/settings.php echo "'username' => '$userid'," >> /var/www/$1/sites/default/settings.php echo "'password' => '$passwd'," >> /var/www/$1/sites/default/settings.php - echo "'host' => 'localhost'," >> /var/www/$1/sites/default/settings.php + echo "'host' => 'localhost');" >> /var/www/$1/sites/default/settings.php chmod 644 /var/www/$1/sites/default/settings.php #Echo DB Name From 774f37f0d52a3197e4b57a60894d3a7b1c5a83df Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Fri, 10 Feb 2012 22:55:30 -0500 Subject: [PATCH 050/143] added more to Nginx setup for Drupal 6 and 7 --- setup-debian.sh | 160 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 150 insertions(+), 10 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 604ba5d..f8455fd 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -377,12 +377,82 @@ server { server_name $1; root /var/www/$1; include /etc/nginx/fastcgi_php; - location / { - index index.php; - if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=\$1 last; + # common Drupal configuration options. +# Make sure to set $socket to a fastcgi socket. + + location = /favicon.ico { + log_not_found off; + access_log off; } - } + + ### + ### support for http://drupal.org/project/robotstxt module + ### + location = /robots.txt { + access_log off; + try_files $uri @drupal; + } + + # no access to php files in subfolders. + location ~ .+/.*\.php$ { + return 403; + } + + location ~* \.(inc|engine|install|info|module|sh|sql|theme|tpl\.php|xtmpl|Entries|Repository|Root|jar|java|class)$ { + deny all; + } + + location ~ \.php$ { + # Required for private files, otherwise they slow down extremely. + keepalive_requests 0; + } + + # private files protection + location ~ ^/sites/.*/private/ { + access_log off; + deny all; + } + + location ~* ^(?!/system/files).*\.(js|css|png|jpg|jpeg|gif|ico)$ { + # If the image does not exist, maybe it must be generated by drupal (imagecache) + try_files $uri @drupal; + expires 7d; + log_not_found off; + } + + ### + ### deny direct access to backups + ### + location ~* ^/sites/.*/files/backup_migrate/ { + access_log off; + deny all; + } + + location ~ ^/(.*) { + try_files $uri /index.php?q=$1&$args; + } + + location @drupal { + # Some modules enforce no slash (/) at the end of the URL + # Else this rewrite block wouldn't be needed (GlobalRedirect) + rewrite ^/(.*)$ /index.php?q=$1; + } +#And here is the configuration for passing the request to PHP FastCGI (fastcgi.conf): + +# common fastcgi configuration for PHP files + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors on; + # workaround as fastcgi_param cannot be used inside if statements + set $https ""; + if ($scheme = https) { + set $https on; + } + fastcgi_param HTTPS $https; + fastcgi_read_timeout 6000; } END invoke-rc.d nginx reload @@ -479,12 +549,82 @@ server { server_name $1; root /var/www/$1; include /etc/nginx/fastcgi_php; - location / { - index index.php; - if (!-e \$request_filename) { - rewrite ^(.*)$ /index.php?q=\$1 last; + # common Drupal configuration options. +# Make sure to set $socket to a fastcgi socket. + + location = /favicon.ico { + log_not_found off; + access_log off; } - } + + ### + ### support for http://drupal.org/project/robotstxt module + ### + location = /robots.txt { + access_log off; + try_files $uri @drupal; + } + + # no access to php files in subfolders. + location ~ .+/.*\.php$ { + return 403; + } + + location ~* \.(inc|engine|install|info|module|sh|sql|theme|tpl\.php|xtmpl|Entries|Repository|Root|jar|java|class)$ { + deny all; + } + + location ~ \.php$ { + # Required for private files, otherwise they slow down extremely. + keepalive_requests 0; + } + + # private files protection + location ~ ^/sites/.*/private/ { + access_log off; + deny all; + } + + location ~* ^(?!/system/files).*\.(js|css|png|jpg|jpeg|gif|ico)$ { + # If the image does not exist, maybe it must be generated by drupal (imagecache) + try_files $uri @drupal; + expires 7d; + log_not_found off; + } + + ### + ### deny direct access to backups + ### + location ~* ^/sites/.*/files/backup_migrate/ { + access_log off; + deny all; + } + + location ~ ^/(.*) { + try_files $uri /index.php?q=$1&$args; + } + + location @drupal { + # Some modules enforce no slash (/) at the end of the URL + # Else this rewrite block wouldn't be needed (GlobalRedirect) + rewrite ^/(.*)$ /index.php?q=$1; + } +#And here is the configuration for passing the request to PHP FastCGI (fastcgi.conf): + +# common fastcgi configuration for PHP files + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors on; + # workaround as fastcgi_param cannot be used inside if statements + set $https ""; + if ($scheme = https) { + set $https on; + } + fastcgi_param HTTPS $https; + fastcgi_read_timeout 6000; } END invoke-rc.d nginx reload From cba981005a76961cf03ba445db4ca585ae11f0b3 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Mon, 20 Feb 2012 17:40:47 -0500 Subject: [PATCH 051/143] escaping all $ in the nginx config, was being substitued like a varible out in some cases adding the site url where it should not --- setup-debian.sh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index f8455fd..88cf13a 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -390,7 +390,7 @@ server { ### location = /robots.txt { access_log off; - try_files $uri @drupal; + try_files \$uri @drupal; } # no access to php files in subfolders. @@ -415,7 +415,7 @@ server { location ~* ^(?!/system/files).*\.(js|css|png|jpg|jpeg|gif|ico)$ { # If the image does not exist, maybe it must be generated by drupal (imagecache) - try_files $uri @drupal; + try_files \$uri @drupal; expires 7d; log_not_found off; } @@ -429,13 +429,13 @@ server { } location ~ ^/(.*) { - try_files $uri /index.php?q=$1&$args; + try_files \$uri /index.php?q=\$1&\$args; } location @drupal { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) - rewrite ^/(.*)$ /index.php?q=$1; + rewrite ^/(.*)$ /index.php?q=\$1; } #And here is the configuration for passing the request to PHP FastCGI (fastcgi.conf): @@ -444,14 +444,14 @@ server { fastcgi_split_path_info ^(.+\.php)(/.+)$; #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_intercept_errors on; # workaround as fastcgi_param cannot be used inside if statements - set $https ""; - if ($scheme = https) { - set $https on; + set \$https ""; + if (\$scheme = https) { + set \$https on; } - fastcgi_param HTTPS $https; + fastcgi_param HTTPS \$https; fastcgi_read_timeout 6000; } END @@ -562,7 +562,7 @@ server { ### location = /robots.txt { access_log off; - try_files $uri @drupal; + try_files \$uri @drupal; } # no access to php files in subfolders. @@ -587,7 +587,7 @@ server { location ~* ^(?!/system/files).*\.(js|css|png|jpg|jpeg|gif|ico)$ { # If the image does not exist, maybe it must be generated by drupal (imagecache) - try_files $uri @drupal; + try_files \$uri @drupal; expires 7d; log_not_found off; } @@ -601,13 +601,13 @@ server { } location ~ ^/(.*) { - try_files $uri /index.php?q=$1&$args; + try_files \$uri /index.php?q=\$1&\$args; } location @drupal { # Some modules enforce no slash (/) at the end of the URL # Else this rewrite block wouldn't be needed (GlobalRedirect) - rewrite ^/(.*)$ /index.php?q=$1; + rewrite ^/(.*)$ /index.php?q=\$1; } #And here is the configuration for passing the request to PHP FastCGI (fastcgi.conf): @@ -616,14 +616,14 @@ server { fastcgi_split_path_info ^(.+\.php)(/.+)$; #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_intercept_errors on; # workaround as fastcgi_param cannot be used inside if statements - set $https ""; - if ($scheme = https) { - set $https on; + set \$https ""; + if (\$scheme = https) { + set \$https on; } - fastcgi_param HTTPS $https; + fastcgi_param HTTPS \$https; fastcgi_read_timeout 6000; } END From 582f27b387d253a348db05eec51da2e99a4861c9 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Wed, 22 Feb 2012 19:26:02 -0500 Subject: [PATCH 052/143] adding ability to add html site easilY --- setup-debian.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 88cf13a..8b007c0 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -328,6 +328,24 @@ END invoke-rc.d nginx reload } +function install_htmlsite { + # Setting up Nginx mapping + cat > "/etc/nginx/sites-enabled/$1.conf" < Date: Wed, 22 Feb 2012 19:33:53 -0500 Subject: [PATCH 053/143] added default index.html file --- setup-debian.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 8b007c0..153718e 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -329,7 +329,15 @@ END } function install_htmlsite { - # Setting up Nginx mapping + # Setup folder + mkdir /var/www/$1 + + # Setup default index.html file + cat > "/var/www/$1/index.html" < "/etc/nginx/sites-enabled/$1.conf" < Date: Thu, 21 Jun 2012 16:52:25 -0400 Subject: [PATCH 054/143] updated for latest Drupal versions, and removed buggy HTTPS code --- setup-debian.sh | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 153718e..1ce1c61 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -367,7 +367,7 @@ function install_drupal6 { # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ - wget -O - http://ftp.drupal.org/files/projects/drupal-6.24.tar.gz | \ + wget -O - http://ftp.drupal.org/files/projects/drupal-6.26.tar.gz | \ tar zxf - -C /tmp/drupal.$$/ mkdir /var/www/$1 cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" @@ -472,12 +472,6 @@ server { include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_intercept_errors on; - # workaround as fastcgi_param cannot be used inside if statements - set \$https ""; - if (\$scheme = https) { - set \$https on; - } - fastcgi_param HTTPS \$https; fastcgi_read_timeout 6000; } END @@ -513,7 +507,7 @@ function install_drupal7 { # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ - wget -O - http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz | \ + wget -O - http://ftp.drupal.org/files/projects/drupal-7.14.tar.gz | \ tar zxf - -C /tmp/drupal.$$/ mkdir /var/www/$1 cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" @@ -644,12 +638,6 @@ server { include fastcgi_params; fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name; fastcgi_intercept_errors on; - # workaround as fastcgi_param cannot be used inside if statements - set \$https ""; - if (\$scheme = https) { - set \$https on; - } - fastcgi_param HTTPS \$https; fastcgi_read_timeout 6000; } END From 069d78e110cfd60c2b7ea0d9e4b11a353911eae7 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Thu, 21 Jun 2012 17:09:38 -0400 Subject: [PATCH 055/143] updated README with more info --- README | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/README b/README index 46f5162..92624f1 100644 --- a/README +++ b/README @@ -1,8 +1,8 @@ -A simple bash shell script to optimize your Debian or Ubuntu server for serving PHP and MySQL driven website platforms like Drupal and Wordpress. +A simple bash shell script to optimize your Debian or Ubuntu VPS server for serving PHP and MySQL driven website platforms like Drupal and Wordpress. #TESTED ON -* Ubuntu 10.04 -* Debian 5 +* Ubuntu 10.04 LTS, Ubuntu 12.04 LTS +* Debian 5, Debian 6 #INSTALLATION Download setup-debian.sh using one of the following commands: @@ -18,43 +18,43 @@ This script should be run by the root user for maximum compatibility. * Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) - +Command: bash setup-debian.sh system -* Install Exim4 - Replacement for sendmail - - Re-configured to allow Internet delivery. - +* Install Exim4 Mail Server + - Lightweight replacement for sendmail. Re-configured to allow Internet delivery. +Command: bash setup-debian.sh exim4 -* Install Nginx for HTTP - - Low memory footprint httpd replacement for Apache. - +* Install Nginx HTTP Server + - Low memory footprint httpd replacement for Apache web server. +Command: bash setup-debian.sh nginx -* Install MySQL for Database +* Install MySQL Database Server - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. - +Command: bash setup-debian.sh mysql -* Install PHP +* Install PHP FastCGI. - Built-in FastCGI running only 1 child process with respawn after 5,000 request. - +Command: bash setup-debian.sh php * Install Wordpress - - Installs the latet version of Wordpress and creates DB, DB user, and DB user pass. - - bash setup-debian.sh wordpress blog.example.com + - Installs the latet version of Wordpress. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password. +Example Command: (Creates a Wordpress site for example.com in /var/www/) + bash setup-debian.sh wordpress example.com * Install Drupal 6 - - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. - - bash setup-debian.sh drupal6 cms.example.com + - Installs the latest version of Drupal 6. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password.. +Example Command: (Creates a Drupal 6 installation for example.com in /var/www/example.com) + bash setup-debian.sh drupal6 example.com * Install Drupal 7 - - Installs the latest version of Drupal 7 and creates DB, DB user, and DB user pass. - - bash setup-debian.sh drupal7 cms.example.com + - Installs the latest version of Drupal 7. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password.. +Example Command: (Creates a Drupal 7 installation for example.com in /var/www/example.com) + bash setup-debian.sh drupal7 example.com #SOFTWARE STACK * Dropbear @@ -64,9 +64,9 @@ This script should be run by the root user for maximum compatibility. * Exim4 - Replaces sendmail (if installed). Re-configured to allow Internet delivery. * Cron - - Schedule tasks on your server. + - Schedule tasks on your server, similar to that of the task manager in Windows. * Nginx - - Lightweight httpd replacement for Apache httpd. + - Lightweight httpd replacement for Apache web server. * MySQL - Optimized with innodb and query caching removed with reduced key buffer size. * PHP From 74b784e062607d5d45a782b62d4b5aeae4d02da4 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Thu, 21 Jun 2012 17:11:20 -0400 Subject: [PATCH 056/143] updated README with more info --- README | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/README b/README index 92624f1..016c72f 100644 --- a/README +++ b/README @@ -18,42 +18,58 @@ This script should be run by the root user for maximum compatibility. * Install System Tools - Installs Dropbear, cron, and inetutils-syslog (replaces rsyslog) -Command: + + Command: + bash setup-debian.sh system * Install Exim4 Mail Server - Lightweight replacement for sendmail. Re-configured to allow Internet delivery. -Command: + + Command: + bash setup-debian.sh exim4 * Install Nginx HTTP Server - Low memory footprint httpd replacement for Apache web server. -Command: + + Command: + bash setup-debian.sh nginx * Install MySQL Database Server - Re-configured to remove innodb support, remove query cache, and reduce key buffer size. -Command: + + Command: + bash setup-debian.sh mysql * Install PHP FastCGI. - Built-in FastCGI running only 1 child process with respawn after 5,000 request. -Command: + + Command: + bash setup-debian.sh php * Install Wordpress - Installs the latet version of Wordpress. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password. -Example Command: (Creates a Wordpress site for example.com in /var/www/) + + Example Command: (Creates a Wordpress site for example.com in /var/www/) + bash setup-debian.sh wordpress example.com * Install Drupal 6 - Installs the latest version of Drupal 6. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password.. -Example Command: (Creates a Drupal 6 installation for example.com in /var/www/example.com) + + Example Command: (Creates a Drupal 6 installation for example.com in /var/www/example.com) + bash setup-debian.sh drupal6 example.com * Install Drupal 7 - Installs the latest version of Drupal 7. Then creates the Virtual Host configuration for the domain supplied in the command, the MySQL Database, the Database User, and the Database User Password.. -Example Command: (Creates a Drupal 7 installation for example.com in /var/www/example.com) + + Example Command: (Creates a Drupal 7 installation for example.com in /var/www/example.com) + bash setup-debian.sh drupal7 example.com #SOFTWARE STACK From 4d5bf0564b3e5cf1870f9893e86cb53923614460 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Sat, 15 Sep 2012 02:50:31 -0400 Subject: [PATCH 057/143] updated for D7.15 --- setup-debian.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup-debian.sh b/setup-debian.sh index 1ce1c61..677b8c2 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -507,7 +507,7 @@ function install_drupal7 { # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ - wget -O - http://ftp.drupal.org/files/projects/drupal-7.14.tar.gz | \ + wget -O - http://ftp.drupal.org/files/projects/drupal-7.15.tar.gz | \ tar zxf - -C /tmp/drupal.$$/ mkdir /var/www/$1 cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" From 4be6cfb01d8c016052a6e841e21cdaf479192d77 Mon Sep 17 00:00:00 2001 From: Jason Moore Date: Thu, 11 Oct 2012 16:45:25 -0400 Subject: [PATCH 058/143] updated for Drupal 6.26, 7.15, and added Magento support --- setup-debian.sh | 98 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/setup-debian.sh b/setup-debian.sh index 153718e..a8a985e 100755 --- a/setup-debian.sh +++ b/setup-debian.sh @@ -367,7 +367,7 @@ function install_drupal6 { # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ - wget -O - http://ftp.drupal.org/files/projects/drupal-6.24.tar.gz | \ + wget -O - http://ftp.drupal.org/files/projects/drupal-6.26.tar.gz | \ tar zxf - -C /tmp/drupal.$$/ mkdir /var/www/$1 cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" @@ -513,7 +513,7 @@ function install_drupal7 { # Downloading the Drupal' latest and greatest distribution. mkdir /tmp/drupal.$$ - wget -O - http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz | \ + wget -O - http://ftp.drupal.org/files/projects/drupal-7.15.tar.gz | \ tar zxf - -C /tmp/drupal.$$/ mkdir /var/www/$1 cp -Rf /tmp/drupal.$$/drupal*/* "/var/www/$1" @@ -656,6 +656,100 @@ END invoke-rc.d nginx reload } +function install_magento { + ##Check for Wget + check_install wget + if [ -z "$1" ] + then + die "Usage: `basename $0` magento " + fi + #Download PHP5-gd package + apt-get -q -y install php5-gd + /etc/init.d/php-cgi restart + + # Downloading the Magento's latest and greatest distribution. + mkdir /tmp/magento.$$ + wget -O - http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz | \ + tar zxf - -C /tmp/magento.$$/ + mkdir /var/www/$1 + cp -Rf /tmp/magento.$$/magento*/* "/var/www/$1" + rm -rf /tmp/magento* + chown root:root -R "/var/www/$1" + + # Setting up the MySQL database + dbname=`echo $1 | tr . _` + + # MySQL dbname cannot be more than 15 characters long + dbname="${dbname:0:15}" + userid=`get_domain_name $1` + + # MySQL userid cannot be more than 15 characters long + userid="${userid:0:15}" + passwd=`get_password "$userid@mysql"` + + # Setup Nginx Magento config file for domain. + cat > "/etc/nginx/sites-enabled/magento/$1.conf" <