You are not logged in.
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
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
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
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
Gracias, era un error de hostname xD
always try to speak english here please!!
GNU/Linux: Share & Enjoy!
Offline