?
Solved

Why is Apache2 web server on Debian Linux displaying script source code?

Posted on 2014-07-17
13
Medium Priority
?
648 Views
Last Modified: 2014-08-01
I tried to install the phpMyAdmin package on a Debian Linux 6 server (via apt-get).  When the package installed, it removed Apache and installed Apache2.  Now, when I try to browse to .cgi and .sql pages on the web server (the files are located in /home/www/), the source code is displayed instead of being executed.  What do I need to configure so that the code is executed instead of being displayed in the browser?

Other Information:
html files seem to work fine.
0
Comment
Question by:Matt Mrowicki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +3
13 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40202931
Make sure PHP is installed.  '.cgi' is usually Perl and '.sql' is usually SQL code that doesn't make any sense as a web page.
0
 

Author Comment

by:Matt Mrowicki
ID: 40202948
When I do a perl -v, I get a response that perl, v5.10.1 is installed.

This server has a bunch of .sql files.  They start with code like:

<! SQL connect localhost <database> <password> >
0
 

Author Comment

by:Matt Mrowicki
ID: 40202962
When I do php --version, I get PHP 5.3.3-7+squeeze19...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Matt Mrowicki
ID: 40202967
php is also working ok.  I get the expected results from phpinfo( ).
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 40203060
But do you see phpinfo() in you web browser when you try to access it thru Apache?  Is phpMyAdmin working?

I don't know what those SQL files are for.  Nothing on my systems would run those.
0
 

Author Comment

by:Matt Mrowicki
ID: 40203097
Yes, phpinfo() works fine in the browser.

It looks the .sql files are MySQL code.  In the original Apache setup, I found the following in httpd.conf.

# Add the handler for www-mysql
AddHandler www-sql .sql
Action www-sql /cgi-bin/www-mysql

I think if I could get this to work with Apache2, I'd be set.
0
 
LVL 11

Expert Comment

by:Radek Baranowski
ID: 40203102
do you browse to localhost/... or rather /apache_root/htdocs etc. ??
is your apache started at all?

please post a screenshot
0
 

Author Comment

by:Matt Mrowicki
ID: 40203134
I'm actually browsing from another PC on the network via IP address.

If I browse to:
http://10.10.100.252/admin/sessions.sql

I get a 404 page:
Not Found
The requested URL /cgi-bin/www-mysql/admin/sessions.sql was not found on this server.
Apache/2.2.16 (Debian) Server at 10.10.100.252 Port 80
0
 
LVL 58

Accepted Solution

by:
Gary earned 1500 total points
ID: 40203176
Sounds like CGI is not set up in the httpd.conf

Sample of what should be there can be found here
http://www.experts-exchange.com/Q_24253113.html
0
 
LVL 62

Expert Comment

by:gheist
ID: 40203785
is cgi-bin a ScriptAlias?
Is script www-mysql exiting without import errors when ran from command line?
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 40204484
Are you saying that both .cgi and .sql files are displaying the source code rather than being executed?  Or are .cgi files executing correctly but not .sql files?

What is the actual path to sessions.sql?

Did you restart apache after adding:
# Add the handler for www-mysql
AddHandler www-sql .sql
Action www-sql /cgi-bin/www-mysql
0
 
LVL 62

Expert Comment

by:gheist
ID: 40205180
restart apache is
# apachectl graceful
0
 

Author Closing Comment

by:Matt Mrowicki
ID: 40234991
The issue has been resolved.  The problem was the configuration in httpd.conf.  What made it tricky is that when the initial Apache installation was done (before the update to Apache2), some defaults were not the same as used in Apache2.  Once the file was edited with the correct info, everything worked properly.  Thank you for all of the assistance!
0

Featured Post

Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Fine Tune your automatic Updates for Ubuntu / Debian
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question