Intergrating Php with apache on Linux

  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

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!
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

For which distribution?

This should be in the Linux/Unix forum by the way
  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

for slackware
  • radnor
  • Beginner
  • Beginner
  • radnor
  • Posts: 40

Post 3+ Months Ago

Knoppix or Kanotix has it.
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

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
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

Ya , but can my apache server read the .php files by default I dont have to change anything?
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

Should I leave this?
Quote:
AddType application/x-tar .tgz
or put your one in its place?
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

Put mine below that
  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

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
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

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
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

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.
  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

Well, its 10.2 and yes its apache 1x, and it loks like it came with php 4 I installed php5 but it seems they are both on there could this mess anything off if so how would i find php4 it was installed at the installion of the distro.
  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

would I use pkgtool to remove php4? And what about the loadmodule you told me to add that is stopping me from starting apache should i remove thaT? What about
Quote:
See if you have a file at /etc/apache2/mod_php.conf


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



That code i listed was from that you didnt say how it looked.
  • Cheeseboy
  • Graduate
  • Graduate
  • Cheeseboy
  • Posts: 106

Post 3+ Months Ago

Its working now man :D




Thx for your help

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 13 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
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.