Home  >  Article  >  Backend Development  >  php config_PHP tutorial

php config_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:37:30947browse

PHP 的安装

由于php是一个zip文件(非install版),安装较为简单
解压就行。把解压的 php5.2.1-Win32重命名为 php5。并复制到安装盘目录下。例如安装路径为 c:php5
1  找到php目录下的 php.ini-dist或 php.ini.recommended文件,重命名为 php.ini,并复制到系统盘的windows目录下(以c:windows为例,2000是在winnt目录下,下面都采用网友的方法来说明).

2  再把php目录下的php5ts.dll,libmysql.dll复制到目录 c:windowssystem32下。

3  把php5ext目录下的php_gd2.dll,php_mysql.dll,php_mbstring.dll文件复制到c:windowssystem32下
如果没有加载 php_gd2.dll  php将不能处理图像。没有加载php_mysql.dll php将不支持mysql函数库  php_mbstring.dll在后面使用phpmyadmin时支持宽字符
所有东西安装完成后我们再进行配置

配置php并关联MySQL
打开c:windowsphp.ini文件
1 设置扩展路径
查找 extension_dir 有这么一行
extension_dir = "./"
将此行改成
extension_dir = "C:php5ext"
其中C:php5是你安装php的路径。路径不正确将无法加载dll
(注意:有些php版本是 ;extension_dir = "./" 要把前面的分号去掉)

2 查找 extension
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_mysql.dl
把上面3项前面的分号去掉,这样apache启动时就可以加载这些dll了
当然前面我们也把这些dll复制到system32下了l

3 设置会话保存路径
查找session.save_path 有这么一行
;     session.save_path = "N;/path"
在此行后加入一行(注意是加入一行,不是加到后面)
session.save_path = "C:WINDOWSTemp"
保存到你的临时目录下,这里完全可以保存到windows临时目录Temp下

4 还有比较值得注意的是 short_open_tag 默认是Off的
也就是说 php不能使用短标记如 必须使用
由于短标记使用方便,并且很多程序也是用短短标记来写,如discuz等
如果不把 short_open_tag 改成On将出现的症状将很难判断是上面原因,这里建议修改
查找
short_open_tag = Off
改为
short_open_tag = On

5 是否显示错误 display_errors
出于安全性考虑,display_errors 也默认为 Off
就是说在调试时,如果php代码有误,就只出现一个空白页。而不会显示出错原因和出错行数。
这样调试起来将非常不便,建议根据自己需要修改
查找
display_errors = Off           (注意不是 ; - display_errors = Off           [Security])
改成
display_errors = On

6 register_globals
出于安全性考虑它默认也是Off
当register_globals=Off的时候,下一个程序接收的时候应该用$_POST[user_name]和$_POST[user_pass])
当register_globals=On的时候,下一个程序可以直接使用$user_name和$user_pass来接受值。
更详细的说明请参考
http://www.phpfans.net/bbs/archiver/?tid-234.htm
建议根据自己需要修改

7 php5时差问题
时间相差八小时
为什么呢?PHP5系列版本新增了时区设置,默认为格林威治时间,与中国所在的东8区正好相差8个小时
查找date.timezone有这么一行
;date.timezone =
将;去掉,改成
date.timezone = PRC
其中PRC:Peoples Republic of China 中华人民共和国,
更详细解决方法请参考本论坛的
http://www.phpfans.net/bbs/archiver/?tid-60.html
更多文章 php爱好者站 http://www.phpfans.net/

Apache整合PHP

1 从开始菜单打开apache配置文档
 
2 修改网站根目录
查找 DocumentRoot有这么一行
DocumentRoot"C:/Program Files/Apache Group/Apache2/htdos"
这就是你网站的根目录,你可以修改,也可以用默认的.如果改,还要修改下面这项,否则可能会出现 403 错误
查找  This should be changed to whatever you set DocumentRoot to
在它下面两行有

把上面两项的 C:/Program Files/Apache Group/Apache2/htdos 改成你想要的目录

3 查找  DirectoryIndex index.html index.html.var
修改成
DirectoryIndex index.html index.html.var  index.php
这样index.php 可以充当默认页面了

4 Apache中模块化安装php
查找 # LoadModule foo_module modules/mod_foo.so
在此行后加入一行
LoadModule php5_module C:/php5/php5apache2.dll

