Intergrating Php with apache on Linux

  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 9th, 2006, 5:32 pm

Hi, I was wondering if someone could give me instructions on how to intergrate php with apache and maybe the manual would have an example. :D








Thx Programmers!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 9th, 2006, 5:32 pm

  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 9th, 2006, 7:14 pm

For which distribution?

This should be in the Linux/Unix forum by the way
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 8:45 am

for slackware
  • radnor
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Mar 06, 2006
  • Posts: 40
  • Status: Offline

Post March 10th, 2006, 8:50 am

Knoppix or Kanotix has it.
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 9:02 am

If you're installing PHP 5 from source, the general method is:

Code: [ Select ]
$ tar -jxvf php-VERSION.tar.bz2
$ ./configure \
--enable-force-cgi-redirect \
--with-mysql \
--enable-modules=php5 \
--with-gd \

# make && make install
  1. $ tar -jxvf php-VERSION.tar.bz2
  2. $ ./configure \
  3. --enable-force-cgi-redirect \
  4. --with-mysql \
  5. --enable-modules=php5 \
  6. --with-gd \
  7. # make && make install

You may need to --with-apsx2, I don't remember if you need this for PHP 5 on Slackware (I'd have to check).

To get it to play nicely with Apache, add this to your httpd.conf:
Code: [ Select ]
AddType application/x-httpd-php .php

and you may also want to add index.php to your DirectoryIndex line there, so it looks something like:
Code: [ Select ]
DirectoryIndex index.php index.html index.shtml
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 9:06 am

Well I meant does anybody have a manual for something that shows me how to use php on apache for example.
Quote:
http://localhost/test.php
How to use (.php) files on apache.



Thx
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 9:13 am

put this into a plain text file in your web root:
PHP Code: [ Select ]
<?php
 
phpinfo();
 
?>
  1. <?php
  2.  
  3. phpinfo();
  4.  
  5. ?>

save it as something.php then point your browser to http://localhost/something.php

If this isn't what you're asking, then I don't know what you mean. All you need to do to use a php script is put the script into your web root directory (/var/www/html by default)
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 10:12 am

Ya , but can my apache server read the .php files by default I dont have to change anything?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 10:21 am

As I wrote:
To get it to play nicely with Apache, add this to your httpd.conf:
Code: [ Select ]
AddType application/x-httpd-php .php

and you may also want to add index.php to your DirectoryIndex line there, so it looks something like:
Code: [ Select ]
DirectoryIndex index.php index.html index.shtml
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 3:27 pm

Should I leave this?
Quote:
AddType application/x-tar .tgz
or put your one in its place?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 3:31 pm

Put mine below that
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 4:29 pm

when i try to restart apache after putting that it says that theres a syntax error at the line where I added it. Here it is
Code: [ Select ]
bash-3.00# apachectl restart
/usr/sbin/apachectl restart: httpd not running, trying to start
Syntax error on line 239 of /etc/apache/httpd.conf:
Cannot load /usr/modules/libphp5.so into server: /usr/modules/libphp5.so: cannot open shared object file: No such file or directory
/usr/sbin/apachectl restart: httpd could not be started
  1. bash-3.00# apachectl restart
  2. /usr/sbin/apachectl restart: httpd not running, trying to start
  3. Syntax error on line 239 of /etc/apache/httpd.conf:
  4. Cannot load /usr/modules/libphp5.so into server: /usr/modules/libphp5.so: cannot open shared object file: No such file or directory
  5. /usr/sbin/apachectl restart: httpd could not be started
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 5:04 pm

What version of Slackware is this?

See if you have a file at /etc/apache2/mod_php.conf

If you do, make sure this line exists in it:
LoadModule php5_module lib/apache2/libphp5.so

And make sure this line is in your httpd.conf:
Include /etc/apache2/mod_php.conf


If you don't, just add this line to your httpd.conf
LoadModule php5_module lib/apache2/libphp5.so


Make sure you do this in httpd.conf before you:
AddType application/x-httpd-php .php

If you still get errors, try running the test script from the command line and see if it gives any errors. Also, look in your error logs for Apache and see if it's telling you anything useful.
  • Cheeseboy
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Jul 25, 2005
  • Posts: 106
  • Status: Offline

Post March 10th, 2006, 5:56 pm

Code: [ Select ]
#
# mod_php - PHP Hypertext Preprocessor module
#

#LoadModule php4_module libexec/libphp4.so
LoadModule php4_module libexec/apache/libphp4.so
#AddModule mod_php4.c

# Tell Apache to feed all *.php files through the PHP module:
AddType application/x-httpd-php .php

# This will display PHP files in colored syntax form. Use with caution.
#AddType application/x-httpd-php-source .phps
  1. #
  2. # mod_php - PHP Hypertext Preprocessor module
  3. #
  4. #LoadModule php4_module libexec/libphp4.so
  5. LoadModule php4_module libexec/apache/libphp4.so
  6. #AddModule mod_php4.c
  7. # Tell Apache to feed all *.php files through the PHP module:
  8. AddType application/x-httpd-php .php
  9. # This will display PHP files in colored syntax form. Use with caution.
  10. #AddType application/x-httpd-php-source .phps





That is what my /etc/apache2/mod_php.conf looks like it has something similiar to that line look good to you?
  • this213
  • Guru
  • Guru
  • User avatar
  • Joined: Mar 01, 2004
  • Posts: 1242
  • Loc: ./
  • Status: Offline

Post March 10th, 2006, 6:11 pm

OK, you can remove the line I said to put into your httpd.conf, because it's in there:
AddType application/x-httpd-php .php

just make sure that include line exists in your httpd.conf (fixed to the right path):
Include /etc/apache2/mod_php.conf

Are you running php 4 or php 5?
LoadModule php4_module libexec/apache/libphp4.so

If you're trying to install PHP 4, don't bother. Go get PHP 5.

Are you running Apache 1.x? If so, you might as well upgrade that as well.

Again, what version of slackware is this, it doesn't exactly look recent.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post March 10th, 2006, 6:11 pm

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 131 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.