LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-03-2016, 09:03 PM   #1
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,706
Blog Entries: 4

Rep: Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949
Apache2 is serving the source-code of a DirectoryIndex "default.php"


Yeah, I know that I'm doing something a little bit unconventional here: directing PHP scripts through a special AddHandler which consists of a short shell-script that executes PHP with a particular php.ini file. And it almost works.
  • If you ask for the home-page, e.g. http://mysite.com, the source code of the DirectoryIndex "default.php" will be printed out!

  • But, if you specify this or any other php-file (that exists ...) explicitly, e.g. http://mysite.com/default.php, the script is executed (using my handler).
In other words, if the DirectoryIndex file is to be served (because no filename has been mentioned ...), it is being served as text, not as an executable. Any PHP-file mentioned by name on the command line is executed by the handler.

This is a Ubuntu system. In an activated config I have this:
Code:
# PHP file
AddHandler custom-php .php

# Direct these to the custom executable.
Action  custom-php   /frobozz-cgi/custom-php5.cgi  virtual

# This is the alias that must be used with the Action.
ScriptAlias /frobozz-cgi/ /my_custom/cgi-php5/

# Specify access to this resource.
<Directory "/my_custom/cgi-php5/">
    AllowOverride none
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Require all granted
</Directory>
where custom.cgi looks like this:
Code:
#!/bin/sh
exec /usr/bin/php5 --php-ini /my_custom/php.ini $PATH_TRANSLATED
and a relevant <VirtualHost> looks something like this:
Code:
<VirtualHost *:80>
    DocumentRoot   "/my_custom/documents"
    ServerName     mysite.com
    DirectoryIndex "default.php"
    
    <Directory "/my_custom/documents">
       Options FollowSymLinks
       Order allow,deny
       Allow from all
       AllowOverride All
       Require all granted
    </Directory>
</VirtualHost>

Last edited by sundialsvcs; 03-03-2016 at 09:04 PM.
 
Old 03-04-2016, 07:06 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,706

Original Poster
Blog Entries: 4

Rep: Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949Reputation: 3949
Oh, the worst possible thing just happened: "the problem went away." But, I know what I saw and that I saw it for several frustrating hours. If anyone else has encountered something like this, please advise. Continuing to look at it with a slightly less-sleepy head today . . .
 
Old 03-04-2016, 08:05 AM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
"All of a sudden"...

I've never seen quotes used around index.php on the DirectoryIndex directive...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Video interview with Google&#039;s Open Source Director Chris DiBona on a "default to code" mentali LXer Syndicated Linux News 0 12-10-2013 02:00 PM
Find me source code for "iwlist" & "iwconfig" Angela Wu Linux - Kernel 2 09-15-2013 08:44 PM
[SOLVED] problems with PHP, showing code trying to "run" a php file? michaelinux Slackware 1 12-29-2010 10:21 PM
Apache2 is serving PHP source files unless called without the extension rjlee Linux - General 3 12-08-2006 06:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration