How to configure the apache php environment in windows (php. ini configuration)

Source: Internet
Author: User
Tags apache php

The php configuration environment is simple. We only need to install apache before configuring php, but we can also configure the php. ini file separately. Next I will introduce how to quickly configure the php environment.

First, we first go to php.net to download a php decompressed version. Remember that if it is windows, it also needs a secure thread version.

Decompress php to the c:/php Directory, and change the configuration file in to php. ini (you can change php. ini-development to php. ini)


1. Set the extension path

Find the row in extension_dir

The Code is as follows: Copy code
Extension_dir = "./"

Change this row

The Code is as follows: Copy code

Extension_dir = "C: phpext"

C: php is the path where you install php. dll cannot be loaded if the path is incorrect.

(Note: Some php versions are; extension_dir = "./" should remove the semicolon above)

2. Search

The Code is as follows: Copy code

; Extension = php_curl.dll
; Extension = php_gd2.dll
; Extension = php_mbstring.dll
; Extension = php_exif.dll
; Extension = php_mysql.dll
; Extension = php_mysqli.dll
; Extension = php_sockets.dll
; Extension = php_xmlrpc.dll
; Extension = php_zip.dll

Remove the semicolons from the above items so that these dll files can be loaded.
When installing PHP with IIS, copy these dll files to C: Windowssystem32.

3. Set the session storage path.
Find the row in session. save_path.
; Session. save_path = "N;/path"
Add a row after this line (note that adding a row is not followed ),
Session. save_path = "C: Temp"
If you use a level-2 Directory to store sessions hierarchically, you need to change it:
Session. save_path = "2; C: Temp"
Save it to your temporary directory. Here, the path you set prevails. Pay attention to modifying folder permissions.

For how to set level-2 Directory Hierarchical Storage, see:
Hierarchical Storage and Regular deletion of PHP temporary file sessions

4. Note the short_open_tag. Some php versions are Off by default.
That is to say, php cannot use short tags.
Short tags are easy to use, and many programs use short tags for writing, such as discuz.
If you do not change short_open_tag to On, it will be difficult to determine the cause. We recommend that you modify it here.
Search
Short_open_tag = Off
Change
Short_open_tag = On

5. Whether the error display_errors is displayed
For security reasons, some display_errors versions are also Off by default.
That is to say, during debugging, if the php code is incorrect, only one blank page is displayed, and the error cause and number of lines are not displayed.
Therefore, debugging is inconvenient. You are advised to modify it as needed.
Search
Display_errors = Off (note not;-display_errors = Off [Security])
Change
Display_errors = On

6. display the NOTICE prompt
Although the error prompt is displayed in step 5, the error report is also controlled by error_reporting.
By default, NOTICE is disabled in php5. If debugging is performed locally, you are advised to enable the NOTICE prompt.
Search
Error_reporting = E_ALL &~ E_NOTICE
Change
Error_reporting = E_ALL
In addition, you can use error_reporting () to control the output of error reports. For details, refer to the following manual.

7 register_globals

It is also Off by default for security reasons.
When register_globals = Off, $ _ POST ['user _ name'] and $ _ POST ['user _ pass'] should be used for receiving the next program.
When register_globals = On, the next program can directly use $ user_name and $ user_pass to accept the value.

8 php5 Time Difference

Time Difference: eight hours
Why? The Time Zone settings are added for the PHP5 series. The default value is Greenwich Mean Time, which is 8 hours different from the East 8 zone in China.
Find the row in date. timezone
; Date. timezone =
Replace;
Date. timezone = PRC
PRC: People's Republic of China,


After the configuration is complete, we can configure apache. We can also download an x86 apache package from apache.org and install it on the computer. Then we can open httpd in the apache installation directory. conf is added at the end

The Code is as follows: Copy code

LoadModule php5_module "c:/PHP/php5apache2_2.dll"
PHPIniDir "c:/PHP /"
AddType application/x-httpd-php. php. phtml

Restart apache.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.