SlashpacheConfigFiles: Difference between revisions

From SoylentNews
Jump to navigation Jump to search
No edit summary
(→‎Site Conf: Syntax highlighting.)
 
Line 81: Line 81:


Contents of /usr/local/slash/site/slashcott.org/slashcott.org.conf
Contents of /usr/local/slash/site/slashcott.org/slashcott.org.conf
<pre>
<syntaxhighlight lang="apache">
# note that if your site's path is a symlink, the
# note that if your site's path is a symlink, the
# path listed here is most likely the actual path;
# path listed here is most likely the actual path;
Line 193: Line 193:
</VirtualHost>
</VirtualHost>


</pre>
</syntaxhighlight>


[[Category:Development]]
[[Category:Development]]

Latest revision as of 21:37, 19 March 2014

SlashDocumentationIndex - parent These files are what tells Apache to be a slave to perl. Various apache functions are replaced by perl functions.

Notable things:

  • Anything ending in .pl is to be interpreted as a perl script handled by Apache::Registry
  • Apache is told Files ending in .tmpl are to be handled by Slash::Apache::TemplatePages
  • A number of perl modules are added to every Apache process
  • Database is set to mysql Slash::DB::MySQL
  • AllowOverride None is set on htdocs so .htaccess files will never work, and could not anyway due to the access control phase being taken over.
  • The virtual user and 'skin' are set. The code says 'skin' but this is actually a 'theme'
  • A number of Apache 'phases' have perl code added to them, which in most cases means Apache uses the perl code rather thamn its own. Among these:
    • First Apache phase: post-read-request
    • Second Apache phase: URI translation - the index page handler and userdir handler completely replaced
    • Fourth Apache phase: access control - Slash::Apache::Banlist, Slash::Apache::User
    • Ninth Apache phase: response, aka content handler
    • Eleventh Apache phase: cleanup- PerlCleanupHandler ,Slash::Apache::Log ,PerlCleanupHandler,Slash::Apache::Log::UserLog
  • AddHandler server-parsed .shtml , AddHandler server-parsed .inc


Main Conf

Located in usr/local/slash/httpd/

This is what the install does to create slash.conf from the default:
[root@slashcode httpd]# diff slash.conf.def  slash.conf
37a38,39
> #Include /usr/local/slash/site/slashcode.local/slashcode.local.conf
> Include /usr/local/slash/site/slashcott.org/slashcott.org.conf

contents of usr/local/slash/httpd/slash.conf :

# this is all the mod perl specific stuff that makes 
# slash the root handler for the site
# ... you might want to check to make sure these are not already
# defined in your main httpd.conf, if you have trouble

# $Id$

AddHandler perl-script .pl
PerlHandler Apache::Registry

# For template pages
<FilesMatch "\.tmpl">
        SetHandler perl-script
        PerlHandler Slash::Apache::TemplatePages
</FilesMatch>

# add in modules for compiling into each process
PerlModule Slash
PerlModule Slash::Apache
PerlModule Slash::Apache::User
PerlModule Slash::Apache::Log
PerlModule Slash::Display::Plugin
PerlModule Slash::XML::RSS

# used in a couple of .pl files
PerlModule Image::Size

# add other, or comment out, DB modules here
PerlModule Slash::DB::MySQL
#PerlModule Slash::DB::PostgreSQL

# add or comment out plugin modules
#PerlModule Slash::Journal
#PerlModule Slash::Search
#PerlModule Slash::XML::FZ

LimitRequestBody 75000
#Include /usr/local/slash/site/slashcode.local/slashcode.local.conf
Include /usr/local/slash/site/slashcott.org/slashcott.org.conf


Site Conf

This is the site specific file included at the end of the file above. The name will vary by site.

Contents of /usr/local/slash/site/slashcott.org/slashcott.org.conf

# note that if your site's path is a symlink, the
# path listed here is most likely the actual path;
# fix it and DocumentRoot if you want to
<Directory /usr/local/slash/site/slashcott.org/htdocs>
    Options FollowSymLinks ExecCGI Includes Indexes
    AllowOverride None
</Directory>

<VirtualHost *:80>
    ServerAdmin mcasadevall@slashcott.org
    DocumentRoot /usr/local/slash/site/slashcott.org/htdocs
    ServerName slashcott.org
    ErrorLog logs/slashcott.org_error_log
    CustomLog logs/slashcott.org_access_log common

    PerlSetupEnv On
    PerlSetEnv TZ GMT

    SlashVirtualUser slash
    SlashSetVar skin slashcode
    # this directive will compile all the templates
    # in the database, if cache_enabled is true
    # and template_cache_size is 0.  Set to On/Off.
    # Default is off since most sites don't need it
    # much and startup performance, as well as
    # memory usage, degrades when it is On...
    # setting template_cache_size to 100 or so is
    # probably a lot better
    SlashCompileTemplates Off
 
    ########################

    # First Apache phase:  post-read-request

    # if you have a frontend/backend setup and have X-Forwarded-For
    # headers (such as from mod_proxy_add_forward), use this
    # to properly populate remote_ip for formkeys etc.
    PerlPostReadRequestHandler Slash::Apache::ProxyRemoteAddr

    # Second Apache phase:  URI translation

    # this directive will redirect non-logged-in users to
    # index.shtml if they request the home page; turn it
    # on to help increase performance or if you are using something
    # other than index.pl for the index
    PerlTransHandler Slash::Apache::IndexHandler
    # this directive will display a user's pages at /~username
    PerlTransHandler Slash::Apache::User::userdir_handler

    # Third Apache phase:  header parsing

    # Fourth Apache phase:  access control
    PerlAccessHandler  Slash::Apache::Banlist
    PerlAccessHandler  Slash::Apache::User

    # Fifth Apache phase:  authentication
        
    # Sixth Apache phase:  authorization
        
    # Seventh Apache phase:  MIME type checking

    # Eighth Apache phase:  fixups

    # Ninth Apache phase:  response, aka content handler:
    # Apache::Registry and whatever else is in the slash.conf file

    # Tenth Apache phase:  logging

    # Eleventh Apache phase:  cleanup
    PerlCleanupHandler Slash::Apache::Log
    PerlCleanupHandler Slash::Apache::Log::UserLog

    ########################

    # this can be used to preload your .pl scripts in the parent,
    # saving both startup time and memory in the child
    # add/remove scripts from @pls (normally best to include only
    # and all commonly used scripts)
    PerlModule Apache::RegistryLoader;
    <Perl>
        # if you need to debug, temporarily turn this on
        # $Apache::Registry::Debug = 4;
        my @pls     = qw(index comments article users journal search ajax firehose);
        my $vhost   = 'slashcott.org';
        my $docroot = '/usr/local/slash/site/slashcott.org/htdocs';
        my $r       = Apache::RegistryLoader->new;

        for my $u (@pls) {
                my $f = "$docroot/$u.pl";
                $r->handler("/$u.pl", $f, $vhost) if -e $f;
        }
    </Perl>

    DirectoryIndex index.pl index.shtml
    ErrorDocument 404 /404.pl

    AddType text/xml .xml
    AddType application/rss+xml .rdf
    AddType application/rss+xml .rss
    AddType application/atom+xml .atom
    AddType text/vnd.wap.wml .wml

    # change default of "iso-8859-1" here (to, for example, utf-8)
    # if you change "content_type_webpage" in vars, and vice versa
    AddType text/html;charset=iso-8859-1 .shtml
    AddHandler server-parsed .shtml

    AddType text/html .inc
    AddHandler server-parsed .inc
</VirtualHost>