<commit_before>#!/bin/bash
#
# Setup Lighttpd w/ APC for Wordpress
#
# Assumes the host is clean unconfigured CentOS 6 / EL 6 derivatives (inc Amazon Linux AMI). Should be idempotent.
#
# Adlibre Pty Ltd 2012
#

## Configuration
WWW_ROOT='/srv/www'
SERVER_NAME=`hostname`
APC_SHM_SIZE='256M'
# APC: use 0, 600, 600 to flush cache in case of APC memory exhaustion (prevents fragmentation too) 
APC_TTL=0 
APC_USER_TTL=600
APC_GC_TTL=600
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000

## Constants
LOGFILE='install.log'

echo "### Beginning Install ###"

( # Start log capture

## Start

# Install base packages
yum -y install lighttpd-fastcgi php php-mysql php-gd php-xml php-pecl-apc

# Configure Lighttpd Permissions
mkdir -p /var/cache/lighttpd/compress /var/run/lighttpd
chown -R lighttpd:lighttpd /var/cache/lighttpd/ /var/run/lighttpd
chown root:lighttpd /var/lib/php/session/
mkdir -p ${WWW_ROOT}

# turn on services
chkconfig lighttpd on

# Configure Lighttpd base config
cp -n /etc/lighttpd/modules.conf /etc/lighttpd/modules.conf.orig # backup
cp -n /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig # backup

# enable lighttpd modules
sed -i -e 's@#  "mod_alias",@  "mod_alias",@g' /etc/lighttpd/modules.conf
sed -i -e 's@#  "mod_redirect",@  "mod_redirect",@g' /etc/lighttpd/modules.conf
sed -i -e 's@#  "mod_rewrite",@  "mod_rewrite",@g' /etc/lighttpd/modules.conf
# enable lighttpd features
sed -i -e 's@#include "conf.d/compress.conf"@include "conf.d/compress.conf"@g' /etc/lighttpd/modules.conf
sed -i -e 's@#include "conf.d/fastcgi.conf"@include "conf.d/fastcgi.conf"@g' /etc/lighttpd/modules.conf
sed -i -e 's@#include "conf.d/expire.conf"@include "conf.d/expire.conf"@g' /etc/lighttpd/modules.conf
# enable vhost includes
sed -i -e 's@#include_shell "cat /etc/lighttpd/vhosts.d/*.conf"@include_shell "cat /etc/lighttpd/vhosts.d/*.conf"@g' /etc/lighttpd/lighttpd.conf

# Configure Lighttpd vhost
cat > /etc/lighttpd/vhosts.d/${SERVER_NAME}-wordpress.conf << EOF
    # Wordpress Lighttpd Config for ${SERVER_NAME}
    
    # Redirect naked domain to www
    \$HTTP["host"] != "^(www.${SERVER_NAME})" {
        url.redirect = ( "^/(.*)" => "http://www.${SERVER_NAME}/\$1" )<commit_msg>Escape sed asterisk<commit_after>#!/bin/bash
#
# Setup Lighttpd w/ APC for Wordpress
#
# Assumes the host is clean unconfigured CentOS 6 / EL 6 derivatives (inc Amazon Linux AMI). Should be idempotent.
#
# Adlibre Pty Ltd 2012
#

## Configuration
WWW_ROOT='/srv/www'
SERVER_NAME=`hostname`
APC_SHM_SIZE='256M'
# APC: use 0, 600, 600 to flush cache in case of APC memory exhaustion (prevents fragmentation too) 
APC_TTL=0 
APC_USER_TTL=600
APC_GC_TTL=600
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000

## Constants
LOGFILE='install.log'

echo "### Beginning Install ###"

( # Start log capture

## Start

# Install base packages
yum -y install lighttpd-fastcgi php php-mysql php-gd php-xml php-pecl-apc

# Configure Lighttpd Permissions
mkdir -p /var/cache/lighttpd/compress /var/run/lighttpd
chown -R lighttpd:lighttpd /var/cache/lighttpd/ /var/run/lighttpd
chown root:lighttpd /var/lib/php/session/
mkdir -p ${WWW_ROOT}

# turn on services
chkconfig lighttpd on

# Configure Lighttpd base config
cp -n /etc/lighttpd/modules.conf /etc/lighttpd/modules.conf.orig # backup
cp -n /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig # backup

# enable lighttpd modules
sed -i -e 's@#  "mod_alias",@  "mod_alias",@g' /etc/lighttpd/modules.conf
sed -i -e 's@#  "mod_redirect",@  "mod_redirect",@g' /etc/lighttpd/modules.conf
sed -i -e 's@#  "mod_rewrite",@  "mod_rewrite",@g' /etc/lighttpd/modules.conf
# enable lighttpd features
sed -i -e 's@#include "conf.d/compress.conf"@include "conf.d/compress.conf"@g' /etc/lighttpd/modules.conf
sed -i -e 's@#include "conf.d/fastcgi.conf"@include "conf.d/fastcgi.conf"@g' /etc/lighttpd/modules.conf
sed -i -e 's@#include "conf.d/expire.conf"@include "conf.d/expire.conf"@g' /etc/lighttpd/modules.conf
# enable vhost includes
sed -i -e 's@#include_shell "cat /etc/lighttpd/vhosts.d/\*.conf"@include_shell "cat /etc/lighttpd/vhosts.d/\*.conf"@g' /etc/lighttpd/lighttpd.conf

# Configure Lighttpd vhost
cat > /etc/lighttpd/vhosts.d/${SERVER_NAME}-wordpress.conf << EOF
    # Wordpress Lighttpd Config for ${SERVER_NAME}
    
    # Redirect naked domain to www
    \$HTTP["host"] != "^(www.${SERVER_NAME})" {
        url.redirect = ( "^/(.*)" => "http://www.${SERVER_NAME}/\$1" )
{'fraction_non_alphanumeric': 0.15297833935018051, 'fraction_numerical': 0.013086642599277979, 'mean_word_length': 4.233766233766234, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1033860', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1748, 'n_words': 390}