How to serve static content from Apache Web Server?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Web Server (EWS) 1.x,2.x
  • Apache httpd 2.2.x

Issue

  • How can we include static content from external shared folders in EWS/Apache httpd? Any requests to these resources should be excluded from mod_jk AJP. Currently these contents are being deployed as part of our EAP(with entries in profile.xml and vfs.xml), which in fact, is not required. This causes lot of time being spent in deployment.
  • How to use Alias to server static files from Apache httpd?

Resolution

  • A simple test case would be as follows:
  1. Create images in the /var/www/img directory
  2. In httpd.conf, have the following configuration.
<VirtualHost *:80>
ServerName myapp.example.com
DocumentRoot /var/www/
Alias /images "/var/www/img/"  
<Directory "/var/www/img">  
Options +Indexes  
AllowOverride None  
Order allow,deny  
Allow from all  
</Directory>
</VirtualHost>
  1. Go to url http://localhost/images and you should see the images listed.To prevent directory listings remove Options +Indexes.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.