Setting up apache to serve PHP when an MP3 file is requested

Active3 hr before
Viewed126 times

6 Answers


Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers ,However, that example doesn't appear to work when I use it as the source in an audio tag like this,Thanks for contributing an answer to Stack Overflow!, Stack Overflow Public questions & answers

The rest looks fine. But I would also send the 404 status code if the file cannot be found.

$track = "lilly.mp3";

if (file_exists($track)) {
   header("Content-Type: audio/mpeg");
   header('Content-Length: '.filesize($track));
   header('Content-Disposition: inline; filename="lilly.mp3"');
   header('X-Pad: avoid browser bug');
   header('Cache-Control: no-cache');
} else {
      ' 404 Not Found', true, 404);
   echo "no file";
load more v

And then restart apache.,You need to modify your mime.types file not your httpd.conf file. Add (or modify) the following line to your mime.types file and restart Apache. ,I added the following code to httpd.conf, but there is not any difference!, Security Delete files

You need to modify your mime.types file not your httpd.conf file. Add (or modify) the following line to your mime.types file and restart Apache.

audio / mpeg mpga mp2 mp3
load more v

You can make the web server accessible on port 8000 to any interface with: , The built-in Web Server should not be used on a public network. , To reuse a framework router script during development with the CLI web server and later also with a production web server: , The CLI SAPI provides a built-in web server.

$ cd~/public_html
$ php - S localhost: 8000
load more v

Checking PHP Modules from the ProcessMaker Interface,Checking the PHP Modules,Checking the ProcessMaker Requirements,Compression to Improve ProcessMaker Performance

Configuring Apache

To configure Apache, edit its httpd.conf file (or apache2.conf and ports.conf files if using Debian/Ubuntu). The other file to modify is the pmos.conf file, which holds the VirtualHost definition for ProcessMaker. The location of these two files depends upon the operating system:

load more v

Modify your Apache HTTP Server configuration file (httpd-vhosts.conf) to point to the Build Forge application.,Install PHP and configure the PHP modules required for the Apache HTTP Server, your Build Forge database, and password encryption if you want to use this security feature.,To use your existing Apache HTTP Server, modify your installation as follows: ,PHP is not installed with the Apache HTTP Server. You must install PHP 5.2.4 and configure it to point to the httpd-vhosts.conf for the Apache HTTP Server.

cd <apache-dir>/conf/extras/
   vi httpd-vhosts.conf
load more v

HTTP range requests allow to send only a portion of an HTTP message from a server to a client. Partial requests are useful for large media or downloading files with pause and resume functions, for example.,Partial request responses,In case of no support of range requests, the 200 OK status is sent back from a server.,In case of a successful range request, the 206 Partial Content status is sent back from a server.

If the Accept-Ranges is present in HTTP responses (and its value isn't "none"), the server supports range requests. You can check this by issuing a HEAD request with cURL, for example.

curl - I http: //

   HTTP / 1.1 200 OK
   Accept - Ranges: bytes
Content - Length: 146515

If sites omit the Accept-Ranges header, they likely don't support partial requests. Some sites also explicitly send "none" as a value, indicating no support. In some apps, download managers disable their pause buttons in that case.

curl - I https: //

   HTTP / 1.1 200 OK
   Accept - Ranges: none
load more v

Other "serve-apache" queries related to "Setting up apache to serve PHP when an MP3 file is requested"