How to set up EPrints on virtual directories other than root

From EPrints Documentation
Jump to: navigation, search

How to share EPrints with other web applications on the same server

In most cases, an EPrints installation will take over an entire virtual host, but it is possible to use the same web server for EPrints and other web applications together under the same host or domain.

There are 3 ways of doing this:

 1. Set up eprints in a subdirectory of the EPrints server, leaving the root directory free for other things.  
    (This is straightforward and can be done through bin/epadmin mod_core [repoid], or during initial setup)

 2. 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 )

 3. Set up eprints in a separate server and use Apache's ProxyPass directives to make it appear in your chosen server.
    (This Page!)

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

In this scenario, you have a 'border' server, perhaps administered by a security-conscious IT Services department. They do not want you to install Mod_Perl on this machine so you have to consider a way around this.

What follows is a detailed explanation of how to overcome this limitation. It closely mimics the situation at Complutense University, Madrid, Spain.

Assumed scenario

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 as user nobody.

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

EPrints version used for this tests is 2.3.11.

Web server configuration steps

It's recommended to perform the following task in the given 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 a 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, these are the keys for success, following the steps from official EPrints documentation (, and modified when needed. The whole process is run as 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 fields 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 know, 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).