View Full Version : apache2 with multiple directories
August 22nd, 2010, 09:30 AM
Apache2 default directory is /var/ww. Is it possible to add one more directory(/usr/share/tomcat/webapps) to apache config.? so that i can have both /var/www as well as /usr/share/tomcat/webapps
Thank you all!
August 23rd, 2010, 06:45 PM
Yes. There are several ways to do that. One is to make use of the runtime directives, directory (http://httpd.apache.org/docs/2.3/mod/core.html#directory) and, maybe, alias (http://httpd.apache.org/docs/2.3/mod/mod_alias.html#alias).
August 27th, 2010, 02:49 PM
Please any one show me how to do this without any errors..
August 27th, 2010, 07:16 PM
I just use vhosts.
Create a file in /etc/apache2/sites-available for each subdomain you'd like to host and then enable those domains.
This is a very simple example for hostname website and would be located at /etc/apache2/sites-available/website
This is an SSL site located at /etc/apache2/sites-available/ecommerce
I like to add this to the bottom of my /etc/apache2/apache2.conf file so that traffic gets compressed and I set expires headers...
# GZIP files
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0 no-gzip
BrowserMatch \bMSIE <img src="no-gzip" alt="" />gzip-only-text/html
# Expire Headers
ExpiresDefault "access plus 10 years"
To enable a website just type...
Then, restart apache
Doing this, you can add many different directories to host websites (although, I'd recommend putting all your created apps in /var/www, that's the default).
Just make sure they are owned by www-data with the correct permissions...
chown -R www-data:www-data /var/www
chmod -R 755 /var/www
Hope that helps.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.