LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-02-2008, 11:40 AM   #1
luco.vico
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Rep: Reputation: 0
Slackware 12 - Apache 2.2.8 and PHP 5.2.5


Hello, everyone!

I may have made a boo-boo and I thought this would be the best place to find out what to do.

- installed full slackware 12 distro
- installed apache 2.2.8 and php 5.2.5 as per these articles:
http://cowbox.coe.uky.edu/stu/linux/apache/
http://cowbox.coe.uky.edu/stu/linux/apache/php.php

So I have the /home/httpd/ directory where there are a number of folders. One is /conf/ where I was modifying the httpd.conf file. There was also a /var/www/ directory where the websites seem to go. Apache seems to work (I get the 'It Works!' page when I got to http://localhost/). PHP doesn't work. I just get a directory listing and when I click on any .php file, firefox displays its contents.

I was searching online for solutions and the more things I found the more confused I became.

First, in the /home/httpd/conf/ folder there is 'original' folder with another httpd.conf file? My guess is that it is a 'backup'.

One of the websites was talking about checking some things in the /etc/apache2/ directory. I don't have one. Also, my /etc/php/ directory is empty and I also have an /etc/httpd/ directory with its own httpd.conf, php.ini, and an 'original' folder again with httpd.conf (and other stuff too).

Then I read on one site that Slackware already comes with Apache. This is where I decided to turn to forums. What should be the next step? Are there some conflicts? Should I try to uninstall the Apache and PHP that I did using the 'cowboy' site? If so, how do it do it, since I did not use installpkg after compiling the source code?

Thank you for your time and help!

Vico
 
Old 03-03-2008, 01:14 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
As far as I know there is one thing that you need to change to get PHP working. You have to tell apache to parse php files.

You can do that in /etc/httpd/httpd.conf
Code:
# Uncomment the following line to enable PHP:
#
Include /etc/httpd/mod_php.conf

And this is part of mod_php.conf (as far as I know. it's the default settings)
Code:
#
# mod_php - PHP Hypertext Preprocessor module
#

# Load the PHP module:
LoadModule php5_module lib/httpd/modules/libphp5.so

# Tell Apache to feed all *.php files through PHP.  If you'd like to
# parse PHP embedded in files with different extensions, comment out
# this line and see the example below.
AddType application/x-httpd-php .php
Please note that the above applies to a standard Slackware 12 (with LAMP) installation; you might have changed some stuff by installing a newer apache in which case locations and filenames might have changed.
 
Old 03-03-2008, 01:51 AM   #3
gani
Member
 
Registered: Jun 2004
Location: Metro Manila, Philippines
Distribution: Linuxmint, Slackware
Posts: 356

Rep: Reputation: 34
If you strictly followed that tutorial, it says there that your install --prefix is /home/httpd. Therefore all of apache's pertinent files were installed by "make install" in /home/httpd including etc that contains your httpd.conf and other configuration files.

Also don't forget to tell apache to be able to recognize .php extension besides .html.

Code:
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>
-----
GANI
 
Old 03-03-2008, 02:17 AM   #4
daikamisama
LQ Newbie
 
Registered: Mar 2008
Posts: 2

Rep: Reputation: 0
Hi Vico

I'm not an expert but may can help you with this issue. First, your "default" installation directory for apache is "/home/httpd" because you compiled with "./configure --prefix=/home/httpd --enable-module=so" it tells apache(with the --prefix) that it has to be installed in that directory (/home/httpd). As you said it seems to be working fine so what I think is that you need to "enable" the php module, that way apache will know what to do with php files.

1)Double check that your http.conf file (/home/httpd/conf/httpd.conf) has this line otherwise add it:
Code:
LoadModule php5_module modules/libphp5.so
2)Now you have to add another line to this httpd.conf file so that Apache invokes PHP parser whenever a file with extension php (.php) is accessed. When PHP parser is invoked by Apache it reads .php file which contains PHP code blocks, html tags and other text. Parser then executes PHP code found inside <?php and ?> blocks and then merges PHP code results and other html content (as is). Resulting output is then sent back to Apache which in turn sends it to web browser which requested the file.

The line to be added is:
Code:
AddType application/x-httpd-php .php
To add this line search for word AddType in httpd.conf file. There will be a line like this:
Code:
"AddType application/x-tar .tgz"
Below this line add (on a new line):
Code:
AddType application/x-httpd-php .php
3)Also double check
Code:
DirectoryIndex index.html index.php
4)After that in root mode type (It works in debian but give it a try):
Code:
a2enmod php5
5)Finally:
Code:
/home/httpd/bin/apachectl restart
Anyways I used to follow this instructions:
http://www.web-tech-india.com/articl...ng_php_apache/

Keep in mind that they use "--prefix=/wwwroot/" and you "--prefix=/home/httpd" otherwise that should help you.

As you said, it may be possible that you have a previous installation of apache, you can figure it out like this:
1)First stop your(compiled) apache server:
Code:
/home/httpd/bin/apachectl stop
2)Try to load a web page on your server, if you see the default page then you have another web server running. If not then you can start your (compiled) apache server:
Code:
/home/httpd/bin/apachectl start
Good Luck!
 
Old 03-03-2008, 10:24 AM   #5
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
@daikamisama
He will never be able to have two webservers running at the same time (unless on different ports). So I doubt very much that above test adds anything (no offence intended).

