You are not logged in.

#1 2003-09-11 23:29:07

red_over_blue
Member
Registered: 2003-07-19
Posts: 152

Howto - Using apache and mod_php4

This is a quick tutorial on how to use the apache web server with the php module.  I am by no means an expert, so if you have any questions/suggestion, please feel free.  That being said, let's get started:

1.  Install apache and php:

[root@limbo root]# pacman -Sy apache
[root@limbo root]# pacman -Sy php

2.  First, ensure that you have the apache web server running properly, and can serve up simple HTML documents:

[root@limbo phpbb]# /etc/rc.d/httpd start
[ Starting HTTP Daemon                                                    DONE ]

Now, point your browser to http://localhost/ and you should see a default Arch web server page.  If not, you must get this working before continuing.

3.  Now, if the apache web server is working, let's shut it down and work on adding PHP functionality:

[root@limbo root]# /etc/rc.d/httpd stop
[ Stopping HTTP Daemon                                                    DONE ]

4.  We must now make changes to the apache config file:

[root@limbo root]# nano /etc/httpd/conf/httpd.conf

5.  We must load the PHP module.  Find the LoadModule portion of httpd.conf and add:

LoadModule php4_module        lib/apache/libphp4.so

and then find the AddModule section and add:

AddModule mod_php4.c

6.  To let apache know that files ending in .php are in fact PHP files, we add the following.  It doesn't matter where you put it, but you can search for AddType and pick a plac e you think fits.

# Added by root for mod_php 
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

7.  And to ensure that .php files are looked at first by apache when looking at directory contents, find the section that looks like what you see below, but notice that I have added index.php for php index files:

#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
    DirectoryIndex index.php index.html 
</IfModule>

8.  Now, change the root apache directory by finding the line containing DocumentRoot and change it to the following (we will create the directory shortly, and place an index.php in there also):

DocumentRoot "/home/httpd/html/phptest"

9.  For the final config step, we must tell the Arch init script to load the php module when it starts apache.  All we have to do is edit /etc/conf.d/httpd and add the APACHE_OPTS line:

HTTPD_USE_SSL="no"
APACHE_OPTS="-D PHP4"

10.  Now, create the directory /home/httpd/html/phptest

11.  Create a plain text file using your favorite text editor.  The file is  /home/httpd/html/phptest/index.php

The contents of this file should be the following:

<html>
<head>
  <title>PHP Test</title>
</head>
<body>
<? phpinfo(); ?>
</body>
</html>

12.  Once running the apache web server, you will notice that Arch sets it up to run as user "nobody".  Therefore, we want "nobody" to own all the files that we are going to use:

[root@limbo root]# chown -R nobody.nobody /home/httpd/html/*
[root@limbo root]# chmod -R 744 /home/httpd/html/*

13.  Finally, start the apache web server again, and point your browser to your http://localhost/   You should now see alot of info, provided dynamically by the PHP module.



I hope this quick tutorial is useful.  It you see anything wrong with it, or have suggestions, please let me know and I will edit this post.


Don't forget to post your PKGBUILD in your thread when you announce a new package in incoming.
see HERE for details

Offline

#2 2003-09-23 13:16:58

seba
Member
From: Villa Alemana, Chile
Registered: 2003-08-14
Posts: 23
Website

Re: Howto - Using apache and mod_php4

hi, i cant start apache

[root@zlk daemons]# /etc/rc.d/httpd start
[ Starting HTTP Daemon                                                  FAILED ]


Danielita I Love You So Much My Life
[code][segfault@biotec ~]$ cat /etc/arch-release
Arch Linux 0.7.2 (Gimmick)[/code]
Blog:http://segfault.kde.cl/blog

Offline

#3 2003-09-23 13:22:33

netkrash
Member
From: Viña del Mar, Chile.
Registered: 2003-03-19
Posts: 94

Re: Howto - Using apache and mod_php4

seba wrote:

hi, i cant start apache

[root@zlk daemons]# /etc/rc.d/httpd start
[ Starting HTTP Daemon                                                  FAILED ]

check you /var/log/httpd/error_log

:^)


GNU/Linux: Share & Enjoy!

Offline

#4 2003-09-23 14:21:49

seba
Member
From: Villa Alemana, Chile
Registered: 2003-08-14
Posts: 23
Website

Re: Howto - Using apache and mod_php4

Gracias, era un error de hostname xD


Danielita I Love You So Much My Life
[code][segfault@biotec ~]$ cat /etc/arch-release
Arch Linux 0.7.2 (Gimmick)[/code]
Blog:http://segfault.kde.cl/blog

Offline

#5 2003-09-23 20:46:03

netkrash
Member
From: Viña del Mar, Chile.
Registered: 2003-03-19
Posts: 94

Re: Howto - Using apache and mod_php4

seba wrote:

Gracias, era un error de hostname xD

always try to speak english here please!!


GNU/Linux: Share & Enjoy!

Offline

Board footer

Powered by FluxBB