Sign up to create your own snipts, or login.

Public snipts » apache The latest public apache snipts.

showing 1-20 of 67 snipts for apache
  • reconfigure plesk vhost
    /usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=<NOME_DOMINIO>
    

    copy | embed

    0 comments - tagged in  posted by ftassi on Mar 12, 2010 at 12:44 p.m. EST
  • .htaccess file to lock down files with db or secure in the prefix
    <FilesMatch "^(db|secure).*$">
    deny from all
    </FilesMatch>
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Mar 02, 2010 at 11:17 a.m. EST
  • Dynamic Django mod_wsgi hook files
    # --- django.wsgi - in any project
    from some_common_module import wsgi_helper
    application = wsgi_helper.setup(__file__)
    
    
    # --- wsgi_helper.py - in some_common_module
    import os, sys
    import django.core.handlers.wsgi
    
    def setup(filename):
    	project_root = os.sep.join(filename.split(os.sep)[:-2])
    	project_dir = None
    	
    	for path in os.listdir(project_root):
    		# Find each dir off the root, and check it for settings.py
    	
    		path = os.path.join(project_root, path)
    	
    		if os.path.isdir(path):
    			file = "".join([path, os.sep, "settings.py"])
    			if os.path.exists(file):
    				# We have found /project_name/settings.py
    				project_dir = path
    				os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % path.split(os.sep)[-1]
    	
    	if not project_dir:
    		raise Exception("Could not find project settings file! Checked path: %s" % path)
    	
    	if project_root not in sys.path: sys.path.insert(0, project_root)
    	if project_dir not in sys.path: sys.path.insert(0, project_dir)
    
    	return django.core.handlers.wsgi.WSGIHandler()
    

    copy | embed

    0 comments - tagged in  posted by Fotinakis on Feb 26, 2010 at 6:39 p.m. EST
  • Rewrite .cfm files to files with .cfm
    RewriteEngine On
    Options -Indexes
    
    # redirect all .cfm files to files without .cfm
    RedirectMatch 301 ^(.*)\index.cfm$ $1
    RedirectMatch 301 ^(.*)\.cfm$ $1
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Feb 15, 2010 at 11:25 a.m. EST
  • htaccess redirect all traffic to homepage
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . http://domain.tld/index.php [L]
    </IfModule>
    

    copy | embed

    0 comments - tagged in  posted by rendrag on Feb 06, 2010 at 1:49 p.m. EST
  • Rewrite .htaccess to EE's engine if directory conflicts with existing directory
    RewriteEngine On
    RewriteBase /
    
    # if the file/dir does not exist, append index.php 
    # which will call EE and pull up it's structured url
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/interact/$1 [L]
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Feb 03, 2010 at 10:10 a.m. EST
  • Prevent .htaccess and .htpasswd file from being viewed by web clients
    #
    # The following lines prevent .htaccess and .htpasswd files from being 
    # viewed by Web clients. 
    #
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    

    copy | embed

    0 comments - tagged in  posted by yvoictra on Jan 16, 2010 at 6:02 p.m. EST
  • Apache non-www .htaccess config
    Options +FollowSymLinks
    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} !^apaair\.aero$ [NC]
    RewriteRule ^(.*)$ http://apaair.aero/$1 [R=301,L]
    
    # Important: It is needed to have mod_rewrite MODULE activated and have "AllowOverride Directive" set to ALL.
    

    copy | embed

    0 comments - tagged in  posted by yvoictra on Jan 16, 2010 at 9:05 a.m. EST
  • See which modules are loaded in Apache (on OSX)
    /usr/sbin/apachectl -l
    

    copy | embed

    0 comments - tagged in  posted by pkarl on Dec 15, 2009 at 10:26 a.m. EST
  • apache configure htaccess defaults
    #
    # AccessFileName: The name of the file to look for in each directory
    # for additional configuration directives.  See also the AllowOverride
    # directive.
    #
    AccessFileName .htaccess
    
    #
    # The following lines prevent .htaccess and .htpasswd files from being 
    # viewed by Web clients. 
    #
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Dec 15, 2009 at 7:59 a.m. EST
  • protect svn/cvs in apache conf
    # Protect revision controlled web projects. This version is 
    # for Apache's global configuration (conf) file. Protection
    # can also be done if you dont have access to Apache conf, 
    # in any directorie's .htaccess file, in which case,  Apache 
    # conf must aleady be configured to use htaccess.
    <DirectoryMatch "^/.*/(\.svn|CVS)/">
      Order deny,allow
      Deny from all 
    </DirectoryMatch>
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Dec 15, 2009 at 7:57 a.m. EST
  • My Custom .htaccess file
    RewriteEngine On
    #comment out the options followsymlinks when in prod
    #Options +ExecCGI +FollowSymLinks
    RewriteBase /rbanh/blah/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L,QSA]
    
    # prevent directory browsing
    Options -Indexes
    
    <FilesMatch "\.(htaccess|svn|xml|inc|.*sql|cache_|.*~)$">
        deny from all
    </FilesMatch>
    

    copy | embed

    0 comments - tagged in  posted by robertbanh on Dec 08, 2009 at 10:21 a.m. EST
  • Basic query string rewriting with mod_rewrite
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [S=40]
    RewriteRule ^([A-Za-z0-9\_]+)?/?$ /index.php?page=$1 [QSA,L]
    
    RewriteRule ^(events|news)/([0-9]+)/?$ /index.php?page=$1&id=$2 [L]
    RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3&id=$4 [L]
    RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3 [L]
    #RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L]
    </IfModule>
    

    copy | embed

    0 comments - tagged in  posted by trey on Dec 02, 2009 at 4:54 p.m. EST
  • Apache Log File Retriever via FTP
    #!/bin/bash
    
    ## GLOBAL CONFIGS ##
    LOG=$(date +"%Y%m")
    let DAY=$(date +"%d")-1
    
    SITES=( [0]="domain1.tld" [1]="domain2.tld" [2]="domain3.tld" )
    USERS=( [0]="user1" [1]="user2" [2]="user3" )
    PASSW=( [0]="passw1" [1]="passw2" [2]="passw3" )
    FILES=( [0]="www.$LOG$DAY" [1]="www.$LOG$DAY.gz" [2]="www.$LOG$DAY" )
    
    for index in 0 1
    do
    	[ ! -d /srv_admin/remote_logs/${SITES[index]} ] && mkdir -p /srv_admin/remote_logs/${SITES[index]} || :
    	ftp -in ${SITES[index]}<<FTPEOF
    quote USER ${USERS[index]}
    quote PASS ${PASSW[index]}
    cd www_logs
    lcd /srv_admin/remote_logs/${SITES[index]}
    binary
    verbose
    passive
    get ${FILES[index]}
    exit
    FTPEOF
    done
    

    copy | embed

    0 comments - tagged in  posted by john_clarke on Nov 29, 2009 at 12:36 a.m. EST
  • 301 redirect - non-www to www
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    

    copy | embed

    0 comments - tagged in  posted by carsonblack on Nov 18, 2009 at 4:18 a.m. EST
  • arquivo de propriedade do log4j
    # Configura dois appenders (stdout para o console, fileout para um arquivo)
    # para o logger padrão, e configura um nível (INFO). Como todos os
    # loggers que criamos herdam do logger padrãoo, quaisquer loggers que criarmos
    # terão esta configuração
    log4j.rootCategory=INFO, stdout, fileout
    # O primeiro appender escreve para o console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    # O padrão para apresentação do conteúdo (layout)
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
    # O segundo appender escreve para um arquivo
    log4j.appender.fileout=org.apache.log4j.RollingFileAppender
    log4j.appender.fileout.File=exemplo.log
    # Controla o tamanho máximo do arquivo de log
    log4j.appender.fileout.MaxFileSize=500KB
    # Arquiva arquivos de log (somente um arquivo de backup)
    log4j.appender.fileout.MaxBackupIndex=1
    # O padrãoo para apresentação do conteúdo (layout)
    log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
    log4j.appender.fileout.layout.ConversionPattern=(%F:%L) %p %t %c - %m%n
    

    copy | embed

    0 comments - tagged in  posted by mwanalezi on Nov 16, 2009 at 9:00 p.m. EST
  • Mediatemple (dv) server - Plesk & Apache restart
    /usr/local/psa/admin/sbin/websrvmng -a -v
    

    copy | embed

    0 comments - tagged in  posted by erincarter on Nov 15, 2009 at 12:37 a.m. EST
  • django wsgi apache vhost
    <VirtualHost *:8080>
        ServerAdmin  user@domain.com
        ServerName   domain.com
        ServerAlias  sub.domain.com
        LogLevel     warn
        ErrorLog     /var/www/project/log/error.log
        CustomLog    /var/www/project/log/access.log combined
    
        <Location "/">
            SetHandler         python-program
            PythonPath         "['/var/www/project'] + sys.path"
            PythonHandler      django.core.handlers.modpython
            SetEnv             DJANGO_SETTINGS_MODULE project.settings
            PythonDebug        Off
            PythonInterpreter  project
        </Location>
    
    </VirtualHost>
    

    copy | embed

    0 comments - tagged in  posted by nick on Nov 12, 2009 at 3:15 p.m. EST
  • mac os x apache development setup
    ##
    ##  This will setup a fresh install of Mac OS X up for AUTOMATICALLY serving
    ##  custom top level domains (such as .dev or .test) for your development 
    ##  environment on a MacBook Pro laptop.  You no longer have to muck with adding
    ##  VirtualHosts  or editing /etc/hosts files, and you definitely dont need 
    ##  to download MAMP.
    ##
    ##  I recommend executing commands below by hand. 
    ##
    ##  After completion of all the commands, add  ""127.0.0.1""  (without quotes)
    ##  to the top of the list of DNS servers in:
    ##    
    ##     System Preferences > Network > Advanced... > DNS tab > DNS Servers
    ##
    ##  The directory structure of your ~/Sites folder should be the following: 
    ##   ~/Sites
    ##     |- dev
    ##     |  |- project1
    ##     |  |  |- public
    ##     |  |  |  |- index.html
    ##     |  |  |  |- otherpage.html
    ##     |  |- subdomainswork.project2
    ##     |  |  |- public
    ##     |  |  |  |- index.html
    ##
    ##  The BIND / Apache configurations explained below combined with the above 
    ##  example folder structure would enable the following:
    ##
    ##   http://localhost/                
    ##          <--- /Users/username/Sites/ 
    ##   http://project1.dev/             
    ##          <--- /Users/username/Sites/dev/project1/public/
    ##   http://subdomainswork.project2.dev/
    ##          <--- /Users/username/Sites/dev/SubDomainsWork.Project2/public/
    ##
    ##  The code here is a summarized version of the instructions and comments in a 
    ##  blog entry by Jason Johnoson of postpostmodern.com, originally posted here:
    ##
    ##     http://postpostmodern.com/instructional/a-smarter-mamp/ 
    ##
    
    
    E_BADARGS=85
    if [ -z "$1" ]
    then
      echo "Usage: `basename $0` tld"
      exit $E_BADARGS
    fi
    
    # edit the following as desired, if running this by hand
    USERNAME=`whoami`
    TLD=$1
    
    # The file needs to be ran as your regular Mac OS X user, not root.
    if [[ `whoami` = "root" ]] 
    then
     echo "Please execute this script as an admin user, do not use the sudo command."
     echo "Usage: `basename $0` tld"
     exit 0
    fi
    
    
    
    ############################
    ##   BIND Configurations  ##
    ############################
    
    # Create a custom launch key for BIND
    if [ ! -e /etc/rndc.conf ]
    then 
      echo "Creating RNDC"
      sudo rndc-confgen > /etc/rndc.conf
      sudo head -n 6 /etc/rndc.conf > /etc/rndc.key
    fi
    
    
    if [ ! -e /var/named/$TLD.zone ]
    then
      # Add the top level domain to BIND.
      echo "Adding TLD '$TLD' to BIND"
      sudo chmod 777 /etc/named.conf
      cat >> /etc/named.conf <<END
    zone "$TLD" IN {
      type master;
      file "$TLD.zone";
    };
    END
      # Create the Zone file for BIND
      echo "Creating zone file for $TLD (/var/named/$TLD.zone)"
      sudo chmod 644 /etc/named.conf
      sudo touch /var/named/$TLD.zone
      sudo chmod 777 /var/named/$TLD.zone
      cat > /var/named/$TLD.zone <<END
    ;
    ; BIND data file for $TLD sites
    ;
    \$TTL    604800
    @       IN      SOA     $TLD. root.$TLD. (
                         2008101920         ; Serial
                             604800         ; Refresh
                              86400         ; Retry
                            2419200         ; Expire
                             604800 )       ; Negative Cache TTL
    ;
    @       IN      NS      $TLD.
    @       IN      A       127.0.0.1
    *.$TLD.  14400   IN      A       127.0.0.1
    END
    fi
      sudo chmod 644 /var/named/$TLD.zone
    
    # Allow named daemon to be launched on boot. 
    if [[ `sudo defaults read /System/Library/LaunchDaemons/org.isc.named Disabled` = 1 ]]
    then 
      echo "Configuring BIND LaunchDaemon"
      # Unfortunately this will convert the plist from XML to binary format! 
      sudo defaults write /System/Library/LaunchDaemons/org.isc.named Disabled -boolean true
      # here's an alternate  that maintains the file in human-readable text format.
      # sed -n 5,6s/<true/<false/  /System/Library/LaunchDaemons/org.isc.named.plist
    fi
    # Load/Reload BIND
    sudo launchctl load /System/Library/LaunchDaemons/org.isc.named.plist
    
    
    ###############################
    ##  Bonjour Configurations   ##
    ###############################
    
    
    if [ ! -e /etc/resolver/$TLD ]
    then
      echo "Creating top level domain entry in Bonjour for '$TLD'"
      if [ ! -d /etc/resolver ] ; then sudo mkdir /etc/resolver ; fi
      # Enable Bonjour to serve your top level domain when you aren't connected to the internet
      sudo chmod 777 /etc/resolver
      cat > /etc/resolver/$TLD <<END
    domain $TLD
    nameserver 127.0.0.1
    END
    fi
      sudo chmod 755 /etc/resolver
      
    ###############################
    ##  TLD VirtualHost Folder   ##
    ###############################
    
    if [ ! -e "/Users/$USERNAME/Sites/$TLD" ]
    then
       echo "Creating ~/Sites/$TLD folder for user $USERNAME"
       mkdir -p "/Users/$USERNAME/Sites/$TLD"
    else
       echo "~/Sites/$TLD exists."
    fi
    
    ###############################
    ##  Apache Configurations    ##
    ###############################
    
    # create a new apache configuration for your user.
    echo "Updating Apache config /etc/apache2/users/$USERNAME.conf for NameVirtualHost mode."
    sudo mv /etc/apache2/users/$USERNAME.conf /etc/apache2/users/$USERNAME.conf.`date "+%Y%m%d%H%M%S"`
    sudo chmod 777 /etc/apache2/users
    cat > /etc/apache2/users/$USERNAME.conf <<END
    DocumentRoot /Users/$USERNAME/Sites
    <Directory "/Users/$USERNAME/Sites/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    NameVirtualHost 127.0.0.1
    <VirtualHost 127.0.0.1>
        VirtualDocumentRoot /Users/$USERNAME/Sites/%-1/%-2+/public
    </VirtualHost>
    END
    sudo chmod 755 /etc/apache2/users
    
    # restart apache, You may wan to check in the Console.app for any apache errors.
    echo "Restarting Apache."
    sudo apachectl restart
    
    
    # Dont forget to add 127.0.0.1 to the list of DNS servers in System Preferences  (see above).
    # You'll also need to add probably some other DNS entries as well. I recommend OpenDNS.
    

    copy | embed

    0 comments - tagged in  posted by jrguitar21 on Nov 09, 2009 at 2:56 a.m. EST
  • Apache directory listing tweaking
    ### Add this in httpd.conf for some directory listing tweaking ###
    IndexOptions FancyIndexing NameWidth=* 
    IndexOptions XHTML HTMLtable 
    IndexOptions SuppressHTMLPreamble 
    IndexOptions FoldersFirst
    
    # set charset and make icons links
    IndexOptions Charset=UTF-8 IconsAreLinks
    IndexOptions IconHeight=16
    IndexOptions IconWidth=16
    
    IndexHeadInsert "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><script type=\"text/javascript\" src=\"http://www.google.com/jsapi\"></script><script type=\"text/javascript\">google.load(\"mootools\", \"1.2.4\");</script><script type=\"text/javascript\" src=\"http://domain.com/script.js\"></script>"
    
    IndexStyleSheet "http://domain.com/style.css"
    

    copy | embed

    0 comments - tagged in  posted by fevangelou on Oct 25, 2009 at 7:36 a.m. EDT
Sign up to create your own snipts, or login.