Apache 2 and PHP

Discussion in 'HOWTO-Related Questions' started by kingtech, Oct 25, 2006.

  1. kingtech

    kingtech New Member

    I have been beating my head against the wall for 12 hours, I can't figure out how I screwed up the php in my Apache2.... PHP4 and Apache2 are installed, using the perfect setup for debian - see page 5 (http://www.howtoforge.com/perfect_setup_debian_sarge_p5)

    The problem is, apache does not seem to recognize the php file as something it needs to process, it just tries to send the php file directly to the browser.

    I had PHP5 installed and removed it, installed PHP4 using above method... there was nothing in the /etc/apache2/mods-available/ as far as php4.load or php4.conf, but the files php5.load and php5.conf were there, i cp'd them to php4.conf & .load and changed the content so they said 4 instead of 5... then made a sym link from mods-avail to mods-enabled for them and restarted apache2 .... nothing....

    how would I completely remove all traces of apache, apache2, php4, php5 and do a clean install without redoing the whole box? it is like 50 miles away from me and is being used as a company fileserver (samba) and I was going to create an intranet for them, but just cant get php to work right...

    it is running debian sarge, also with postfix/courier, pretty much exactly the way the perfect setup lays it out, but I installed this box a long time before I ever read these tutorials...
  2. kingtech

    kingtech New Member

    what i mean by clean install is remove all traces of the previous installs, as apt-get remove leaves behind a lot of things...

    My logic is: If I could successfully remove it all, then when I do the perfect install (p5) it should work correctly..?
  3. kingtech

    kingtech New Member

    Well I really screwed up.

    I did apt-get --purge remove on everything I could think of, and still had issues, so I went and rm /usr/sbin/apache* as well as php and exim

    I mistakenly thought that this would erase the installations... WRONG. it just made damn sure good that I could never reinstall any of those. well actually, apt-get --reinstall install actually did appear to reinstall apache, but it was still missing some vital pieces.

    I guess what I really was trying to do was to clear the installs and configs and the apt cache so that it would all reinstall smoothly using the tutorial here, but now I just have a screwed up box. The samba is still running on it at least.

    anyone have any suggestions?
  4. Ben

    Ben ISPConfig Developer ISPConfig Developer

    Can you just install apache* and php4 or 5 (don't know what's in the howto, but I would just install apache2, e.g. and mod_php4 or 5, the dependencies should come bye it own).
    Then you could upload the httpd.conf + the include confs of php...
  5. kingtech

    kingtech New Member

    server:~# apt-get --reinstall install apache2
    Reading Package Lists... Done
    Building Dependency Tree... Done
    0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
    Need to get 33.5kB of archives.
    After unpacking 0B of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 ftp://mirrors.usc.edu stable/main apache2 2.0.54-5sarge1 [33.5kB]
    Fetched 33.5kB in 2s (14.8kB/s)
    (Reading database ... 42855 files and directories currently installed.)
    Preparing to replace apache2 2.0.54-5sarge1 (using .../apache2_2.0.54-5sarge1_i386.deb) ...
    Unpacking replacement apache2 ...
    Setting up apache2 (2.0.54-5sarge1) ...
    server:~# /etc/init.d/apache2 restart
    -bash: /etc/init.d/apache2: No such file or directory
    ummmn... nope...
  6. kingtech

    kingtech New Member

    here was the fix:

    apt-get --purge remove apache2-common
    apt-get --reinstall install apache2 apache2-common apache2-doc apache2-mpm-worker apache2-utils libapr0 ssl-cert
    i just went step by step through the perfect install... it errored out a few times saying it was trying to remove files that were not there, so I just touched them and then repeated it till it worked.

  7. kingtech

    kingtech New Member

    well guess what?

    I have reinstalled apache2 and all the modules and components, but once again, apache wants to send me the php file rather than interpret it.

  8. kingtech

    kingtech New Member

    well I figured it out... somehow I still had php5 installed...

    my main problem was I had no idea how to see what packages were installed...

    if you want to see them, try this:

    apt-get install apt-show-versions


    apt-show-versions | sort

    will give you a nice list of installed packages...

    best way to remove all traces of them is

    apt-get --purge remove packagename

    (I got fancy and did apt-get --purge remove php5* which removed all of em)
  9. R0l@ndSm0ke

    [email protected] New Member

    Does anyone know what the SuSE versions of these commands would be? I'm having the same problem as this fella with PHP5 and Apache2 on OpenSuSE 10.2 per the Perfect OpenSuSE 10.2 setup.
  10. falko

    falko Super Moderator ISPConfig Developer

    On SuSE you can use
    to do all this.
  11. gps4213

    gps4213 New Member

    PHP just transfering scripts not parsing them.

    First off, I am posting here as it is the most relavent thread I have been able to find for the problem at hand.

    Second, OMG!!! Wonderful site with more version specific information than any other site that I have found, and I have been searching for a site like this for almost a month.

    Third, Per the above quote, only 12 hrs? I have a new wall installed in my computer room due to the loss of sheetrock from hands, feet, and heads going through it for the last almost month now! I have gone from mild anger to outright rage in my attempt to get php to parse on my personal server with no luck. Perl and CGI run like a champ but php is sent like a file transfer. :confused:

    I hope you don't mind the short story here but it does come with a point.

    I started with Mandrake 9.2, (The distro I found to be most usefull and "want to escape windows" friendly.) a few years ago and eased my self into linux. I still love my games so VirusXP is still on my main box. :eek:

    Last month I found the need to setup a forum for an online game. After doing a bit of checking arround I found a wonderful script in php. "OK" I said to myself, "never ran php before. Time to learn something new." That is when the problem started...

    I have since that time gone thru 4 distros of mandrake/iva, 9.2 10.2 2005 2007 all with this same problem. I even tried compiling my own server from binaries. No luck. So I scouered the FAQ's for PHP and Apache only to find a single reference to this problem.

    QUOTE from PHP.NET FAQ "I have followed all the steps to install the Apache module version on Unix, and my PHP scripts show up in my browser or I am being asked to save the file."

    With this as the first solution

    "Make sure that the httpd binary you are running is the actual new httpd binary you just built. To do this, try running: /path/to/binary/httpd -l

    If you don't see mod_php4.c listed then you are not running the right binary. Find and install the correct binary. "

    No mater how I have tried to build apache(1.3/2.2) with PHP(4/5) I could not get this to show as stated above or get php scripts to do anything besides be downloadable objects.

    Then I found your site with the "Perfect install Mandriva 2007"
    :D YAY :D I am saved!


    Now 3 installs later and even making a shell script to run the show so I can't screw anything up, cut and paste directly from the howto, I still have the same problem. There is only one one httpd binary on the computer /usr/sbin/httpd and with the -l option I always get;

    Compiled in modules

  12. till

    till Super Moderator Staff Member ISPConfig Developer

    If you installed your server according to the perfect setup guide, the PHP module is lodaed (dynamically) and dont show up when you execute httpd -l even if its installed and available.

    Did you install ISPCOnfig too, if not you will have to undo the part described under "13.1 Disable PHP Globally" to run php scripts.
  13. gps4213

    gps4213 New Member

    No, I didn't install ISPConfig as this is for a single user/single site setup.

    I don't get it. Do I need to add something to the appache.conf for the cgi-bin so they work? Current rules look like this;

    <?Directory "/var/www/cgi-bin">
    AllowOverride All
    Options ExecCGI
    Order allow,deny
    Allow from all

    Do I need to add something to the options line that I have overlooked somewhere by chance?

    Thank you for your help on this.
  14. falko

    falko Super Moderator ISPConfig Developer

    If you use the "Perfect Setup" for Mandriva 2007, but don't want to install ISPConfig, then do everything from the tutorial except chapter 13.1! So if you have finished your setup, just undo everything from chapter 13.1.
  15. gps4213

    gps4213 New Member

    I did it!!! I found a solution to my PHP woes! :D :D
    I hope this helps someone else in the future as well.

    After doing some extensive testing I oopsed and found out that php was indeed working just not in the cgi-bin dir. But it _was_ working in the html dir. Weird if ya ask me. So I did what I do best at that point, pout! Why the (censored) is it working in /var/www/html and not /var/www/cgi-bin!? !?! Back to searching the web for answers. And with a stroke of luck I found a page I had overlooked before. Low and behold there was an answer.

    Here is what I found. A few lines lacking in httpd.conf.
    LoadModule ....
    LoadModule php5_module extramodules/mod_php5.so
    AddHandler php5-script .php <-This
    Action php5-script /cgi-bin/php <-and this

    Once I added thease 2 lines and restarted httpd it worked like a charm. They were added as shown directly after all the LoadModule lines. Just to be sure encase there needs to be a distinction, this is working with Apache 2.2.3 and PHP 5.1.6 (and perl 5.8.8).

    PHP is still allowed to run under /var/www/http (Trying to turn this off :confused: ) but atleast now I have a solution that works to keep the .php scripts out of the regular .html directory.

    Thank you for your help and kind ears. Any additional onfo is still more than welcome.

    P.S. I think you should add a distinction after the end of 13.1 in the "Perfect Setup" for Mandriva 2007 , I originaly missed the end in my first reinstall and skiped the "Edit /etc/httpd/conf/httpd.conf and add the following line to the LoadModule section:" on page 5 and went to step number 14 on page 6.
  16. till

    till Super Moderator Staff Member ISPConfig Developer

    Thats not nescessary, because the perfect setup prepares your sytsem for the installation of ISPConfig. If you add these lines, ISPConfig wont function properly anymore as ISPConfig does all these configuartzions for you by enabling just one checkbox.

Share This Page