I don't have Slack12 available at the moment (only at work), but from my memory:
check for a file rc.httpd (in /etc/rc.d).
Simply setting the permissions to 755 makes apache start at bootup. I will try to remember to verify tomorrow.

Last edited by Wim Sturkenboom; 03-03-2008 at 10:27 AM.
 
Old 03-03-2008, 06:07 PM   #6
luco.vico
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Hello, everyone!

Thank you for you help and contributions! The 'breaker' was

Code:
/home/httpd/bin/apachectl restart
I was stopping/starting apache with

Code:
apachectl _______
That was affecting the pre-installed apache server, I am guessing. Yesterday I changed /etc/rc.d/rc.httpd to executable. When I booted up my machine and ran

Code:
/home/httpd/bin/apachectl restart
it gave me an error message about the port being used up and what-not. So I stopped the default server and started the one I installed yesterday. And it works now!! I guess I do not need the /var/www/ directory any more if I use the newly installed Apache/PHP?

I will ask for your opinion here: would you recommend getting rid of the Apache that came with Slackware or should I get rid of the one that I installed yesterday?

I checked the version of php that came with slackware (should have done this before-hand) and it is the same as the one that I installed. If I were to get rid of the one I installed yesterday, how would I do that in slackware 12 considering that I never made a package out of it? Or is this a question more suitable for the Slackware forum?

Thanks everyone!

Vico
 
Old 03-03-2008, 06:30 PM   #7
Lantzvillian
Member
 
Registered: Oct 2007
Location: BC, Canada
Distribution: Fedora, Debian
Posts: 210

Rep: Reputation: 41
Also, another way is Virtual Host, if you are using DNS and if you own a domain. With them you can put the directories of the website you want to be seen.

For example:

<VirtualHost *>
ServerAdmin brashr@orangespike.ca
DocumentRoot /usr/local/apache2/htdocs/webDirectoryHere/
ServerName site1.orangespike.ca
DirectoryIndex index.php
AcceptPathInfo on
</VirtualHost>

Now your firewall might now allow traffic incoming, but if you allow DNS, these do work on the internal network with full qualified domain names, using a service such as http://zoneedit.com

Now I don't think that solves your problem, but it does provide an alternative.
 
Old 03-03-2008, 09:25 PM   #8
luco.vico
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Sorry to be bugging you with all the questions.

I have php.ini in /usr/local/lib/ and in /etc/httpd/ - the one that is affecting the way php behaves is the former one. There are also other configuration files, including httpd.conf in /etc/httpd/ that I do not seem to need to modify in order to affect the way apache or php runs. Seeing that /etc/ directory contains all the configuration files for the system, do files in /etc/httpd/ actually have any affect on my apache and php? Or do they serve as a starting point/reference/backup and the actual files that affect apache and php reside elsewhere (like /usr/local/lib/ for php.ini and /home/httpd/conf/ for httpd.conf in my case)?

Your thoughts? Ideas?

Thanks a lot in advance!

Vico
 
Old 03-04-2008, 02:17 AM   #9
Lantzvillian
Member
 
Registered: Oct 2007
Location: BC, Canada
Distribution: Fedora, Debian
Posts: 210

Rep: Reputation: 41
This here might help you. I did this awhile back http://www.orangespike.ca/?q=node/35 its using compiling, but the conf stuff might be good for you. Feel free to look at some of my other documentation. There is bits of apache stuff everywhere

To answer your question abotu what affects what. I believe somewhere apache includes the other php.ini somewhere and I think one takes presidence over the other. As for what you edit, those are pretty much the money makers. They are the head haunchos pretty much.

There can be files to edit in some random place ( its Linux after all ), but most of what you run into is located in those directories where those two confs are located.
 
Old 03-05-2008, 07:50 AM   #10
luco.vico
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Thank you very much!

I'll take a deeper look into it!

Cheers!

Vico
 
Old 03-05-2008, 12:34 PM   #11
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
In the original Slackware setup, the files in /etc/httpd definitely have a purpose as those files configure apache etc.

As it's very unclear to me what you are using at this stage (the new or the opriginal stuff), I can not be very specific.
One thing that might make you think that changing one of those does not effect apache is that you need to restart apache for the changes to take effect.
 
Old 03-08-2008, 12:11 PM   #12
luco.vico
LQ Newbie
 
Registered: Feb 2008
Posts: 14

Original Poster
Rep: Reputation: 0
I think I have 2 apache servers installed right now - the original and the one I compiled/installed. The latter was made with in /home/httpd/ .
Code:
apachectl restart
affects the original installation while
Code:
/home/httpd/bin/apachectl restart
affects the one I did. And of course there are configuration files for both servers and both look in different directories for 'websites'. Things seem to be working for now as long as I run the apache that that installed (as its config files were changed to run php). So I think I'll just stick with having two servers and just not start the original.

Thank you all for your contributions and help!

Vico
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Slackware 10.2, apache and php jmille34 Slackware 1 08-18-2006 01:49 PM
Apache with PHP in Slackware 9.0 traveldanimal Slackware 3 09-28-2004 12:41 PM
slackware, apache and PHP from .tgz - problems with PHP szymon Slackware 2 09-06-2004 04:57 PM
Apache/PHP Help on Slackware wenberg Linux - Software 7 01-03-2004 10:04 PM
php and apache and slackware 9 joel112 Linux - Software 4 07-10-2003 12:44 PM

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

All times are GMT -5. The time now is 10:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration