title: Apache: Execute Javascript files like .php files
body: <p><strong>Apache and PHP</strong></p>
  
  <p>PHP with Apache is really nice to play with because you can create a random <code>test.php</code> with</p>
  
  <pre><code>echo '&lt;h1&gt;Hello World&lt;/h1&gt;';
  </code></pre>
  
  <p>and when you visit <a href="http://myserver.com/test.php" rel="nofollow">http://myserver.com/test.php</a> it will show <code>&lt;h1&gt;Hello World&lt;/h1&gt;</code></p>
  
  <p><strong>My wish with Apache and JS</strong></p>
  
  <p>What I would like is to create a file <code>test.js</code> with</p>
  
  <pre><code>console.log('&lt;h1&gt;Hello World&lt;/h1&gt;');
  </code></pre>
  
  <p>and when I visit <a href="http://myserver.com/test.js" rel="nofollow">http://myserver.com/test.js</a> it would show <code>&lt;h1&gt;Hello World&lt;/h1&gt;</code></p>
  
  <p><strong>What's possible currently</strong></p>
  
  <p>The nearest attempt I found was <a href="http://www.modjs.org/" rel="nofollow">http://www.modjs.org/</a> but it is no longer maintained.</p>
  
  <p>Meanwhile we can run a <a href="http://arguments.callee.info/2010/04/20/running-apache-and-node-js-together/" rel="nofollow">run a NodeJS instance</a> and simulate apache with file listing and executing javascript files based on the url, but it sucks ...</p>
  
  <p>Anyone knows if it's possible? :)</p>
  
  <p>Thanks!</p>