<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: apache code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 12 May 2008 02:18:40 GMT</pubDate>
    <description>DZone Snippets: apache code</description>
    <item>
      <title>Deploying on a passenger / mod_rails host with capistrano</title>
      <link>http://snippets.dzone.com/posts/show/5466</link>
      <description>// add this to deploy.rb&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;namespace :mod_rails do&lt;br /&gt;  desc &lt;&lt;-DESC&lt;br /&gt;  Restart the application altering tmp/restart.txt for mod_rails.&lt;br /&gt;  DESC&lt;br /&gt;  task :restart, :roles =&gt; :app do&lt;br /&gt;    run "touch  #{release_path}/tmp/restart.txt"&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;namespace :deploy do&lt;br /&gt;  %w(start restart).each { |name| task name, :roles =&gt; :app do mod_rails.restart end }&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 06 May 2008 05:25:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5466</guid>
      <author>jerome ()</author>
    </item>
    <item>
      <title>Split Apache logs according to GeoIP country</title>
      <link>http://snippets.dzone.com/posts/show/5255</link>
      <description>// Split Apache logs according to GeoIP country&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/perl&lt;br /&gt;&lt;br /&gt;# $Id$&lt;br /&gt;&lt;br /&gt;# Split Apache logs according to GeoIP country&lt;br /&gt;&lt;br /&gt;use strict;&lt;br /&gt;use warnings;&lt;br /&gt;&lt;br /&gt;## no critic (ValuesAndExpressions::RequireInterpolationOfMetachars)&lt;br /&gt;our ($VERSION) = '$Revision$' =~ m{ \$Revision: \s+ (\S+) }xms;&lt;br /&gt;## use critic&lt;br /&gt;&lt;br /&gt;use Geo::IP;&lt;br /&gt;&lt;br /&gt;my $gi = Geo::IP-&gt;open('/usr/local/share/GeoIP/GeoIPCity.dat', GEOIP_STANDARD);&lt;br /&gt;&lt;br /&gt;my @logs = @ARGV;&lt;br /&gt;&lt;br /&gt;my %record_for;&lt;br /&gt;&lt;br /&gt;foreach my $log (@logs) {&lt;br /&gt;    die "Can't read $log\n" if !-r $log;&lt;br /&gt;    &lt;br /&gt;    my %fh_for;&lt;br /&gt;    my $num_lines_parsed = 0;&lt;br /&gt;    &lt;br /&gt;    my $log_fh;&lt;br /&gt;    if ($log =~ m/ \.gz \z /xms) {&lt;br /&gt;        open $log_fh, "gzip -cd $log |" or die "Can't open gzip pipe\n";&lt;br /&gt;    }&lt;br /&gt;    else {&lt;br /&gt;        open $log_fh, '&lt;', $log or die "Can't open $log\n";&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    my $log_base = $log;&lt;br /&gt;    $log_base =~ s/ \.gz \z //xms;&lt;br /&gt;    &lt;br /&gt;    while (my $line = &lt;$log_fh&gt;) {&lt;br /&gt;        $num_lines_parsed++;&lt;br /&gt;        if (!($num_lines_parsed % 1000)) {&lt;br /&gt;            print STDERR "Parsed $num_lines_parsed lines of $log\n";&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        my ($host) = $line =~ m/ \A (\S+) \s /xms;&lt;br /&gt;        &lt;br /&gt;        if (!exists $record_for{$host}) {&lt;br /&gt;            my $record = $gi-&gt;record_by_name($host);&lt;br /&gt;            $record_for{$host} = $record || 0;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        my $country = 'unknown';&lt;br /&gt;        if (exists $record_for{$host} &amp;&amp; $record_for{$host}) {&lt;br /&gt;            $country = lc($record_for{$host}-&gt;country_name());&lt;br /&gt;            $country =~ s/\W+/_/gxms;&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        if (!exists $fh_for{$country}) {&lt;br /&gt;            open $fh_for{$country}, '&gt;', "$log_base.$country.out"&lt;br /&gt;                or die "Can't write to $log_base.$country.out\n";&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        print {$fh_for{$country}} $line;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    foreach my $fh (values %fh_for) {&lt;br /&gt;        close $fh;&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    close $log_fh;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 19 Mar 2008 15:02:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5255</guid>
      <author>iansealy (Ian Sealy)</author>
    </item>
    <item>
      <title>Apache rewrite rules</title>
      <link>http://snippets.dzone.com/posts/show/4904</link>
      <description>Pass all requests for non-existing files or directories to index.php&lt;br /&gt;&lt;code&gt;&lt;br /&gt;RewriteCond        %{REQUEST_FILENAME}        !-f                &lt;br /&gt;RewriteCond        %{REQUEST_FILENAME}        !-d&lt;br /&gt;RewriteRule        ^(.*)$                    index.php        [L]&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 19 Dec 2007 06:48:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4904</guid>
      <author>rutgerw ()</author>
    </item>
    <item>
      <title>apache dir config</title>
      <link>http://snippets.dzone.com/posts/show/4823</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Alias /swf1  "E:/flexprojects/t2/deploy"&lt;br /&gt;    &lt;Directory "E:/flexprojects/t2/deploy"&gt;&lt;br /&gt;		AllowOverride   None  &lt;br /&gt;        Order   allow,deny  &lt;br /&gt;        Allow   from   all   &lt;br /&gt;	&lt;/Directory&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 29 Nov 2007 07:12:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4823</guid>
      <author>yuanyc (yuanyunchang)</author>
    </item>
    <item>
      <title>Using Apache with RewriteMap and a text file</title>
      <link>http://snippets.dzone.com/posts/show/4699</link>
      <description>This code will read a text file using Apache then upon a user request, look for a url containing /l/ eg. http://mysite.com/l/digg and rewrite the URL in full eg. http://mysite.com/gwd/feed/digg.html . The example file is shown here for completeness.&lt;br /&gt;&lt;br /&gt;RewriteMap uses a text file as a convenient alternative for the administrator when declaring many rewrite rules. Code based on the article from ONLamp.com -  A Day in the Life of #Apache http://urltea.com/1vwb&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;file name="links.txt" location="/var/www/localhost/"&gt;&lt;br /&gt;scotsman /gwd/feed/scotsman.html&lt;br /&gt;digg /gwd/feed/digg.html&lt;br /&gt;&lt;/file&gt;&lt;br /&gt;&lt;br /&gt;&lt;IfModule mod_rewrite.c&gt;&lt;br /&gt;RewriteEngine on&lt;br /&gt;RewriteMap links txt:/var/www/localhost/links.txt&lt;br /&gt;RewriteRule ^/l/(.*) ${links:$1|http://mysite.com/} [R]&lt;br /&gt;&lt;/IfModule&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Note: The [R] at the end of RewriteRule means redirect, to have a clean url simply remove that switch.&lt;br /&gt;&lt;br /&gt;*update 15-Feb-08 *&lt;br /&gt;Restart Apache rather reloading the module when switching redirection on or off for a RewriteRule.  The Apache version 2.2.6 (Unix) didn't pick up my settings correctly when I tried /etc/init.d/apache2 reload, instead I needed to use /etc/init.d/apache2 restart.</description>
      <pubDate>Thu, 25 Oct 2007 22:51:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4699</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>A simple mod_rewrite example</title>
      <link>http://snippets.dzone.com/posts/show/4694</link>
      <description>Rewrite a long url as a short easy to remember url with mod_rewrite. Place this code in httpd.conf or the virtual hosts file. Original code from sitepoint - mod_rewrite: A Beginner's Guide to URL Rewriting http://urltea.com/1v6d .&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;IfModule mod_rewrite.c&gt;&lt;br /&gt;RewriteEngine on&lt;br /&gt;RewriteRule ^/shortcut$ /complicated/and/way/too/long/url/here&lt;br /&gt;&lt;/IfModule&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 24 Oct 2007 09:11:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4694</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Mongrel and Apache fun with Capistrano 2.0</title>
      <link>http://snippets.dzone.com/posts/show/4510</link>
      <description>I got the Mongrel recipes from somewhere else -- I sadly don't remember where -- and modified them a bit.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;namespace :deploy do&lt;br /&gt;  namespace :mongrel do&lt;br /&gt;    [ :stop, :start, :restart ].each do |t|&lt;br /&gt;      desc "#{t.to_s.capitalize} the mongrel appserver"&lt;br /&gt;      task t, :roles =&gt; :app do&lt;br /&gt;        run "mongrel_rails cluster::#{t.to_s} --clean -C #{mongrel_conf}"&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  namespace :apache do&lt;br /&gt;    desc "Start Apache"&lt;br /&gt;    task :start, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd start &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    desc "Stop Apache"&lt;br /&gt;    task :stop, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd stop &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    desc "Restart Apache"&lt;br /&gt;    task :restart, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd restart &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom restart task for mongrel cluster"&lt;br /&gt;  task :restart do&lt;br /&gt;    deploy.mongrel.restart&lt;br /&gt;    deploy.apache.restart&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom start task for mongrel cluster"&lt;br /&gt;  task :start, :roles =&gt; :app do&lt;br /&gt;    deploy.mongrel.start&lt;br /&gt;    deploy.apache.start&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom stop task for mongrel cluster"&lt;br /&gt;  task :stop, :roles =&gt; :app do&lt;br /&gt;    deploy.apache.stop&lt;br /&gt;    deploy.mongrel.stop&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;/code&gt;</description>
      <pubDate>Fri, 07 Sep 2007 16:31:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4510</guid>
      <author>hmans (Hendrik Mans)</author>
    </item>
    <item>
      <title>Make sure your site (or directory) is SSL encrypted</title>
      <link>http://snippets.dzone.com/posts/show/4405</link>
      <description>Need a simple way to make sure all http requests get redirected to https?&lt;br /&gt;This apache config snippet will redirect all requests at or below the specified location to its https equivilant.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;Location "/"&gt;&lt;br /&gt;        RewriteEngine on&lt;br /&gt;        Options +FollowSymLinks&lt;br /&gt;        Allow from all&lt;br /&gt;        RewriteCond %{SERVER_PORT} !^443$&lt;br /&gt;        RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]&lt;br /&gt;&lt;/Location&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 09 Aug 2007 17:52:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4405</guid>
      <author>mikehale (Michael Hale)</author>
    </item>
    <item>
      <title>apache configuration for 1 application serving requests from mulitple (4) domains</title>
      <link>http://snippets.dzone.com/posts/show/4292</link>
      <description>// One rails application serving 4 domains via mongrel + apache2.2 proxy&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#&lt;br /&gt;# Proxy Server directives. Uncomment the following lines to&lt;br /&gt;# enable the proxy server:&lt;br /&gt;#&lt;br /&gt;&lt;IfModule mod_proxy.c&gt;&lt;br /&gt;ProxyRequests Off&lt;br /&gt;&lt;br /&gt;&lt;Proxy *&gt;&lt;br /&gt;    Order deny,allow&lt;br /&gt;    Deny from all&lt;br /&gt;    Allow from all&lt;br /&gt;&lt;/Proxy&gt;&lt;br /&gt;&lt;br /&gt;#ProxyPass / http://127.0.0.1:8000/dl&lt;br /&gt;#ProxyPassReverse / http://127.0.0.1:8000/dl&lt;br /&gt;#ProxyPreserveHost On&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/IfModule&gt;&lt;br /&gt;# End of proxy directives.&lt;br /&gt;&lt;br /&gt;Listen 8080&lt;br /&gt;&lt;VirtualHost *:8080&gt;&lt;br /&gt;  &lt;Location /&gt;&lt;br /&gt;    SetHandler balancer-manager&lt;br /&gt;    Deny from all&lt;br /&gt;    Allow from localhost&lt;br /&gt;  &lt;/Location&gt;&lt;br /&gt;&lt;/VirtualHost&gt;&lt;br /&gt;&lt;br /&gt;&lt;Proxy balancer://mongrel_cluster&gt;&lt;br /&gt;    BalancerMember http://127.0.0.1:8000&lt;br /&gt;    BalancerMember http://127.0.0.1:8001&lt;br /&gt;    BalancerMember http://127.0.0.1:8002&lt;br /&gt;&lt;/Proxy&gt;&lt;br /&gt;&lt;br /&gt;&lt;VirtualHost *:80&gt;&lt;br /&gt;Include /home/WEBSITEAPP/current/config/apache/dod.conf&lt;br /&gt;&lt;br /&gt;ServerName www.WEBSITENAME4.com&lt;br /&gt;&lt;br /&gt;    ErrorLog logs/WEBSITENAME4_errors_log&lt;br /&gt;    CustomLog logs/WEBSITENAME4_log combined&lt;br /&gt;&lt;/VirtualHost&gt;&lt;br /&gt;&lt;br /&gt;&lt;VirtualHost *:80&gt;&lt;br /&gt;Include /home/WEBSITEAPP/current/config/apache/dl.conf&lt;br /&gt;&lt;br /&gt;ServerName www.WEBSITENAME0.com&lt;br /&gt;&lt;br /&gt;    ErrorLog logs/WEBSITENAME0_errors_log&lt;br /&gt;    CustomLog logs/WEBSITENAME0_log combined&lt;br /&gt;&lt;/VirtualHost&gt;&lt;br /&gt;&lt;br /&gt;&lt;VirtualHost *:80&gt;&lt;br /&gt;Include /home/WEBSITEAPP/current/config/apache/pf.conf&lt;br /&gt;&lt;br /&gt;ServerName test.WEBSITENAME1.com&lt;br /&gt;&lt;br /&gt;    ErrorLog logs/WEBSITENAME1_errors_log&lt;br /&gt;    CustomLog logs/WEBSITENAME1_log combined&lt;br /&gt;&lt;/VirtualHost&gt;&lt;br /&gt;&lt;br /&gt;&lt;VirtualHost *:80&gt;&lt;br /&gt;Include /home/WEBSITEAPP/current/config/apache/dag.conf&lt;br /&gt;&lt;br /&gt;ServerName www.WEBSITENAME2.com&lt;br /&gt;&lt;br /&gt;    ErrorLog logs/WEBSITENAME_errors_log&lt;br /&gt;    CustomLog logs/WEBSITENAME_log combined&lt;br /&gt;&lt;/VirtualHost&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;example of one of the configuration of the virtual hosts&lt;br /&gt;-bash-3.00$ cat /home/WEBSITEAPP/current/config/apache/dod.conf&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;ServerName WEBSITENAME.com&lt;br /&gt;ServerAlias www.WEBSITENAME.com test.WEBSITENAME.com &lt;br /&gt;&lt;br /&gt;# Pass other requests to mongrel instance&lt;br /&gt;ProxyPass / http://127.0.0.1:8000/&lt;br /&gt;ProxyPassReverse / http://127.0.0.1:8000/&lt;br /&gt;ProxyPreserveHost On&lt;br /&gt;ProxyRequests Off&lt;br /&gt;&lt;br /&gt;# Do not allow open proxying, allow only requests starting with a /&lt;br /&gt;&lt;LocationMatch "^[^/]"&gt;&lt;br /&gt;        Deny from all&lt;br /&gt;&lt;/LocationMatch&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;DocumentRoot /home/WEBSITEAPP/current/public&lt;br /&gt;&lt;br /&gt;  &lt;Directory "/home/WEBSITEAPP/current/public"&gt;&lt;br /&gt;    Options FollowSymLinks&lt;br /&gt;    AllowOverride None&lt;br /&gt;    Order allow,deny&lt;br /&gt;    Allow from all&lt;br /&gt;  &lt;/Directory&gt;&lt;br /&gt;&lt;br /&gt;  RewriteEngine On&lt;br /&gt;&lt;br /&gt;  # Uncomment for rewrite debugging&lt;br /&gt;  RewriteLog logs/myapp_rewrite_log&lt;br /&gt;  RewriteLogLevel 9 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  # Check for maintenance file and redirect all requests&lt;br /&gt;  #  ( this is for use with Capistrano's disable_web task )&lt;br /&gt;  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f&lt;br /&gt;  RewriteCond %{SCRIPT_FILENAME} !maintenance.html&lt;br /&gt;  RewriteRule ^.*$ /system/maintenance.html [L]&lt;br /&gt;&lt;br /&gt;  # Rewrite index to check for static&lt;br /&gt;#  RewriteRule ^/$ /index.html [QSA] &lt;br /&gt;  RewriteRule ^/$ /dod/navigation [QSA] &lt;br /&gt;#  RewriteRule ^/$ /dl/navigation [L] &lt;br /&gt;&lt;br /&gt;  # Rewrite to check for Rails cached page&lt;br /&gt;#  RewriteRule ^([^.]+)$ $1.html [QSA]&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  # Redirect all non-static requests to cluster&lt;br /&gt;  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f&lt;br /&gt;#  RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]&lt;br /&gt;  RewriteRule ^/(.*)$ balancer://mongrel_cluster/$1 [P,QSA,L]&lt;br /&gt;#  RewriteRule "^/(.*)" "http://localhost:8001/$1" [P,QSA,L]&lt;br /&gt;&lt;br /&gt;  # Deflate&lt;br /&gt;  AddOutputFilterByType DEFLATE text/html text/plain text/css&lt;br /&gt;  # ... text/xml application/xml application/xhtml+xml text/javascript &lt;br /&gt;  BrowserMatch ^Mozilla/4 gzip-only-text/html&lt;br /&gt;  BrowserMatch ^Mozilla/4.0[678] no-gzip&lt;br /&gt;  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html&lt;br /&gt;&lt;br /&gt;  # Uncomment for deflate debugging&lt;br /&gt;  #DeflateFilterNote Input input_info&lt;br /&gt;  #DeflateFilterNote Output output_info&lt;br /&gt;  #DeflateFilterNote Ratio ratio_info&lt;br /&gt;  #LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate&lt;br /&gt;  #CustomLog logs/myapp_deflate_log deflate&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 12 Jul 2007 12:41:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4292</guid>
      <author>gudata (Gudata)</author>
    </item>
    <item>
      <title>Glossword WAMP source code (NSIS)</title>
      <link>http://snippets.dzone.com/posts/show/4135</link>
      <description>// NSIS (http://nsis.sourceforge.net/)&lt;br /&gt;// Glossword WAMP (http://sourceforge.net/projects/glossword/)&lt;br /&gt;// Apache, MySQL and PHP are stored in archive usr.exe, directory /usr/local&lt;br /&gt;// phpMyAdmin is in archive htdocs.exe, directory /htdocs/phpmyadmin&lt;br /&gt;// Additionaly you need files with phrases: English.nsh and Russian.nsh&lt;br /&gt;// ------------------------------------------&lt;br /&gt;// English.nsh:&lt;br /&gt;// LangString SECT_01 ${LANG_ENGLISH} "Glossword ${PRODUCT_VERSION}"&lt;br /&gt;// LangString TXT_02 ${LANG_ENGLISH} "Thank you for installing Glossword.\r\nFor news and updates go to http://sourceforge.net/projects/glossword/"&lt;br /&gt;// LangString DESC_SecGw ${LANG_ENGLISH} "Glossword program core files."&lt;br /&gt;// ------------------------------------------&lt;br /&gt;// install.bat&lt;br /&gt;// @echo on&lt;br /&gt;// cls&lt;br /&gt;// SET ipath=%1&lt;br /&gt;// cd "%ipath%/usr/local/apache2/bin"&lt;br /&gt;// httpd.exe -k install -n Apache2_GW&lt;br /&gt;// httpd.exe -k start -n Apache2_GW&lt;br /&gt;// cd "%ipath%/usr/local/mysql5/bin"&lt;br /&gt;// mysqld-nt.exe --install MySQL50_GW --defaults-file="%ipath%/usr/local/mysql5/bin/my-custom.cnf"&lt;br /&gt;// net start MySQL50_GW&lt;br /&gt;// ------------------------------------------&lt;br /&gt;// uninstall.bat&lt;br /&gt;// @echo off&lt;br /&gt;// cls&lt;br /&gt;// SET ipath=%1&lt;br /&gt;// cd "%ipath%/usr/local/apache2/bin"&lt;br /&gt;// httpd.exe -k stop -n Apache2_GW&lt;br /&gt;// httpd.exe -k uninstall -n Apache2_GW&lt;br /&gt;// net stop MySQL50_GW&lt;br /&gt;// cd "%ipath%/usr/local/mysql5/bin"&lt;br /&gt;// mysqld-nt.exe --remove MySQL50_GW&lt;br /&gt;// ------------------------------------------&lt;br /&gt;// unpack.bat&lt;br /&gt;// @echo off&lt;br /&gt;// usr.exe -y&lt;br /&gt;// htdocs.exe -y&lt;br /&gt;// del usr.exe&lt;br /&gt;// del htdocs.exe&lt;br /&gt;// del unpack.bat&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now you can create your own WAMP package.&lt;br /&gt;&lt;br /&gt;; Glossword Desktop edition: Apache, MySQL, PHP&lt;br /&gt;; Written by Dmitry Shilnikov (c) 2002-2007&lt;br /&gt;; tty01@rambler.ru&lt;br /&gt;;--------------------------------&lt;br /&gt;;Include Modern UI&lt;br /&gt;&lt;br /&gt;  	!include "MUI.nsh"&lt;br /&gt;&lt;br /&gt;; replace in file with count of changes&lt;br /&gt;	!include "FileFunc.nsh"&lt;br /&gt;	&lt;br /&gt;;--------------------------------&lt;br /&gt;;Custom variables&lt;br /&gt;&lt;br /&gt;	!define PRODUCT_NAME "Apache, MySQL, PHP"&lt;br /&gt;	!define PRODUCT_VERSION "Apache/2.2.4, MySQL 5.0.41-community-nt, PHP 5.2.3 for Windows"&lt;br /&gt;	!define DIR_SRC "."&lt;br /&gt;	!define THIS_DIR_INSTALLTO "Glossword-WAMP"&lt;br /&gt;&lt;br /&gt;;--------------------------------&lt;br /&gt;;General&lt;br /&gt;&lt;br /&gt;	Name "${PRODUCT_NAME}"&lt;br /&gt;	OutFile "glossword-wamp.exe"&lt;br /&gt;&lt;br /&gt;	;Folder selection page&lt;br /&gt;	InstallDir "$PROGRAMFILES\Glossword-WAMP"&lt;br /&gt;&lt;br /&gt;;--------------------------------&lt;br /&gt;;Interface Settings&lt;br /&gt;&lt;br /&gt;	!define MUI_ABORTWARNING&lt;br /&gt;	!define MUI_UI ${NSISDIR}\Contrib\UIs\modern.exe&lt;br /&gt;	!define MUI_ICON ${DIR_SRC}\install\gw_new.ico&lt;br /&gt;	!define MUI_UNICON ${DIR_SRC}\install\gw_remove.ico&lt;br /&gt;	!define MUI_FINISHPAGE_TEXT $(TXT_02)&lt;br /&gt;	&lt;br /&gt;;--------------------------------&lt;br /&gt;;Pages&lt;br /&gt;&lt;br /&gt;!insertmacro MUI_PAGE_WELCOME&lt;br /&gt;!insertmacro MUI_PAGE_DIRECTORY&lt;br /&gt;!insertmacro MUI_PAGE_INSTFILES&lt;br /&gt;!insertmacro MUI_PAGE_FINISH&lt;br /&gt;&lt;br /&gt;;Uninstaller pages&lt;br /&gt;!insertmacro MUI_UNPAGE_CONFIRM&lt;br /&gt;!insertmacro MUI_UNPAGE_INSTFILES&lt;br /&gt;&lt;br /&gt;;--------------------------------&lt;br /&gt;;Languages&lt;br /&gt;&lt;br /&gt;!insertmacro MUI_LANGUAGE "English"&lt;br /&gt;!insertmacro MUI_LANGUAGE "Russian"&lt;br /&gt;&lt;br /&gt;;--------------------------------&lt;br /&gt;;Installer Sections&lt;br /&gt;&lt;br /&gt;Section "$(SECT_01)" SecGw&lt;br /&gt;&lt;br /&gt;	SetDetailsPrint textonly&lt;br /&gt;	DetailPrint "Installing server files..."&lt;br /&gt;    SetOverwrite ifnewer&lt;br /&gt;	&lt;br /&gt;	DetailPrint "htdocs..."&lt;br /&gt;	CreateDirectory "$INSTDIR\htdocs"&lt;br /&gt;	CreateDirectory "$INSTDIR\htdocs\glossword"&lt;br /&gt;&lt;br /&gt;	SetOutPath "$INSTDIR"&lt;br /&gt;	File "usr.exe"&lt;br /&gt;	File "htdocs.exe"&lt;br /&gt;	File "unpack.bat"&lt;br /&gt;	File "install.bat"&lt;br /&gt;	File "uninstall.bat"&lt;br /&gt;	File "localhost.url"&lt;br /&gt;	File "phpinfo.url"&lt;br /&gt;    File "phpmyadmin.url"&lt;br /&gt;    File "news.url"&lt;br /&gt;    File "glossword-wamp224_5041_523.txt"&lt;br /&gt;	&lt;br /&gt;	ExecWait '"unpack.bat"'&lt;br /&gt;&lt;br /&gt;	SetOutPath "$INSTDIR"&lt;br /&gt;	; change configuraiton files&lt;br /&gt;	DetailPrint "httpd.conf..."&lt;br /&gt;	ClearErrors&lt;br /&gt;	FileOpen $0 "$INSTDIR\usr\local\apache2\conf\httpd.conf" "r"&lt;br /&gt;	GetTempFileName $R0&lt;br /&gt;	FileOpen $1 $R0 "w"&lt;br /&gt;	loop1:&lt;br /&gt;		FileRead $0 $2&lt;br /&gt;		IfErrors done1&lt;br /&gt;		StrCmp $2 "# Created by install$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "# Created by glossword-amp.exe$\r$\n"&lt;br /&gt;		StrCmp $2 "DocumentRoot $\"E:/usr/httpdocs/svn/Glossword Desktop/htdocs$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "DocumentRoot $\"$INSTDIR\htdocs$\"$\r$\n"&lt;br /&gt;		StrCmp $2 "ServerRoot $\"E:/usr/httpdocs/svn/Glossword Desktop/usr/local/apache2$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "ServerRoot $\"$INSTDIR\usr\local\apache2$\"$\r$\n"&lt;br /&gt;		FileWrite $1 $2&lt;br /&gt;	Goto loop1&lt;br /&gt;	done1:&lt;br /&gt;		FileClose $0&lt;br /&gt;		FileClose $1&lt;br /&gt;		Delete "$INSTDIR\usr\local\apache2\conf\httpd.conf"&lt;br /&gt;		CopyFiles /SILENT $R0 "$INSTDIR\usr\local\apache2\conf\httpd.conf"&lt;br /&gt;		Delete $R0&lt;br /&gt;	;		&lt;br /&gt;	DetailPrint "my-custom.cnf..."&lt;br /&gt;	ClearErrors&lt;br /&gt;	FileOpen $0 "$INSTDIR\usr\local\mysql5\bin\my-custom.cnf" "r"&lt;br /&gt;	GetTempFileName $R0&lt;br /&gt;	FileOpen $1 $R0 "w"&lt;br /&gt;	loop2:&lt;br /&gt;		FileRead $0 $2&lt;br /&gt;		IfErrors done2&lt;br /&gt;		StrCmp $2 "basedir=$\"../mysql5/$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "basedir=$\"$INSTDIR\usr\local\mysql5\$\"$\r$\n"&lt;br /&gt;		StrCmp $2 "datadir=$\"../mysql5/data/$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "datadir=$\"$INSTDIR\usr\local\mysql5\data\$\"$\r$\n"&lt;br /&gt;		FileWrite $1 $2&lt;br /&gt;	Goto loop2&lt;br /&gt;	done2:&lt;br /&gt;		FileClose $0&lt;br /&gt;		FileClose $1&lt;br /&gt;		Delete "$INSTDIR\usr\local\mysql5\bin\my-custom.cnf"&lt;br /&gt;		CopyFiles /SILENT $R0 "$INSTDIR\usr\local\mysql5\bin\my-custom.cnf"&lt;br /&gt;		Delete $R0&lt;br /&gt;	;&lt;br /&gt;	DetailPrint "php.ini..."&lt;br /&gt;	ClearErrors&lt;br /&gt;	FileOpen $0 "$INSTDIR\usr\local\php5\php.ini" "r"&lt;br /&gt;	GetTempFileName $R0&lt;br /&gt;	FileOpen $1 $R0 "w"&lt;br /&gt;	loop5:&lt;br /&gt;		FileRead $0 $2&lt;br /&gt;		IfErrors done5&lt;br /&gt;		StrCmp $2 "extension_dir = $\"../../php5/ext$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "extension_dir = $\"$INSTDIR\usr\local\php5\ext$\"$\r$\n"&lt;br /&gt;		StrCmp $2 "session.save_path = $\"c:/temp$\"$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "session.save_path = $\"$TEMP$\"$\r$\n"&lt;br /&gt;		FileWrite $1 $2&lt;br /&gt;	Goto loop5&lt;br /&gt;	done5:&lt;br /&gt;		FileClose $0&lt;br /&gt;		FileClose $1&lt;br /&gt;		Delete "$INSTDIR\usr\local\php5\php.ini"&lt;br /&gt;		CopyFiles /SILENT $R0 "$INSTDIR\usr\local\php5\php.ini"&lt;br /&gt;		Delete $R0&lt;br /&gt;	;	&lt;br /&gt;	DetailPrint "install.bat..."&lt;br /&gt;	ClearErrors&lt;br /&gt;	FileOpen $0 "$INSTDIR\install.bat" "r"&lt;br /&gt;	GetTempFileName $R0&lt;br /&gt;	FileOpen $1 $R0 "w"&lt;br /&gt;	loop3:&lt;br /&gt;		FileRead $0 $2&lt;br /&gt;		IfErrors done3&lt;br /&gt;		StrCmp $2 "set ipath=%1$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "set ipath=$INSTDIR$\r$\n"&lt;br /&gt;		FileWrite $1 $2&lt;br /&gt;	Goto loop3&lt;br /&gt;	done3:&lt;br /&gt;		FileClose $0&lt;br /&gt;		FileClose $1&lt;br /&gt;		Delete "$INSTDIR\install.bat"&lt;br /&gt;		CopyFiles /SILENT $R0 "$INSTDIR\install.bat"&lt;br /&gt;		Delete $R0&lt;br /&gt;	;&lt;br /&gt;	DetailPrint "uninstall.bat..."&lt;br /&gt;	ClearErrors&lt;br /&gt;	FileOpen $0 "$INSTDIR\uninstall.bat" "r"&lt;br /&gt;	GetTempFileName $R0&lt;br /&gt;	FileOpen $1 $R0 "w"&lt;br /&gt;	loop4:&lt;br /&gt;		FileRead $0 $2&lt;br /&gt;		IfErrors done4&lt;br /&gt;		StrCmp $2 "set ipath=%1$\r$\n" 0 +2&lt;br /&gt;		StrCpy $2 "set ipath=$INSTDIR$\r$\n"&lt;br /&gt;		FileWrite $1 $2&lt;br /&gt;	Goto loop4&lt;br /&gt;	done4:&lt;br /&gt;		FileClose $0&lt;br /&gt;		FileClose $1&lt;br /&gt;		Delete "$INSTDIR\uninstall.bat"&lt;br /&gt;		CopyFiles /SILENT $R0 "$INSTDIR\uninstall.bat"&lt;br /&gt;		Delete $R0&lt;br /&gt;	ExecWait '"install.bat"'&lt;br /&gt;	;nsExec::ExecToStack '"install.bat"'&lt;br /&gt;&lt;br /&gt;	SetOverwrite off&lt;br /&gt;&lt;br /&gt;	CreateDirectory "$SMPROGRAMS\${THIS_DIR_INSTALLTO}"&lt;br /&gt;	CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Glossword at localhost.lnk" "$INSTDIR\localhost.url"&lt;br /&gt;	CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Glossword development news.lnk" "$INSTDIR\news.url"&lt;br /&gt;	CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\phpinfo().lnk" "$INSTDIR\phpinfo.url"&lt;br /&gt;    CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\phpMyAdmin.lnk" "$INSTDIR\phpmyadmin.url"&lt;br /&gt;	CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Apache Monitor.lnk" "$INSTDIR\usr\local\apache2\bin\ApacheMonitor.exe"&lt;br /&gt;	CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Remove Glossword WAMP.lnk" "$INSTDIR\uninstall.exe"&lt;br /&gt;    CreateShortCut "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Release notes.lnk" "$INSTDIR\glossword-wamp224_5041_523.txt"&lt;br /&gt;&lt;br /&gt;  	WriteUninstaller "$INSTDIR\uninstall.exe"&lt;br /&gt;SectionEnd&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;;--------------------------------&lt;br /&gt;;Descriptions&lt;br /&gt;&lt;br /&gt;!include "${DIR_SRC}\install\English.nsh"&lt;br /&gt;!include "${DIR_SRC}\install\Russian.nsh"&lt;br /&gt;&lt;br /&gt;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN&lt;br /&gt;	!insertmacro MUI_DESCRIPTION_TEXT ${SecGw} $(DESC_SecGw)&lt;br /&gt;!insertmacro MUI_FUNCTION_DESCRIPTION_END&lt;br /&gt; &lt;br /&gt;;--------------------------------&lt;br /&gt;; Functions&lt;br /&gt;&lt;br /&gt;Function .onInit&lt;br /&gt;	!insertmacro MUI_LANGDLL_DISPLAY&lt;br /&gt;FunctionEnd&lt;br /&gt;&lt;br /&gt;;--------------------------------&lt;br /&gt;;Uninstaller Section&lt;br /&gt;&lt;br /&gt;Section Uninstall&lt;br /&gt;	&lt;br /&gt;	SetOutPath "$INSTDIR"&lt;br /&gt;	ExecWait '"uninstall.bat"'&lt;br /&gt;&lt;br /&gt;	SetShellVarContext current&lt;br /&gt;	Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Remove Glossword WAMP.lnk"&lt;br /&gt;	Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Apache Monitor.lnk"&lt;br /&gt;	Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Glossword at localhost.lnk"&lt;br /&gt;	Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Glossword development news.lnk"&lt;br /&gt;	Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\phpinfo().lnk"&lt;br /&gt;    Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\phpMyAdmin.lnk"&lt;br /&gt;    Delete "$SMPROGRAMS\${THIS_DIR_INSTALLTO}\Release Notes.lnk"&lt;br /&gt;	RMDir /r "$SMPROGRAMS\${THIS_DIR_INSTALLTO}"&lt;br /&gt;	RMDir /r "$INSTDIR\usr\local\apache2"&lt;br /&gt;	RMDir /r "$INSTDIR\usr\local\php5"&lt;br /&gt;	RMDir /r "$INSTDIR\usr\local\mysql5\bin"&lt;br /&gt;	RMDir /r "$INSTDIR\usr\local\mysql5\share"&lt;br /&gt;	RMDir /r "$INSTDIR\htdocs\phpmyadmin"&lt;br /&gt;	Delete "$INSTDIR\install.bat"&lt;br /&gt;	Delete "$INSTDIR\uninstall.bat"&lt;br /&gt;	Delete "$INSTDIR\glossword-wamp224_5041_523.txt"&lt;br /&gt;	Delete "$INSTDIR\localhost.url"&lt;br /&gt;	Delete "$INSTDIR\phpinfo.url"&lt;br /&gt;	Delete "$INSTDIR\phpmyadmin.url"&lt;br /&gt;&lt;br /&gt; 	;RMDir /r "$INSTDIR"&lt;br /&gt;	SetAutoClose true&lt;br /&gt;  &lt;br /&gt;SectionEnd&lt;br /&gt;</description>
      <pubDate>Wed, 13 Jun 2007 09:12:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4135</guid>
      <author>Dmitry-Sh (Dmitry Shilnikov)</author>
    </item>
  </channel>
</rss>
