How to set up EPrints on virtual directories other than root

From EPrints Documentation
Revision as of 19:55, 26 July 2010 by Dkane (talk | contribs) (EPrints setup under virtual directories other than / (or how to share EPrints with other web applications on the same server))
Jump to: navigation, search

EPrints setup under virtual directories other than / (or how to share EPrints with other web applications on the same server)

Perhaps you have ever wondered if it's possible to use the same web server for EPrints and other web applications.

There are 3 ways of getting EPrints to cohabit with other content/applications.

  • Set up eprints in a subdirectory of the EPrints server, leaving the root directory free for other things.
  • Set up eprints in the root directory and make a subdirectory that is not controlled by EPrints (See: How to add a subdirectory that runs PHP scripts )
  • Set up eprints in a separate server and use Apache's ProxyPass directives to make it appear in your chosen server.

This page takes you through the last of these three options:

In this scenario, you are faced faced with the fact that EPrints software requires, as for Apache configuration respects, that two important virtual directories (/ and /perl) are redirected to EPrints proprietary physical directories (/opt/eprints2/archives/archiveID/html/ and /opt/eprints2/cgi respectively, as stated in /opt/eprints2/archives/archiveID/cfg/auto-apache.conf). This condition makes impossible, in a first approach, to share EPrints web server with other applications than EPrints itself.

However, this small document explains in detail how to overcome this limitation. It closely mimics the situation at Complutense University, Madrid, Spain.

Starting environment

We have at our disposal one corporative web server ( with the following setup, imposed by our computing services:

  • The main Apache listens to requests on HTTP port #80 and has not built-in mod_perl support.
  • The main campus web site is located under
  • The secondary Apache listens to requests on HTTP port #8000 and has built-in mod_perl support. This is the one to be used for EPrints. We'll use port #8084.
  • Both Apaches run under user nobody.

In order for our customers to be able to acces EPrints service from the main campus web site, we'll configure Apache and EPrints so the software be accessible through

EPrints version used for this tests is 2.3.11.

Web server configuration steps

To be performed in the following order.

  • Main Apache configuration (campus web site)

As for EPrints concerns, this Apache has to redirect all requests for to the 8084 port of the secondary Apache with mod_perl. So its file httpd.conf needs to be modified like this:

ProxyPass /eprints
ProxyPassReverse /eprints

These lines have to be included at the end of the file, outside the virtual hosts sections (if any). Of course, replace with your server name, as fixed in your DNS, and /eprints with the name of the virtual directory you'd like to be used.

  • Secondary Apache configuration (EPrints one)

It has to manage HTTP requests redirected from the main Apache to its 8084 port, so you have to define a virtual host for HTTP port #8084, as well as a default virtual host (required if you want to use virtual hosts; see Apache documentation). The httpd.conf file must be like this:

### Section 1: Global Environment
Listen 8000
Listen 8084
### Section 2: 'Main' server configuration
Port 8000
Port 8084
### Section 3: Virtual Hosts
NameVirtualHost *:8000
<VirtualHost _default_:8000>
   DirectoryIndex index.php index.html index.htm
<VirtualHost *:8084>
   DirectoryIndex index.html
Include /opt/eprints2/cfg/apache.conf

Please be aware that this configuration example is very simplistic. Virtual hosts sections can have lot of directives. We've only reflected here the minimum required. Once again, you'll have to customize

EPrints installation

The most time consuming task is to find the appropriate parameters to be used during EPrints installation and initial archive creation. After several tests, this are the keys for success, following the steps from official EPrints documentation (, and modified when needed. The whole process is run under user nobody (the owner of Apache).

  • Unpack the eprints tar.gz file:
% gunzip eprints-2.something.tar.gz
% tar xf eprints-2.something.tar
  • Run the "configure" script:
% cd eprints-2.something
% ./configure --with-user=nobody --with-group=nobody --with-apache=1

It is very important that you do not specify the parameter --with-virtualhost. EPrints doesn't need it, and so you won't have to take care of certain additional configuration files. The parameter --with-apache=1 is employed here because our Apache releases are 1.x.

  • Run
% ./

EPrints configuration

  • Creating the archive

From EPrints directory (/opt/eprints2 by default) run bin/configure_archive. The answers to the questions asked by this script are:

Archive ID? archiveID
Webserver Port [80]? 8084
Alias (enter # when done) [#] ? #
Administrator Email? ******
Archive Name? ******
Database Name [bucm] ? eprints.database
MySQL Host [localhost] ?
MySQL Port (# for no setting) [#] ? #
MySQL Socket (# for no setting) [#] ? #
Database User [bucm] ? ******
Database Password ? ******
Create database ?eprints.database? [yes] ? yes
MySQL Root Password ? *******
Create config files [no] ? yes
Hit return to continue [] ? 

You have to use your own values for the fileds replaced by ****** and for archiveID,, eprints.database,

  • Configuration files modifications

We have to change certain EPrints configuration files so all the software processes to be run in the future correctly implement the base URL we want to deploy ( The changes required are commenting code lines and including new ones, as you can see below:

/opt/eprints2/archives/archiveID/cfg/, section "Server of static HTML + images, including port"

# Server of static HTML + images, including port
# $c->{base_url} = "http://$c->{host}";
# if( $c->{port} != 80 )-]
# {
#     # Not SSL port 443 friendly
#     $c->{base_url}.= ":".$c->{port};
# }
# $c->{base_url} .= $c->{urlpath};
$c->{base_url} = "";

/opt/eprints2/perl_lib/EPrints/, subroutine get_uri

# sub get_uri
# {
#     my( $self ) = @_;
#     return( $self->{"request"}->uri );
# }
sub get_uri  {
   my( $self ) = @_;
   my $uri= $self->{"request"}->uri;
   if( $uri =~ m+^/+ && $uri !~ m+/eprints+i ){
       $uri = "/eprints" . $uri;
   return $uri;

/opt/eprints2/cgi/users/home, section "Render page"

# my $changeuserpath = "/change_user/".($user->get_value( "username" ));
my $changeuserpath = "/eprints/change_user/".($user->get_value( "username" ));

IMPORTANT NOTE: Though EPrints will be used under instead of, there is no need for modifying urlpath parameter inside /opt/eprints2/archives/archiveID.xml file (the corresponding line must remain as <urlpath></urlpath>).

  • The remaining steps are those we all now, without changes from official EPrints documentation. From EPrints directory (/opt/eprints2 by default), run:
% bin/create_tables archiveID
% bin/import_subjects archiveID
% bin/generate_static archiveID
% bin/create_user archiveID USERID EMAIL admin PASSWORD
% bin/generate_views archiveID
% bin/generate_apacheconf

And do not forget to add the usual periodical tasks to the crontab of the user under which EPrints runs (nobody in our example): generate_views, generate_abstracts, send_subscriptions (daily, weekly and monthly), indexer.

Web server restart

Of course, once all changes are done, you have to restart the affected Apache servers (main Apache and secondary Apache), stopping and starting their daemons (do not use the apachectl restart command).