我的 apache 日志文件中收到许多以下错误:
PHP: syntax error, unexpected '(' in /etc/php5/apache2/php.ini on line 3
但这些是/etc/php5/apache2/php.ini
的前 15 行:
[菲律宾语];;;;;;;;;;;;;;;;;;;;关于 php.ini ;;;;;;;;;;;;;;;;;;;;;PHP 的初始化文件,通常称为 php.ini,负责;配置 PHP 行为的许多方面。;PHP 尝试从多个位置查找和加载此配置。;以下是其搜索顺序的摘要:;1.SAPI模块具体位置。;2. PHPRC 环境变量。(从 PHP 5.2.0 开始(;3. Windows上的许多预定义注册表项(从PHP 5.2.0开始(;4. 当前工作目录(CLI 除外(;5. Web 服务器的目录(用于 SAPI 模块(,或 PHP 的目录
php.ini的第一行未注释:
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
y2k_compliance = On
我以为这将是一个缓存问题,但我刚刚禁用了我的 PHP 缓存(它是 APC(
我找不到任何不在整个文件的评论中的(
。
否则PHP怎么会认为文件中有(
而没有呢?
;
在php.ini
中表示注释行。消息不计算注释行。因此,第 3 行表示顶部评论之后的第 3 行。
编辑1:确保你打开的是正确的php.ini
PHP真正使用的文件
编辑 2 :使用phpinfo();
并在结果页面上查看Loaded Configuration File
值。 它显示当前正在使用php.ini
文件。注意:重新启动您的 apache
我试图模仿你的情况:
~]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/phar.ini,
/etc/php.d/zip.ini
所以我去/etc/php.ini并取消注释其中一行带有"(">
~]$ vi /etc/php.ini
[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
; 3. A number of predefined registry keys on Windows (As of PHP 5.2.0)
; 4. Current working directory (except CLI)
; 5. The web server's directory (for SAPI modules), or directory of PHP
(otherwise in Windows)
; 6. The directory from the --with-config-file-path compile time option, or the
现在我检查是否有错误通知:
~]$ php --ini
PHP: syntax error, unexpected '(' in /etc/php.ini on line 16
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
是的,并且错误,但它显示正确的行号,而不是忽略注释的行。当我重新启动 apache 时,我也在 apache/error_log 中收到了相同的错误消息。
PHP: syntax error, unexpected '(' in /etc/php.ini on line 16
php 文件有效,但没有将有关 ini 的错误发送到日志。
那么,你为什么不编辑你的/etc/php5/apache2/php.ini呢?只需擦除几行,然后查看错误消息是否移动到其他数字。
确保在更改后重新启动 apache。