LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-08-2004, 08:11 PM   #1
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Rep: Reputation: 0
Hello all, an introduction and a question on .php


First I would like to extend my thanks to this forum and the people that frequent here. Over the past week, I've referenced this site numerous times as I worked my way through the initial setup and configurations. It's been frustrating at times, but I'm happy to say I'm excited at being a new Linux user!

A few months ago I took an old computer and started up a small webserver. What originally began as a small interest has turned into an avid hobby of mine, consuming much of my spare time (and some of my "not so" spare time). Since creating my dyndns.org account, I have installed Apache 2.0, Movable Type's weblog, Perl, PHP, and a phpbb2 board running on a MySQL4 database. This poor 450mhz P2 Windows ME machine has been running breathlessly for quite some time now.

With some gift certificates I had to Gateway, I purchased their 920 Server (tinyurl.com/ywkyq) with SUSE Standard Server 8 bundled. My goal is to get everything from my current server switched over to the new Linux machine.

I've done my best to solve most issues, but just can't figure out some. I would like to get these worked out over the next few weeks.

One of them is a problem getting my .php pages to work. The browser tries to download the .php file. If I change the extension to .php3, it will load the page but only show the code.

I followed the instructions in this thread (tinyurl.com/ysvmu), but couldn't resolve the issue. It's possible I'm not applying it correctly. In another thread (tinyurl.com/2we9n), I tried using the ApacheToolbox but got an error "checking for autoconf" and "...gcc" failed when running ./install.sh/

I also tried to upgrade to 2.0 from 1.3 to see if that would help, but couldn't get the program to compile. I read an article saying 1.3 should work fine and stopped there.

What information can I provide to help solve this problem? I can put my httpd.conf file up on my server if that helps.

Well, that should cover everything, I've been so excited working with this I couldn't stop writing. Thanks for taking the time to read everything, I appreciate any assistance you can give me.

Stephen Hosterman
 
Old 01-09-2004, 06:36 AM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Hello Stephen,
glad to have you here and it sounds like your new hobby entitles you to a free propellerhead hat. You are becoming a geek, that's what's happening.

Now, on to your problem.
Quote:
One of them is a problem getting my .php pages to work. The browser tries to download the .php file. If I change the extension to .php3, it will load the page but only show the code.
This sounds as if Apache doesn't recognize the .php file extension.

Make sure you load the php4 module in httpd.conf (the Apache config file, usually in /etc/apache/conf or /etc/httpd/conf):
Code:
LoadModule php4_module libexec/libphp4.so
In the AddModule part of httpd.conf, you need this:
Code:
AddModule mod_php4.c
You also need to tell Apache which file extensions should be parsed by PHP - .php files of course, plus any others that you may want:
Code:
AddType application/x-httpd-php .php .phtml
Save your httpd.conf and exit the editor. Now restart Apache - apachectl restart. If there are any error messages pay attention to them and if there are any instructions you should follow them.

You can use apache -t to verify that the syntax in your configuration file is correct.

