Difference between revisions of "How to set up EPrints on virtual directories other than root"

From EPrints Documentation
Jump to: navigation, search
(EPrints setup under virtual directories other than / (or how to share EPrints with other web applications on the same server))
Line 1: Line 1:
 
[[Category:Howto]]
 
[[Category:Howto]]
 
[[Category:Installation]]
 
[[Category:Installation]]
==EPrints setup under virtual directories other than / (or how to share EPrints with other web applications on the same server)==
+
==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.
 
Perhaps you have ever wondered if it's possible to use the same web server for EPrints and other web applications.

Revision as of 13:33, 28 July 2010

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.

 1. Set up eprints in a subdirectory of the EPrints server, leaving the root directory free for other things.

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

Starting environment

We have at our disposal one corporative web server (http://server.name/) 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 http://server.name/.
  • 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 http://server.name/eprints/.

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 http://server.name/eprints to the 8084 port of the secondary Apache with mod_perl. So its file httpd.conf needs to be modified like this:

ProxyPass /eprints http://server.name:8084
ProxyPassReverse /eprints http://server.name:8084

These lines have to be included at the end of the file, outside the virtual hosts sections (if any). Of course, replace server.name 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>
   ServerName server.name:8000
   DirectoryIndex index.php index.html index.htm
</VirtualHost>
<VirtualHost *:8084>
   ServerName server.name:8084
   DirectoryIndex index.html
</VirtualHost>
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 server.name.

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 (http://software.eprints.org/docs/php/installation.php), 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 install.pl:
% ./install.pl

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
Hostname? server.name
Webserver Port [80]? 8084
Alias (enter # when done) [#] ? #
Administrator Email? ******
Archive Name? ******
Database Name [bucm] ? eprints.database
MySQL Host [localhost] ? mysql.server.name
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, server.name, eprints.database, mysql.server.name.

  • 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 (http://server.name/eprints). The changes required are commenting code lines and including new ones, as you can see below:

/opt/eprints2/archives/archiveID/cfg/ArchiveConfig.pm, 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} = "http://server.name/eprints";

/opt/eprints2/perl_lib/EPrints/Session.pm, 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 http://server.name/eprints instead of http://server.name, 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).