-   Linux - Server (
-   -   Slackware 12 - Apache 2.2.8 and PHP 5.2.5 (

luco.vico 03-02-2008 11:40 AM

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:

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!


Wim Sturkenboom 03-03-2008 01:14 AM

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

# 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)

# mod_php - PHP Hypertext Preprocessor module

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

# 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.

gani 03-03-2008 01:51 AM

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.


# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php


daikamisama 03-03-2008 02:17 AM

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:

LoadModule php5_module modules/
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:

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:

"AddType application/x-tar .tgz"
Below this line add (on a new line):

AddType application/x-httpd-php .php
3)Also double check

DirectoryIndex index.html index.php
4)After that in root mode type (It works in debian but give it a try):

a2enmod php5

/home/httpd/bin/apachectl restart
Anyways I used to follow this instructions:

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:

/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:

/home/httpd/bin/apachectl start
Good Luck!

Wim Sturkenboom 03-03-2008 10:24 AM

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.

luco.vico 03-03-2008 06:07 PM

Hello, everyone!

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


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


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


/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!


Lantzvillian 03-03-2008 06:30 PM

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 *>
DocumentRoot /usr/local/apache2/htdocs/webDirectoryHere/
DirectoryIndex index.php
AcceptPathInfo on

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

Now I don't think that solves your problem, but it does provide an alternative.

luco.vico 03-03-2008 09:25 PM

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!


Lantzvillian 03-04-2008 02:17 AM

This here might help you. I did this awhile back 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.

luco.vico 03-05-2008 07:50 AM

Thank you very much!

I'll take a deeper look into it!



Wim Sturkenboom 03-05-2008 12:34 PM

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.

luco.vico 03-08-2008 12:11 PM

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/ .

apachectl restart
affects the original installation while

/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!


All times are GMT -5. The time now is 08:27 PM.