配置PHP(转载)

Jun 23, 2016 pm 02:32 PM

由于php是一个zip文件(非install版),安装较为简单

  解压就行.把解压的 php-5.2.1-Win32 重命名为 php5.并复制到C盘目录下.即安装路径为 c:\php

  1 找到php目录下的 php.ini.recommended (或者php.ini-dist)文件,重命名为 php.ini

  并复制到系统盘的windows目录下(以c:\windows为例).

  2 再把php目录下的php5ts.dll,libmysql.dll复制到目录 c:\windows\system32下.

  3 把php\ext目录下的php_gd2.dll,php_mysql.dll,php_mbstring.dll文件复制到c:\windows\system32下

  注意:不要把 php_mysql.dll 和 php_mssql.dll 混淆

  如果没有加载 php_gd2.dll php将不能处理图像.没有加载php_mysql.dll php将不支持mysql函数库

  php_mbstring.dll在后面使用phpmyadmin时支持宽字符

  配置php并关联MySQL

  1 设置扩展路径

  查找 extension_dir 有这么一行

  extension_dir = "./"

  将此行改成

  extension_dir = "C:\php\ext"

  其中C:\php是你安装php的路径.路径不正确将无法加载dll

  (注意:有些php版本是 ;extension_dir = "./" 要把前面的分号去掉)

  2 分别查找

  ;extension=php_mbstring.dll

  ;extension=php_gd2.dll

  ;extension=php_mysql.dll

  把上面3项前面的分号去掉,这样apache启动时就可以加载这些dll了

  注意不要把 ;extension=php_mysql.dl 和 ;extension=php_mssql.dl 混淆

  当然前面我们也把这些dll复制到system32下了.(大家在安装的过程中都注意到如何把一些dll加载入来了.

  以后要加载一些dll,比如说php_mysqli.dll,也就懂得怎么加载了)

  3 设置会话保存路径

  查找session.save_path 有这么一行

  ; session.save_path = "N;/path"

  在此行后加入一行(注意是加入一行,不是加到后面)

  session.save_path = "C:\WINDOWS\Temp"

  保存到你的临时目录下,这里完全可以保存到windows临时目录Temp下

  4 是否显示错误 display_errors

  出于安全性考虑,display_errors 有些版本也默认为 Off.

  就是说在调试时,如果php代码有误,就只出现一个空白页.而不会显示出错原因和出错行数.

  这样调试起来将非常不便,建议根据自己需要修改

  查找

  display_errors = Off (注意不是 ; - display_errors = Off [Security])

  改成

  display_errors = On

  5 php5时差问题

  时间相差八小时

  为什么呢?PHP5系列版本新增了时区设置,默认为格林威治时间,与中国所在的东8区正好相差8个小时

  查找date.timezone有这么一行

  ;date.timezone =

  将;去掉,改成

  date.timezone = PRC

  其中PRC:People's Republic of China 中华人民共和国,

  PHP的文件上传问题

  文件上传成败关键的几点php.ini配置

  文件上传的程序没有错,但php的配置很可能导致文件不能上传成功.

  1. 一般的文件上传,除非文件很小.就像一个5M的文件,很可能要超过一分钟才能上传完.

  但在php中,默认的该页最久执行时间为 30 秒.就是说超过30秒,该脚本就停止执行.

  这就导致出现 无法打开网页的情况.这时我们可以修改 max_execution_time

  在php.ini里查找

  max_execution_time

  默认是30秒.改为

  max_execution_time = 0

  0表示没有限制

  另一种方法是可以在php程序中加入

  set_time_limit();

  来设定页面最久执行时间.

  set_time_limit(0);//0表示没有限制

  2. 修改 post_max_size 设定 POST 数据所允许的最大大小。此设定也影响到文件上传。

  php默认的post_max_size 为2M.如果 POST 数据尺寸大于 post_max_size $_POST 和 $_FILES superglobals 便会为空.

  查找 post_max_size .改为

  post_max_size = 150M

  3. 很多人都会改了第二步.但上传文件时最大仍然为 8M.

  为什么呢.我们还要改一个参数upload_max_filesize 表示所上传的文件的最大大小。

  查找upload_max_filesize,默认为8M改为

  upload_max_filesize = 100M

  另外要说明的是,post_max_size 大于 upload_max_filesize 为佳.

  四. active perl 需要安装到c:/perl

  五. ZendOptimizer 安装时把 apache 服务器关掉,在过程中要指定 apache 和 php 的安装路径一

 

 

一、下载php-5.2.11-Win32.zip,解压到D:\php。
二、右击我的电脑>属性>高级>系统变量,双击Path变量,在弹出窗口的变量值字段前加D:\php;D:\php\ext;
三、修改php.ini,去掉下面扩展前面的注释。

extension=php_bz2.dll
extension=php_curl.dll
extension=php_dba.dll
extension=php_dbase.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_mysql.dll
extension=php_zip.dll

四、修改php.ini,改extension_dir = "./"为extension_dir = "D:/php/ext"
五、修改php.ini,实现php上传文件.改;upload_tmp_dir =为upload_tmp_dir ="D:\php\tmp\upload"
六、修改php.ini,改;session.save_path = "/tmp"为session.save_path = "D:\php\tmp\session"
七、修改php.ini,改soap.wsdl_cache_dir="/tmp"为soap.wsdl_cache_dir="D:\php\tmp\soap"
八、(可选修改)修改php.ini中,short_open_tag、asp_tags的值为on,
那样输入php代码时就可以用...?>和,php5为了规范,默认是关闭,只支持
九、拷贝php.ini到C:\windows\文件夹,拷贝D:\php\目录下的libmysql.dll到c:\windows\system32\文件夹。
十、IIS管理器中,网站属性>主目录>应用程序配置>映射,添加php扩展名映射。
可执行文件:D:\php\php5isapi.dll
扩展名:.php
九、重启IIS服务。最好重启服务。
十、查看系统日志,有没出错。并查看php的mysql扩展有没打开。下面代码存成phpinfo.php,显示mysql等扩展正常打开。

 

注:当此时在IIS里浏览php文件时如果出现404错误,请查看IIS中“WEB服务扩展>所有未知ISAPI扩展”是否为“允许”,如果为“禁止”请调整。

转自:http://hi.baidu.com/hiran/blog/item/1a65f53f9fb211e655e7234f.html

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

How does PHP type hinting work, including scalar types, return types, union types, and nullable types? How does PHP type hinting work, including scalar types, return types, union types, and nullable types? Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

See all articles