Skip to main content

Posts

Showing posts with the label Apache

How to use logrotate with Apache's Tomcat (and any other Java process)

Logrotate is an excellent utility for managing log files that can start grow into an unmanageble size, Tomcat 's catalina.out is one such file. Most of the solutions (scroll down to the 'Rotate the logs' section) for managing catalina.out, or other log files generated by Tomcat or any Java process for that matter, don't mention the copytruncate option: Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one, It can be used when some program can not be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place. This basically means that you don't have to configure your logrotate script to restart Tomcat just so you can tidy up...

One suggestion re: Forbidden access via Apache Proxies

If you are getting the following error when configuring Apache 2.2's proxy support (mod_proxy): HTTP error code 403 Forbidden then you might want to take a look inside the error.log for your site. If you see an error message like this: [warn] proxy: No protocol handler was valid for the URL /SomeUrl. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. Then you might want to check that you have more than just mod_proxy enabled. Mod_proxy is more of a virtual module relying on other modules to perform the proxying work depending on the type required. A common mistake is to have enabled mod_proxy but not enabled mod_proxy_http. With Ubuntu or Debian you can enable them with the following two commands: a2enmod proxy a2enmod proxy_http Otherwise you will have to make manual symbolic links to them yourself. Technorati Tags: Apache , mod_proxy , proxy , HTTP , 403 , Forbidden , Andrew Beacock

A Capistrano recipe for restarting Apache 2 (on Linux)

Capistrano is the rather excellent tool for automating Rails application deployment. But it can do a lot more than just uploading Rails applications to live webservers. It's scripts are basically Rake scripts and so have the full power of Ruby behind then so you can pretty much write code to do anything that you want. I wanted a way to reload the configuration for my Apache2 web server running on my home Ubuntu server . I found a post on Mongrel and Capistrano 2.0 by John Ward which showed a very nifty way to create Capistrano tasks for variants of the same base command. My adapted version for controlling Apache is: namespace :apache do [:stop, :start, :restart, :reload].each do |action| desc "#{action.to_s.capitalize} Apache" task action, :roles => :web do invoke_command "/etc/init.d/apache2 #{action.to_s}", :via => run_method end end end Add this code to your config/deploy.rb . This will add four new tasks to Capistrano whi...

Using Apache to display a list of available Subversion repositories

If you have setup Apache to be able to serve multiple Subversion repositories from one parent Subversion path then you are probably wondering if there is a way to display the list of repositories available in that parent directory. By default Apache will give you a 403 permissions error reporting: 403 Forbidden You don't have permission to access /parent-subversion-directory on this server. To enable the repository listing you need to use the SVNListParentPath option (see "Listing available repositories in mod_dav_svn (server)" under "Enhancements and Bugfixes" in the 1.3 release notes) in the Apache virtual host setup. Note: this will only work in Subversion 1.3 and higher. Edit your Subversion Apache configuration file to add the SVNListParentPath On line, an example is given below: # Subversion <Location "/svn"> DAV svn SVNParentPath /svn SVNListParentPath On SVNIndexXSLT "/svnindex.xsl" </Location> If yo...

Supporting multiple Subversion (SVN) repositories with Apache

My previous posts about Subversion on Debian Linux ( installing , configuring , backported packages ) showed how I installed and configured my local repository that I use for my home projects. I also used these tutorials when installing Subversion at work. After creating a couple of repositories for different teams (all within the base /svn directory) I noticed that my Apache configuration file was starting to look a little repetitive: # Subversion - team A <Location "/a"> DAV svn SVNPath /svn/team-a SVNIndexXSLT "/svnindex.xsl" </Location> # Subversion - team B <Location "/b"> DAV svn SVNPath /svn/team-b SVNIndexXSLT "/svnindex.xsl" </Location> I plan on creating at least two more repositories for other teams and so this was repetition was starting to bother me. A colleague pointed out that SVNParentPath (scroll about 1/4 down) should be the solution. I rewrote my conf file to be the following...

Problems with Trac and backported Subversion on Debian Linux

After installing the backported package of Subversion last week and importing a pre-existing codebase into it I decided that now was a good time to put Trac on the server. Following my previously blogged Trac installation & configuration guides I was able to get Trac up and running fairly smoothly with one small problem: the "Browse Source" button was failing reporting some issue with "svn" being an unknown repository type. After some searching and thinking I realised that this was most probably due to conflict between the newer backported version of Subversion and the older Python Subversion bindings libraries. Here's how I resolved this issue: apt-get remove python2.3-subversion apt-get install python-subversion Refreshed my browser and everything worked correctly! Technorati Tags: Andrew Beacock , Trac , Subversion , Python , Backports , Debian

