Archive

Posts Tagged ‘apache’

Apache Caching Proxy Server

August 27, 2011 Leave a comment

This setup is using Apache 2.2 bundled with XAMPP, in Windows 7

Create new config file: /xampp/apache/conf/extra/httpd-cache-proxy.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

Listen 3128
NameVirtualHost *:3128
<VirtualHost *:3128>
    ErrorLog "logs/proxy-error.log"
    CustomLog "logs/proxy-access.log" combined

    <IfModule mod_proxy.c>
      ProxyRequests On
      ProxyVia On
      <Proxy *>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.1
      </Proxy>
    </IfModule>

    <IfModule mod_cache.c>
      LoadModule disk_cache_module modules/mod_disk_cache.so
      <IfModule mod_disk_cache.c>
        CacheEnable disk /
        CacheRoot "c:/xampp/apache/proxy/cache"
        CacheDirLevels 3
        CacheDirLength 5
        CacheMaxFileSize 10485760
        CacheMaxExpire 2592000
      </IfModule>
      ProxyTimeout 60
    </IfModule>
</VirtualHost>

Include this file to /xampp/apache/conf/httpd.conf

Include conf/extra/httpd-cache-proxy.conf

Make sure to create folder for CacheRoot. Restart Apache using XAMPP control panel or Windows Services (if you installed as service), and set browser’s proxy server to 127.0.0.1:3128.

Categories: Notes Tags: , ,

Trac on Fedora

November 6, 2010 Leave a comment

This is multiple projects installation, a continuation from previous posts.

Install required packages:

yum install trac mod_wsgi

Software: Trac 0.11.7, mod_wsgi 2.3

Trac folder: /var/svn/trac
Python eggs cache dir: /tmp/egg-cache

Create new trac environment

trac-admin /var/svn/trac/testproj initenv
  Project Name > Test Project
  Database connection string > [sqlite:db/trac.db]
  Repository type > [svn]
  Path to repository > /var/svn/repos/testproj

Create wsgi script

vim /var/svn/trac/trac.wsgi
#!/usr/bin/env python
import os
def application(environ, start_request):
  os.environ['TRAC_ENV_PARENT_DIR'] = '/var/svn/trac'
  os.environ['PYTHON_EGG_CACHE'] = '/tmp/egg-cache'
  from trac.web.main import dispatch_request
  return dispatch_request(environ, start_request)

Apache mod_wsgi settings

vim /etc/httpd/conf.d/trac.conf
# comment all settings in /etc/httpd/conf.d/wsgi.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /trac /var/svn/trac/trac.wsgi
<Directory /var/svn/trac>
  WSGIApplicationGroup %{GLOBAL}
  Order deny,allow
  Allow from all
</Directory>
<LocationMatch "/trac/[^/]+/login">
  AuthType Digest
  AuthName "Project Repository"
  AuthUserFile /var/svn/auth
  Require valid-user
</LocationMatch>

Grant administration right to admin user (trac>=0.11)

trac-admin /var/svn/trac/testproj permission add user1 TRAC_ADMIN

Set ownership

chown -R apache.apache /var/svn

Reload apache

service httpd reload

View list of projects - http://localhost/trac

Categories: Notes Tags: , , , ,

Apache + SVN on Fedora

November 6, 2010 1 comment

Create SVN repo, accessible from network, all users can read & checkout, certain users can write / commit

Software: Apache 2.2.11, Subversion 1.6.6, mod_dav_svn 1.6.6

File & folder:

/var/svn/
/var/svn/auth – authentication file
/var/svn/repos/ – project repositories

Install mod_dav_svn

yum install mod_dav_svn svn

Create SVN repo (refer previous post)

svnadmin create --fs-type fsfs /var/svn/repos/testproj

Create authentication file

htdigest [-c] <auth file> <realm> <username>
htdigest -c /var/svn/auth "Project Repository" user1

c – create file (exclude this flag when adding users)

Setup Apache + mod_dav_svn

vim /etc/httpd/conf.d/subversion.conf
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

<Location /svn>
  DAV svn
  SVNParentPath /var/svn/repos
  SVNListParentPath On
  AuthType Digest
  AuthName "Project Repository"
  AuthUserFile /var/svn/auth
  <LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
  </LimitExcept>
</Location>

Change ownership of the whole svn repo dir

chown -R apache.apache /var/svn

Note: Re-assign the ownership everytime you create a new repo

Lastly, reload apache

service httpd reload

View list of projects – http://localhost/svn
View contents of particular (myproj) project – http://localhost/svn/myproj

Categories: Notes Tags: , , ,

Deploy Turbogears 2.1 on Fedora

February 19, 2010 Leave a comment

(Update: Using Fedora 16)

Install mod_wsgi for apache

yum install mod_wsgi

Edit apache config: (/etc/httpd/conf/httpd.conf)

ServerName hostname:80

Workaround for mod_wsgi 2.x in Fedora, move this line:

Include conf.d/*.conf

… to below these lines:

User apache
Group apache

Add this to the end of the config file: (/etc/httpd/conf.d/wsgi.conf)

<IfModule mod_wsgi.c>
  WSGISocketPrefix /var/run/wsgi
</IfModule>

Using TG2 demo app from the previous post (HelloWorld), create apache config file for this app: (/etc/httpd/conf.d/HelloWorld.conf)

Listen 8080
NameVirtualHost *:8080

<VirtualHost *:8080>

  ServerAdmin webmaster@hostname
  ServerName hostname
  ErrorLog logs/hostname-error_log
  CustomLog logs/hostname-access_log common

  Alias /images/ /var/www/HelloWorld/images/
  Alias /css/ /var/www/HelloWorld/css/
  Alias /javascript/ /var/www/HelloWorld/javascript/

  WSGIDaemonProcess HelloWorld threads=10 processes=3
  WSGIProcessGroup HelloWorld
  WSGIScriptAlias / /var/www/HelloWorld/HelloWorld.wsgi

  <Directory /var/www/HelloWorld>
    Order deny,allow
    Allow from all
  </Directory>

</VirtualHost>

Create directory for static contents (do these as root):

mkdir -p /var/www/HelloWorld/python-eggs

Create wsgi script for apache to launch this app: (/var/www/HelloWorld/HelloWorld.wsgi)

import os, sys, site
appname = 'HelloWorld'
prev_sys_path = list(sys.path)
site.addsitedir('/usr/local/pythonenv/%s/lib/python2.6/site-packages' % appname)
new_sys_path = []
for item in list(sys.path):
    if item not in prev_sys_path:
        new_sys_path.append(item)
        sys.path.remove(item)
sys.path[:0] = new_sys_path
sys.path.append('/usr/local/turbogears/%s' % appname)
from pkg_resources import working_set, Environment
env = Environment('/usr/local/pythonenv/%s' % appname)
env.scan()
distributions, errors = working_set.find_plugins(env)
for dist in distributions:
    working_set.add(dist)
os.environ['PYTHON_EGG_CACHE'] = '/usr/local/turbogears/%s/python-eggs' % appname
from paste.deploy import loadapp
application = loadapp('config:/usr/local/turbogears/%s/production.ini' % appname)

Move TG2 public folder to static contents folder:

cp -r HelloWorld/helloworld/public/* /var/www/HelloWorld
chown -R apache.apache /var/www/HelloWorld

Move TG2 app to application folder:

mkdir -p /usr/local/turbogears
cp -r HelloWorld/ /usr/local/turbogears/

Create production config file of the app:

cd /usr/local/turbogears/HelloWorld
cp development.ini production.ini

Set debug to false: (/usr/local/turbogears/HelloWorld/production.ini)

debug=false

Set permission:

chown -R apache.apache /usr/local/turbogears

Finally, restart apache:

service httpd restart

Now, browse to http://localhost:8080

Categories: Notes Tags: , , ,

Thunderbird calendar + WebDAV

February 19, 2010 1 comment
Users synchronize their calendar in Thunderbird with calendar server (WebDAV) on Fedora

Users synchronize their calendar in Thunderbird with calendar server (WebDAV) on Fedora

Install Thunderbird & calendar plugin:

yum install thunderbird thunderbird-lightning

Install apache + mod dav:

yum install httpd mod_dav_svn

Calendars will be stored in /home/webmaster/calendar. Make sure to chmod 755 /home/webmaster

Setting up apache:

(/etc/httpd/conf.d/mod_dav.conf)

<IfModule mod_dav.c>
  Alias /calendar /home/webmaster/calendar
  <Directory /home/webmaster/calendar>
    DAV On
    Options +Indexes
    AuthType Basic
    AuthName "Calendar Authentication"
    AuthUserFile /home/webmaster/calendar.htpasswd
    <LimitExcept GET OPTIONS>
      require valid-user
    </LimitExcept>
    Order allow,deny
    Allow from all
  </Directory>
</IfModule>
<Directory /home/webmaster/calendar>
  AuthUserFile /home/webmaster/calendar.htpasswd
  AuthName "Calendar Authentication"
  AuthType basic
  require valid-user
</Directory>

Create user & password:

htpasswd -cb /home/webmaster/calendar.htpasswd username password

Create calendar directory & set permission:

mkdir /home/webmaster/calendar
chown -R apache /home/webmaster/calendar

Test the new configuration:

touch calendar.ics
cadaver http://localhost/calendar
put calendar.ics

Refer /var/log/httpd/error_log if there’s any error. Always check folder permission.

Create new calendar for Thunderbird (calendar name: Personal):

touch Personal.ics
cadaver http://localhost/calendar
[Authentication]
put Personal.ics

Launch Thunderbird

  1. Events & Tasks > Calendar (or Ctrl+Shift+C)
  2. File > New > Calendar
  3. ‘On the network’
  4. ‘iCalendar (ICS)’, location: http://localhost/calendar/Personal.ics
  5. Enter username & password (in /home/webmaster/calendar.htpasswd)

Create new event for the new calendar

Follow

Get every new post delivered to your Inbox.