One thing that can be really helpful determining problems is using a phpinfo page. Create a file called phpinfo.php in your DocumentRoot (the webserver's root directory) and enter the following code in it:
Code:
<?php
    phpinfo();
?>
Try accessing that file with your web browser. If PHP works and is parsed and sent to the browser correctly you should get a page displaying information about your PHP and web server environment. If it doesn't work, well then you will get that ol'd "Save as" box in your browser again.

If you still are having problems post the relevant parts of your httpd.conf file and make sure you're editing the config file that is actually used (in case you have more than one)!


Håkan
 
Old 01-09-2004, 12:26 PM   #3
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for the suggestions. I tried what you said but had no success.

Here is where I added the code...
(I made notes to myself for reference)
Code:
....
LoadModule usertrack_module   /usr/lib/apache/mod_usertrack.so
LoadModule unique_id_module   /usr/lib/apache/mod_unique_id.so
LoadModule setenvif_module    /usr/lib/apache/mod_setenvif.so

#following 1 lines added by Steve (Jan 8, 2004)
LoadModule php4_module        /usr/lib/apache/libphp4.so

<IfDefine DUMMYSSL>
LoadModule ssl_module         /usr/lib/apache/libssl.so
</IfDefine>

Include /etc/httpd/suse_loadmodule.conf

....
And again here...
(I wasn't sure where to add the AddType line)
Code:
....
AddModule mod_so.c
AddModule mod_setenvif.c

#following 2 lines added by Steve (Jan 8, 2004)
AddModule mod_php4.c
AddType application/x-httpd-php .php

<IfDefine DUMMYSSL>
AddModule mod_ssl.c
</IfDefine>
....
Additionally, I found this code in the .conf file that I thought might be related.
Code:
<IfModule mod_mime.c>
....
....
    #
    # PHP 3.x:
    #
    <IfModule mod_php3.c>
    AddType application/x-httpd-php3 .php3
    AddType application/x-httpd-php3-source .phps
    AddType application/x-httpd-php3 .phtml
    </IfModule>

    #
    # PHP 4.x:
    #
    <IfModule mod_php4.c>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .php4
    AddType application/x-httpd-php-source .phps
    </IfModule>
....
I created a testphp.php file and another "Hello World" test.php file. Both times the browser tried to download the file.

I also looked for any other .conf files in case I was editing the wrong one, but couldn't locate any. Is there a command to find out the location of the current .conf file being used? Also the apache -t command didn't work. (bash: apache: command not found)

I did find a httpd.conf.SuSEconfig file though, which seems to contain everything the httpd.conf file does. I added the lines there also and restarted but no success.

Here are my files if you want to see the whole thing. (Won't let me post URL's yet)
(httpd.conf) shosterman.dyndns.org/errors/httpd.conf
(httpd.conf.SuSEconfig) shosterman.dyndns.org/errors/httpd.conf.SuSEconfig


Stephen

Last edited by shosterman; 01-09-2004 at 12:28 PM.
 
Old 01-09-2004, 05:21 PM   #4
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
The apache binary might not be called "apache", it might be called "apache2" or "httpd". Try /usr/sbin/apache2 -t or /usr/sbin/httpd -t instead. As for the config file, I'll leave that until tomorrow. It's time for me to hit bed and it's quite lengthy.
Just a quick thought - did you verify that the module libphp4.so in /usr/lib/apache ?


Håkan
 
Old 01-10-2004, 12:44 PM   #5
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Just a quick thought - did you verify that the module libphp4.so in /usr/lib/apache ?
Yes, I did a search for that file and it came up in that folder.

Thanks for taking the time to look through the file. For the record, I wasn't implying that I wanted you to read through the whole thing , but I wanted it to be available in case you were looking for something specific.

Last edited by shosterman; 01-10-2004 at 12:45 PM.
 
Old 01-10-2004, 03:05 PM   #6
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
I'm no SuSE wiz but there is one interesting Include statement in your httpd.conf - on line 330 it says "Include /etc/httpd/suse_addmodule.conf". I think there's where you should start looking. Also check /etc/httpd/suse_include.conf which is referenced from the last line of httpd.conf.

I just recently started toying around with Gentoo, and coming from Debian it's quite a shock. They have all sorts of non-standard configuration files, but I guess in the end when you're used to it it's much easier. But starting out it's quite confusing.

SuSE also seems to have an /etc/apache2/conf.d directory (like Gentoo), where some extra configuration files are stored, like mod_php4.conf.

There is a SuSE apache2 FAQ as well. It might be worth checking out.


Håkan
 
Old 01-12-2004, 02:55 PM   #7
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Original Poster
Rep: Reputation: 0
Well, here's an update on what I've got installed so far.

This has been a very frustrating process, especially trying to get this PHP working and not seeming to get anywhere. I figured I would give the apache2 install another try.

I first downloaded the Unix source from Apache.org and gzipped and tarred (however it's said) the file and then moved into the directory. I was having a problem with the $./configure --prefix=/usr/local/apache2 command working. It would start a few lines then come up with a error: no C compiler in $PATH. I did another search for this error and it said something about gcc not being installed, so I went to my install and did a search for gcc. Sure enough, I checked that box and reran the command and voila it worked! I bet it would have been beneficial if I had stated this error earlier.

After that, I tried the $ make command and nothing happened. So again I searched for it and installed it. Once installed I ran $ make and then $ make install which took just a couple minutes to finish.

Finally, I started the server and browsed to localhost. It still says "Apache/1.3.26" at the bottom, how should I go about getting rid of this version and using 2.0? Do I want to remove it through YasT2? Will that remove any shared files or cause problems?

Steve
 
Old 01-12-2004, 03:40 PM   #8
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Let us stop for a while and make a few things clear:

1. You have one version of Apache installed from the distribution and you're building another one from source, is this correct? If so, what version are you building and what version did you install directly from the distribution?

2. If you build and install Apache or Apache2 from source the default installation directory is /usr/local/apache (or (...)/apache2 if you're going with Apache2). It shouldn't interfere with the version that shipped with your distribution. You will find the apachectl program (to manually stop and start the web server) and other important executables (like the server itself) in /usr/local/apache2/bin. Config files for the local build should be in /usr/local/apache2/conf. If you're starting Apache with /usr/local/apache2/bin/apachectl start then those are the files you need to edit.


Håkan
 
Old 01-12-2004, 06:35 PM   #9
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Original Poster
Rep: Reputation: 0
Here is what is installed when I did a search for "apache" in YaST2:
apache 1.3.26-57
mod_perl 1.27-50
mod_python 12.7.8-98
mod_ssl 2.8.10-57

The one I downloaded was httpd-2.0.48.tar.gz. I built and compiled that one during my last step.

To answer your first question, yes, I am trying to install the 2.0.48 from source with the intent of upgrading from 1.3.26-57 to the 2.0.48. I guess maybe I'm used to Windows installs and assumed it would do the upgrade.

Concerning your second statement, I see that there are two apachectl programs. The one you're referring to is in "/usr/local/apache2/bin", but there is also another one in "/usr/sbin/".

When I run the command apachectl start, the return is "/usr/sbin/apachectl start: httpd started". This is even if I run it out of the apache2/bin directory. I guess it's running that program and I don't know how to change it...if it's a problem. I'm guessing the command is embedded somewhere, but I don't know where to begin to look.

Now even after starting and I do a apachectl restart, I get
"/usr/sbin/apachectl restart: httpd not running, trying to start"
"/usr/sbin/apachectl restart: httpd started"

I also tried removing the apache that came installed with the distribution and then running apachectl start, but no luck and I forgot to write down the error message.


Steve
 
Old 01-13-2004, 04:32 AM   #10
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
About starting Apache when a distribution-supplied version of Apache is already installed:
/usr/sbin is in your path when you're root, but /usr/local/apache2/bin isn't, that's why the apachectl in /usr/sbin is executed when you type the command. However, if you supply the full path to /usr/local/apache2/bin/apachectl (<--- that's what you type, or cd to (...)apache2/bin and type ./apachectl) you tell the shell that this is the program I want to run and no other program by the same name. You should pass arguments to the program as usual (append the "restart" or whatever commands).

To view what directories are in your path type echo $PATH. The $PATH environment variable is a colon-separated list that lists the directories that will be searched when looking for executables. There are several discussions on this forum about configuring the $PATH variable so I won't try to cover that here. We're doing pretty well writing lengthy posts anyway.

You don't really need to remove the distribution version of Apache (it's probably more trouble than you or I need ) as long as you're aware of the difference between the one you have built (where its config files are located, what modules that are installed for it, and so on) and the one that shipped with your distribution.


Håkan
 
Old 01-13-2004, 05:40 PM   #11
shosterman
LQ Newbie
 
Registered: Jan 2004
Location: Columbus, OH
Posts: 19

Original Poster
Rep: Reputation: 0
WOOHOO!!

Sorry, I couldn't help myself!

My PHP code runs, the board works, I just need to do some file swapping now! Well that ./ command makes sense now, I was confused how to run a file from a specific directory.

According to your guidelines heres how I finished it up.

I downloaded the newest source code of PHP4.3.4 from php.net and unzipped that. Then using this page as a reference, I ran the following code:
(I'm not sure what all of it does)
Code:
./configure \
	--with-apxs2=/usr/local/apache/bin/apxs \
	--with-mysql \
	--prefix=/usr/local/apache/php \
	--with-config-file-path=/usr/local/apache/php \
	--enable-force-cgi-redirect \
	--disable-cgi \
	--with-zlib \
	--with-gettext \
	--with-gdbm
The problem was that I kept getting errors trying to run that code, so I just did a basic compile of:
Code:
./configure --prefix=
I then did make and then make install. Apache loaded fine but the libphp4.so file was nowhere to be found. Assuming I left something out of the compile I went back to the original code. It's then I realized I needed to install the gdbm-devel and the zlib-devel packages.

So I compiled again and tried make, but was getting some errors. After a bit with google I found I needed to run make clean. I guess to clear my previous install? Everything installed fine afterwards.



Do you foresee any problems I might have after running that configure code more than once or doing the make install more than once? I'll leave the 1.3 on there like you said to save myself (or you) from any further hassle.

I guess my last question is how can I change it so when I type apachectl Linux will know to use the new apache2 version? I would have to get rid of or rename the old one and move the new one to my /usr/sbin directory, correct? Although it's not terribly important now that everything is running.

Well, looks like I've already made this long enough. I want to say thanks again for all your help, I can't tell you how many days or weeks this would have taken me otherwise.

Thanks,
Stephen
 
Old 01-13-2004, 07:18 PM   #12
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Glad to hear it's working now!

Here is one way of making the locally built apachectl command get executed instead of the old one from the distribution: First cd to /usr/sbin and rename apachectl to something sane - mv apachectl apachectl_distro. Then simply create a link called "apachectl" in the /usr/sbin directory pointing to your own apachectl: ln -s /usr/apache2/bin/apachectl /usr/sbin/apachectl.

Running the configure script several times won't hurt a bit. It creates the Makefile(s) used by make to build the program, and running make install will only over-write the files you installed while doing the same thing the last time.

You should also look into how your distribution uses boot scripts in order to have Apache start automatically on boot. You can often (I'm not saying this will work with SuSE) link to apachectl from the /etc/rc.<runlevel> directories for the runlevels that you want Apache to run at.


Håkan
 
  


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
Introduction Surfrider LinuxQuestions.org Member Intro 4 08-03-2005 05:36 PM
Introduction wlksms LinuxQuestions.org Member Intro 2 07-01-2005 03:58 PM
Introduction rightcoast LinuxQuestions.org Member Intro 2 11-09-2004 06:36 PM
My Introduction and a UT2003 question golgotha64 Slackware 9 02-22-2004 12:46 AM
Introduction riel Conectiva 10 09-25-2002 08:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:25 AM.

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