Installing Subversion 1.3.2 using Backports on Debian (Sarge) Linux

Following on from my previous posts about installing Subversion from source, here are some notes on how to do it using backported Debian packages . Add the following lines to your sources.list file in /etc/apt: # backports deb http://www.backports.org/debian sarge-backports main contrib non-free Update your Apt sources list: apt-get update Uninstall any old Subversion packages: apt-get remove subversion apt-get remove libsvn0 Install Subversion with 1.3.2 as a specific version (this causes the backported version to override the stable version): apt-get install libsvn0=1.3.2-5~bpo1 apt-get install subversion=1.3.2-5~bpo1 Check that the installed Subversion is the right one by using svn --version you should get something like: svn, version 1.3.2 (r19776) compiled Aug 12 2006, 12:05:49 ... Install the Apache2 Subversion modules: apt-get install libapache2-svn=1.3.2-5~bpo1 Follow my instructions on Configuring Subversion (svn) on Linux (Debian Stable) . There you go! Technorati Ta...

Upgrading Subversion (svn) to 1.3.2 on Linux (Debian Stable)

I upgraded my Subversion repository tonight from 1.2.1 to 1.3.2 and it was an absolute breeze! I followed the Subversion installation instructions that I've blogged about before (using the newly downloaded 1.3.2) ignoring the bit about installing Apache. Ran through the usual Linux make, make install stuff, restarted Apache and accessed the repository browser webpage which displayed the updated version number at the bottom. Couldn't have been simpler! Technorati Tags: Subversion , Debian , Linux , Andrew Beacock

Creating a Trac instance on Debian Linux

In a post back in October (has it really been that long?) I walked through how to install Trac on Debian Linux . This post will cover the configuration of Trac so that at the end you will have a running Trac system that you can use as a wiki, ticket manager and Subversion repository browser. First you need to decide where you want your Trac instance to live, I wanted mine to be accessible via a sub-section of a website, but I wanted the instance to live outside of that website's directory structure. I decided on /var/www/Trac which I would link to from within my other website. To create the instance run the trac-admin command as the root user like so: trac-admin /var/www/Trac initenv It will now ask you a number of questions about your environment and project: * Project Name - enter a human-readable name for your project, this will appear on emails, webpages, etc. * Database connection string - just hit return to use the default SQLite * Path to repository - the directory ...

Configuring Subversion (svn) on Linux (Debian Stable)

My last post documented how to install Subversion. This post will cover the resulting configuration of Apache, plus the creation of the initial repository. When you install Subversion, it adds two LoadModule lines to /etc/apache2/httpd.conf . This is not wanted as the Debian version of Apache2 installs things slightly differently from the default Apache (httpd.conf is not used, all this configuration now lives in apache2.conf, plus the loading of modules is done differently). edit /etc/apache2/httpd.conf and remove the 2 uncommented LoadModule lines. Debian loads modules a little differently that the default Apache2. It lists the available modules as individual configuration files within a mods-available directory, then enables these by linking to them from a mods-enabled directory. We need to create the two required module configuration files that are required by Subversion (we just removed them from /etc/apache2/httpd.conf !): cd /etc/apache2/mods-available echo "LoadM...

Installing Subversion (svn) on Linux (Debian Stable)

This post details my recent install of Subversion 1.2.1 on Debian Stable . The Debian packaged version of Subversion is currently only 1.1.4, but I wanted to install the latest version as it supports full WebDAV autoversioning & has the FSFS repository back end as the default. I wanted to access Subversion via the WebDAV protocol , this requires Apache2 . As Debian Stable only recently included the apache2 package, I had to update to that version first. Note: all these commands were run as the root user. Install Apache2: apt-get install apache2 That installs the web server and all the required packages, it does not start Apache by default, you need to edit /etc/default/apache2 and change NO_START to 0 , then run /etc/init.d/apache2 start to get the basic web server running. When you build Subversion from source, it requires the apxs2 tool to be able to build and install the Subversion extension modules. This is hidden away in the apache2-threaded-dev package, it's n...