C:/php5/php5apache2.dll is the corresponding path where you install php.
Be careful not to confuse php5apache2.dll with php5apache.dll. php5apache.dll is only applicable to apache version 1.
Note : The php5apache2.dll in the PHP5 compressed package is only suitable for apache2.0.* version. If it is 2.2.* or above version,
"Cannot load C:/php/php5apache2.dll into server: The specified module could not be found."
or:
"The requested operation has failed"
. For the solution to this problem, please refer to this forum's
http://www.phpfans. net/bbs/viewthread.php?tid=857&extra=page%3D1

5 Find AddType application/x-gzip .gz .tgz
Add a line after this line
AddType application/x-httpd-php .php
So that apache can interpret the php file
The configuration is basically completed here

########Restart apache#########

Create a phpinfo.php file in the root directory of the website

phpinfo();
?>

Open
http://localhost/phpinfo.php in the browser
If the following information appears, it means that php has been configured


Let’s test the association between php and mysql database
Create a test.php file in the root directory of the website

CODE:[Copy to clipboard]$link=mysql_connect("localhost","root","12345"); //Change 12345 to your mysql password
if(! $link) echo "Failure!";
else echo "Success!";
mysql_close();
?>

Open http://localhost/test.php in the browser
If the output is successful, it means you are done.

Install phpMyAdmin

Download phpMyAdmin-2.7.0.zip, unzip it to the root directory of your website and rename it to phpMyAdmin.
Find and open config.defaut.php (some versions are config.inc.php or libraries/ config.default.php)
Make the following changes:

1 Find the following two lines for password
$cfg[Servers][$i][user] = root;
$cfg[Servers][$i][password] = ;

Fill in your mysql password into $cfg[Servers][$i][password] = ; inside the single quotes

2 Search $cfg[PmaAbsoluteUri] and set it to the phpMyAdmin directory path, such as: http://localhost/phpMyAdmin/;

Modify the following two items according to the coding you need (if you are not very familiar with database coding, it is recommended not to modify it)
3 Search $cfg[DefaultLang] and set it to zh-gb2312;
4 Search $cfg[DefaultCharset] and set it to gb2312;

Open the browser, enter: http://localhost/phpMyAdmin/, Apache and MySQL have been started,
If the following page appears, the phpmyadmin installation is complete and can be used

The specific functions of phpMyAdmin , please get familiar with it slowly, and I won’t go into details here.

My comprehensive summary:

1. Try to name the installation directory in English, as well as the files (who says China is lagging behind?)

2. Apache provides web services. I have not verified the MYSQL database connection. I installed it directly using a PHPWIND forum, which proves that the connection is successful. It is best to download PHP from the official website. (I first used PHP5.2.1, which I downloaded from somewhere, but a file was missing. It always said that the module could not be loaded. It took me a long time to find out, which was frustrating)

3. My system is the 2000 server version under D. Therefore, c:windows is changed to d:winnt. You should understand this.

4. In addition, it is easier to configure PHP under iis:

Installation method of PHP+IIS under Windows 2000

<1>. Unzip php-5.0.0 (recommended if there is a new version)-Win32.zip and put it in C:php.

<2>. Copy php.ini-dist to the Winnt directory and rename it to php.ini. Copy php5ts.dll and libmysql.dll to WINNTsystem32.

<3> Next, make settings in IIS, open the Default Site Properties dialog box, switch to the "Home Directory" tab, then click the "Configure" button to open the "Application Configuration Dialog Box", click "Add ” button opens the “Add/Edit Application Extension Mapping” dialog box. In the "Executable File" input box, point to c:/php/php5isapi.dll, enter ".php" (excluding quotation marks) in the "Extension Name" input box, and select "Script Engine" and "Check whether the file There are two check boxes, confirm and exit IIS.

At this point the server should be able to support both asp and php.

Configure php.ini below to allow php to support MYSQL and GD libraries

<1>, search for "extension_dir" in notepad, and then set
extension_dir = "./"

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486590.htmlTechArticlePHP installation Since php is a zip file (non-install version), the installation is relatively simple, just unzip it. Rename the unzipped php5.2.1-Win32 to php5. And copy it to the installation disk directory. For example, An...

Statement:
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