Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a VirtualHost to serve only static content

I want to create a virtual host in apache such that it serves only static content like stylesheets, videos, images, javascripts, text files, etc. I am not looking at any "processing" capabilities from this virtual host.

like image 900
deostroll Avatar asked Jun 24 '10 17:06

deostroll


People also ask

How is static content served?

There are three steps to requesting static content from a server: A user sends a request for a file to the web server. The web server retrieves the file from disk. The web server sends the file to the user.

Is Apache a static server?

Simply put, Apache HTTP server is a web server designed to serve static web pages. Whereas, Apache Tomcat is an application server built to serve java applications. Web pages can still be served through Apache Tomcat, but it will be less efficient than using an Apache HTTP server.


1 Answers

Create a VirtualHost entry as follows:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName media.domain.tld

    DocumentRoot "/Library/WebServer/Documents/media"

    ErrorLog "/private/var/log/apache2/media-error_log"
    CustomLog "/private/var/log/apache2/media-access_log" common

    <Directory /Library/WebServer/Documents/media>
    Order deny,allow
    Allow from all
    SetHandler default-handler
    </Directory>

</VirtualHost>
like image 107
viam0Zah Avatar answered Oct 17 '22 02:10

viam0Zah