LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Slackware 12 - Apache 2.2.8 and PHP 5.2.5 (https://www.linuxquestions.org/questions/linux-server-73/slackware-12-apache-2-2-8-and-php-5-2-5-a-625155/)

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

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

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.

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

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

Wim Sturkenboom 03-03-2008 10:24 AM

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

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

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

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

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!

Vico

Lantzvillian 03-04-2008 02:17 AM

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.

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

Thank you very much!

I'll take a deeper look into it!

Cheers!

Vico

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


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