Showing posts with label configuration. Show all posts
Showing posts with label configuration. Show all posts

Friday, February 09, 2007

Problems when installing pear

I got the following error when I first tried to install PEAR components:
Cannot find module (IP-MIB): At line 0 in (none)
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (TCP-MIB): At line 0 in (none)
Cannot find module (UDP-MIB): At line 0 in (none)

.......
I googled this error, every expert says there's a configuration error. Yes, there must be a configuration issue. That is so obvious! But, WHERE? Where does this fucking configuration issue reside?
I checked the php.ini file, but I didn't get many clues at first. After a while, I recalled that the php.ini file is created by renaming the default "php.ini-dist" file. There are some unnecessary entries in the end of the file which led to the above error. After deleting all of them, everything works fine.
However, another problem appeared, which was like:
PHP Warning: Cannot use a scalar value as an array in phar://go-pear.phar/PEAR/Command.php on line 268
......
This was also a strange error. But still, not much information in the documentation related to this! The solution was:
(1) go to the site: http://go-pear.org/ , read the instructions;
(2) you'll find the following command for windows:
C:\php5>php -r "readfile('http://pear.php.net/go-pear');">go-pear
C:\php5>php go-pear

The it's all solved! It took me almost one hour due to lack of documentation.

Thursday, February 01, 2007

PHP Apache tips

(1) How to log errors in PHP instead of displaying them on the page?
Use the following lines in php.ini:
; Print out errors (as a part of the output).
information.display_errors = off
; Even when display_errors is on, errors that occur during PHP's startup; debugging.display_startup_errors = Off
; Log errors into a log file (server-specific log, stderr, or error_log (below));
sites.log_errors = On
; Set maximum length of log_errors.
log_errors_max_len = 1024
; Do not log repeated messages.
ignore_repeated_errors = Off
; Ignore source of message when ignoring repeated messages.
ignore_repeated_source = Off
; Log errors to specified file.
error_log = "logs/errors.log"
(2) How to find backend SQL errors?
Set the following line in php.ini:
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and SQL-Errors will be displayed.
mysql.trace_mode = On

(3) How to avoid exposing index structures for a folder?
Set the following lines in httpd.conf:
## DirectoryIndex: sets the file that Apache will serve if a directory is requested.

DirectoryIndex index.php

In such a way, request for a directory will be redirected to the file "index.php".
(4) How to use logging in Apache server?
Use the following 2 settings:
## ErrorLog: The location of the error log file.
ErrorLog logs/error.log
## LogLevel: Possible values include: debug, info, notice, warn, error, crit, alert, emerg.

LogLevel warn
(5) How to do directory-level access configuration for Apache Http Server?
Here's an example:

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

Details can be found in http://httpd.apache.org/docs/2.2/mod/core.html#options .

Wednesday, January 31, 2007

Configure MySQL with PHP

Product version: PHP5 (Non-installed version for windows), MySQL5 (Non-installed version for windows).
Steps:
(1) Use php.ini-recommended as the default ini file by renaming it to php.ini.
(2) In the development environment, it's useful to set display_errors = on. When moving the web application to production, this switch should be turned off.
(3) Check the document root in the following line: doc_root ="C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" .
(4) Specify the loadable module directory extension_dir = "C:\php5\ext" .
(5) Enable php_mysql.dll inside of php.ini by removing semicolon from the line ;extension=php_mysql.dll .
(6) PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH. So add "C:\php5\" to PATH environmental variable.
(7) Specify upload_tmp_dir and session.save_path if necessary.
(8) Copy some extension pointers in the orginal php.ini file into the new php.ini file.