PHP安装与基本配置

(0 comments)

下载源代码编译安装,下面以php-4.3.9版本为例说明配置过程。

./configure --prefix=/usr/local/php-4.3.9 \
--with-mysql \
--enable-force-cgi-redirect \
--with-freetype-dir=/usr \
--with-ttf \
--with-gettext \
--with-iconv \
--with-zlib \
--with-xml \
--with-ldap \
--with-openssl \
--enable-calendar \
--with-apxs2=/usr/sbin/apxs

默认设置下,通过Web方式浏览时,所有出错信息都记录在httpd服务器的error_log里面,页面上只会显示空白页面。调试程序时,为了将错误信息直接打印到Web页面上,可以将display_errors打开,如下所示:

display_errors = On

调试程序可以使用两种方式:

  • 命令行直接调用php命令调试。
    浏览器通过Web方式调试。

PHP默认只允许上传最大不超过8M大小的文件,首先确信file_uploads选现被打开,并增加最大允许上传的文件大小到1536M,如下所示:

; Whether to allow HTTP file uploads.
file_uploads = On
  
; Maximum allowed size for uploaded files.
upload_max_filesize = 1536M

通常用户会以POST方式上传文件,因此也需要增大post_max_size参数大小,如下所示:

; Maximum size of POST data that PHP will accept.
post_max_size = 1536M

将资源限制设置的更大,包括内存大小和timeout限制等,如下所示:

; Maximum execution time of each script, in seconds
max_execution_time = 2000
; Maximum amount of memory a script may consume (8MB)
memory_limit = 64M

关闭short_open_tag有利于开发环境,这样你的代码安装到其他服务器上时有更好的兼容性。

可是当你的服务器上安装了其他人的代码,为了提高兼容性,可以将这个选项打开。

; Allow the <? tag.  Otherwise, only <?php and <script> 
; tags are recognized.
short_open_tag = Off
Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required