Databases Reference
In-Depth Information
If you check the permissions again, you should find that other users can access the file;
we've granted the group read access as well, but that's not strictly necessary:
$ ls -al path_to_document_root/ phpinfo.php
-rw-r--r-- 1 saied saied 20 Jul 22 11:35 /var/www/html/phpinfo.php
A common cause of Access Denied problems is the file or directory not being readable.
The web server also needs execute access to the directory containing the file, and all
the directories above it. On some systems, only the superuser can write to the document
root, so you may also need to allow write access to the document root. See “Restricting
access to files and directories,” at the beginning of this chapter, for more discussion of
file and directory permissions.
After creating the file, run the script by requesting the address http://localhost/phpinfo
.php with a web browser that is running on the same machine as the web server. If you
see a readable web page—and not just what you typed into the file—then your web
server has PHP support. Search this page for the word “mysql”; if you find a section
labeled “mysql” (and perhaps another labeled “mysqli”), your PHP installation can talk
to your MySQL server.
If you just see the contents of the phpinfo.php file, or your browser tries to download
the file, your Apache server may not support PHP. However, there are three common
problems that can cause this to happen even when your server does support PHP:
• Your PHP test files don't have the extension .php . If this is the case, your web server
will deliver the source code and not run the scripts. Rename your scripts with
a .php extension.
• Your web server isn't configured to run the PHP engine when a file with the .php
extension is requested. In Apache, this is controlled by the Apache configuration
file described earlier in “The Apache Configuration File.” Open the configuration
file and search for the following line:
AddType application/x-httpd-php .php
If this line is commented out—that is, there's a pound or hash symbol ( # ) before
the text on the line—uncomment the line by removing this symbol, save the file,
and restart the web server following the instructions listed earlier in “Starting and
Stopping Apache.” If the line isn't there at all, add it and restart the server.
• Your Apache PHP module isn't being loaded by Apache. Open the Apache con-
figuration file and check whether one of the following lines appears in the file:
LoadModule php4_module libexec/libphp4.so
LoadModule php5_module libexec/libphp5.so
Add one of these lines if they don't appear in the file. Try using the php5_module
line first. If both lines have the pound or hash symbol before the text on the line,
remove the comment symbol from one of the lines to activate the PHP module. If
you change the Apache configuration file, restart the web server.
 
Search WWH ::




Custom Search