Apache and PHP5

DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
Hi,

I am runnign a webserver with Apache2 installed and have recently added in PHP5.

however a website I have set up using a virtual host will not correctly run the PHP code and when you go the www.sitename.com/index.php the file downloads rather than displays?

how can I see if Apache is loading the PHP module (it is in the mod-enbaled directory), and how can i insue PHP is enababled in the virtual host statment?

Cheers

Devil
  • If you can't explain it simply, you don't understand it well enough. Albert Einstein
  • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.

Comments

  • DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    [email protected]:/etc/apache2/sites-enabled$ more moodle 
    <VirtualHost 172.17.1.11:80>
    	ServerName moodle.domain.co.uk
    	ServerAdmin [email protected]
    	
    	DocumentRoot /var/www/moodle
    	<Directory /var/www/moodle/>
    		DirectoryIndex index.php
    		Options Indexes FollowSymLinks MultiViews
    		Options -Indexes	
      		AllowOverride FileInfo
    		Order allow,deny
    		allow from all
    
    	</Directory>
    
    
    	 # CGI Directory
    	 ScriptAlias /cgi-bin/ /var/****e/cgi-bin/
    	 <Location /cgi-bin>
                    Options +ExecCGI
            </Location>
    
    
    	ErrorLog /var/log/apache2/error.log
    
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel warn
    
    	CustomLog /var/log/apache2/access.log combined
    	ServerSignature On
    
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • NightShade03NightShade03 Member Posts: 1,383 ■■■■■■■□□□
    Here are a few troubleshooting steps for you:

    1) Make a test.php page and put it anywhere (doesn't have to be in your virtual host site). It should contain:

    <?php

    phpinfo();

    ?>

    Then navigate to the page and see if it shows you the details of your PHP install. If it doesn't then PHP isn't installed properly...if it shows then it isn't a PHP problem.

    2) Make sure that you have restart the webserver since you installed PHP (I'm sure you have just checking).

    3) Check the site with a different browser...I've seen some weird results with another browser working.

    4) Also check the errorlog right after apache has been restarted for any errors in loading modules.

    Let me know what you come up with.
  • DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    OK,

    answer to questions 1 and 2 are

    no it does not work (tried this yesturday) and yes I ahve carried out an "apache2 restart"

    3. No browsers work icon_sad.gif

    and as for 4.
    [Wed Sep 29 11:53:38 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 11:53:48 2010] [notice] Apache/2.2.8 (Ubuntu) mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
    [Wed Sep 29 12:28:32 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 12:28:42 2010] [notice] Apache/2.2.8 (Ubuntu) mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming normal operations
    [Wed Sep 29 12:33:36 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 12:33:46 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    [Wed Sep 29 12:39:48 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 12:43:49 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    [Wed Sep 29 14:39:45 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 14:39:55 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    [Wed Sep 29 14:55:30 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 14:55:40 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    [Wed Sep 29 14:59:55 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 15:00:05 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    [Wed Sep 29 15:00:33 2010] [notice] caught SIGWINCH, shutting down gracefully
    [Wed Sep 29 15:00:43 2010] [notice] Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.12 with Suhosin-Patch mod_perl/2.0.3 Perl/v5.8.8 configured -- resuming norma
    l operations
    
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • NightShade03NightShade03 Member Posts: 1,383 ■■■■■■■□□□
    If #1 didn't work (the test.php) then you don't have PHP installed correctly. Trying removing it completely and reinstalling. I noticed you have Ubuntu make sure that when you do apt-get remove you use the -purge option to remove any config files lying around.

    Then try to reinstall PHP from the repos and test the test.php page again. Make sure to restart apache before testing the page.
  • Forsaken_GAForsaken_GA Member Posts: 4,024
    check /etc/apache2/mods-enabled for both, php5.load and php5.conf (I'm going based off of a Debian install, but I believe Ubuntu handles it the same way). It's not enough to load the module itself, you also need the configuration directives to associate .php files to the php handler. If you copied the php5 files yourself to the mods-enabled directory, remove them and use a2enmod to properly enable them

    Most of the time when apache prompts you to download the .php file instead of parsing and rendering it, it means that A) your code is nasty and caused php to segfault B) apache has no clue what to do with the file. The default action in that case is to assume the user wants to download

    Judging by the log file parses you posted above from the restarts, you have the php5 module installed and loaded, you probably just don't have it associated
  • DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    If #1 didn't work (the test.php) then you don't have PHP installed correctly. Trying removing it completely and reinstalling. I noticed you have Ubuntu make sure that when you do apt-get remove you use the -purge option to remove any config files lying around.

    Then try to reinstall PHP from the repos and test the test.php page again. Make sure to restart apache before testing the page.

    Ahh in the end this seemed to be mutiply issues :) First PHP was not installed correctly as you suggested. So i removed it and re-added it (3rd or 4th time actualy). Now the info script worked but the site still would not load.

    Checking further It suggested I needed 5.2.8 and only 5.2.4 was installed. Although I am suprised this did not work.

    I finaly tried the current release version of Moodle (1.9 rather than 2.0) and it started to work find when I added index.php on to the end of the web address.

    I had also refreshed the source list as it was running with non unbunta sites (this distribution is based on unbuntu but has its own repositories as well.

    And finally it is all working. However I also noticed that when I go to the site through the work PC's the proxy server (thirds party controlled) has a nasty habit of caching the pages. so once it had failed to work the first time. any further attempts even once the site was up and working, I still did not see the page and the file tried to download.

    Is there any way to tell the proxy server not to cache a page? These can be activaly created pages so I don't want them cached!

    Cheers for all the help by the way.. with you suggestions finaly got there :)

    moodle.vlascientific.co.uk

    :)
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
  • Forsaken_GAForsaken_GA Member Posts: 4,024
    DevilWAH wrote: »
    Checking further It suggested I needed 5.2.8 and only 5.2.4 was installed. Although I am suprised this did not work.

    PHP5 is weird sometimes. I think it was around php 5.2.5 that they did some serious syntax changes and broke alot of software that hadn't been upgraded in awhile, much the same way that php5.3 breaks a boatload of php5.2 software. I'm actually surprised you had 5.2.4 on an Ubuntu box, as they usually stay pretty current with php, I believe 10.04 is pulling in php 5.3.2 these days
    Is there any way to tell the proxy server not to cache a page? These can be activaly created pages so I don't want them cached!

    If you're using squid, then yes. You create an acl that encases what you don't want to cache, and then add a cache deny <acl_name> to the configuration file
  • DevilWAHDevilWAH Member Posts: 2,997 ■■■■■■■■□□
    PHP5 is weird sometimes. I think it was around php 5.2.5 that they did some serious syntax changes and broke alot of software that hadn't been upgraded in awhile, much the same way that php5.3 breaks a boatload of php5.2 software. I'm actually surprised you had 5.2.4 on an Ubuntu box, as they usually stay pretty current with php, I believe 10.04 is pulling in php 5.3.2 these days

    This is a distribution based on the old hardy (version icon_cool.gif yer I know its old but I have it serving an old website and am just testing here. In a few days it will be on a 10.04 box.

    seems the Hardy Repository only goes up to 5.2.4, I could run a manual install I suppose but like I say this box is headed for the heap soon :)

    As for the proxys I know there blue coat but we have no control over them icon_sad.gif , they are controlled by government forces, yes they really are so will have to have words with the men in black....
    • If you can't explain it simply, you don't understand it well enough. Albert Einstein
    • An arrow can only be shot by pulling it backward. So when life is dragging you back with difficulties. It means that its going to launch you into something great. So just focus and keep aiming.
Sign In or Register to comment.