Home  >  Article  >  Backend Development  >  PHP environment configuration php5 mysql5 apache2 phpmyadmin installation and configuration_PHP tutorial

PHP environment configuration php5 mysql5 apache2 phpmyadmin installation and configuration_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:01:211173browse

The configuration of the PHP environment is definitely a troublesome task for novices. You will always encounter problems of one kind or another and take many detours.
So I specially wrote this configuration document today. I believe you will succeed by following the following steps. I also hope that everyone
can correct me if I am wrong.
More articles php fans site http://www.phpfans.net

This example is the installation and configuration of apache2.0.55 php5.1.1 (zip) mysql5.0.19 phpmyadmin2.7.0 under wiondws
The above resources can be downloaded at http://www.phpfans.net/download.php/

/*
Author: I am not a fish
Website: http:// www.phpfans.net
Blog: http://www.phpfans.net/space/index.php/2
email:deng5765@163.com
*/

Apache installation
1 Click apahce installation package


2 Fill in the following three items as you like
Apache listens to port 80. If iis uses port 80, modify the iis port or apache port to avoid conflicts


3 The default here is typical.如果想修改安装路径的话也可以选择custom,注意安装路径不能含中文


4 开始安装


5 安装完成后在浏览器里打入  http://localhost
如果可以看到这个页面,证明apache安装成功,已经可以解释静态页面了


MySQL 的安装

1 点击mysql安装包


2 默认是Typical,如果想修改安装路径的话也可以选择custom.
注意:安装mysql的路径中,不能含有中文!


3 安装开始


4 跳过注册


5 是否现在就配置 mysql。也可以之后在开始菜单的configuration wizard 进行配置
  这里是现在进行配置


6 选择Detailed Configuration,点Next继续


7 下面这个选项是选择mysql应用于何种类型,第一种是开发服务器,
将只用尽量少的内存,第二种是普通WEB服务器,将使用中等数量内存,
最后一种是这台服务器上面只跑mysql数据库,将占用全部的内存。
用户可根据自己的需求,选择选项。这里只选择开发服务器,点Next继续


8 下面是选择数据库用途,第一种是多功能用途,
将把数据库优化成很好的innodb(事务)存储类型和高效率的myisam(非事务)存储类型,
第二种是只用于事务处理类型,最好的优化innodb,但同时也支持myisam,只有myisam才支持全文索引
最后一种是非事务处理类型,适合于简单的应用,只有不支持事务的myisam类型是被支持的。
一般选择第一种多功能的。


9 下面是选择InnodDB的数据存放位置,一般默认好了,不需要改动


10 下面是选择mysql允许的最大连接数,第一种是最大20个连接并发数,
第二种是最大500个并发连接数,最后 一种是自定义,你可以根据自己的需要选择。
Select the first one here


11The following is Select the database listening port. The default is 3306. If you change it to another port,
you must remember the modified port when you connect to the database in the future. Otherwise, you cannot connect to the mysql database.
It is too troublesome. No modifications are made here. Use the default port of mysq: 3306


12 This step settings The default encoding of mysql, the default is latin1, which is also a standard encoding


13 Of course we can change it to gb2312 or gbk as needed. Encoding was introduced in version 4.1 and above.
If you want to use the data from the original database, it is best to determine what encoding the original database uses. If the encoding set here
is inconsistent with the encoding of the original database data, garbled characters may appear when using it. It is recommended to use latin1 standard encoding


14 This step is whether to use mysql Set it as a Windows service, generally choose to set it as a service,
so that you can start and close the MySQL database through the service in the future. Recommendation: Also check the check box below,
In this way, in cmd mode. , you don’t have to go to the bin directory of mysql to execute the command. Consult the executable file on the command line


15 This step is to set the super user password of mysql. This super user is very important.
Has full permissions on mysql. Please set and remember the super user password.
Below There is a checkbox to choose whether to allow remote machines to connect to your mysql server as the root user.
If you have this requirement, please also check it.


16 点击 Execute


17 到这一步


18 我们可以开始使用mysql了,打开开始菜单的 mysql Command line Client,输入密码
出现这个界面说明mysql已经安装好了


可能出现的问题:
如果在第15步,你出现的界面是像下面这样

有三个输入密码的地方,则有可能您是在原来基础上安装的。
你在第一个文本框输入原来root的密码,后面两个文本框输入root的新密码,
点击Next基础,出现下图

给您推荐几种解决办法:
1、        点Retry,重试;
2、         再运行一次设置,看到有关“移除原设置”的选项,选择移除,然后在重新设置。
3、        重装。
重装注意事项:最好删除原来的所有文件,必要的话,可以清一下注册表,
如果你机器上没有其它mysql相关的程序。而且一定记得不要保留原有的my.ini文件。
还有就是删除原来安装路径下的文件,并删除数据目录下面的ibdata1文件.
更多文章 php爱好者站 http://www.phpfans.net

PHP 的安装

由于php是一个zip文件(非install版),安装较为简单
解压就行。把解压的 php5.1.1-Win32重命名为 php5。并复制到C盘目录下。That is, the installation path is c:php5

1 Find the php.ini-dist or php.ini.recommended file in the php directory, rename it to php.ini
and copy it to the windows directory of the system disk (Take c:windows as an example).

2 Then copy php5ts.dll and libmysql.dll in the php directory to the directory c:windowssystem32.
If libmysql.dll is not copied to system32, the following warning may appear when restarting apache


3 Copy the php_gd2.dll, php_mysql.dll, php_mbstring.dll files in the php5ext directory to c:windowssystem32
If php_gd2.dll is not loaded, php will not be able to process images . If php_mysql.dll is not loaded, php will not support the mysql function library
php_mbstring.dll will support wide characters when using phpmyadmin later

We will configure it after everything is installed

Configure php and associate MySQL
The following content can be seen only by replying to the post
========== =====================

Open the c:windowsphp.ini file

1 Set the extension path
Look for extension_dir Yes Such a line
extension_dir = "./"
Change this line to
extension_dir = "C:php5ext"
where C:php5 is the path where you installed php. If the path is incorrect, the dll will not be loaded
(Note: some PHP versions are;extension_dir = "./" and the preceding semicolon must be removed)

2 Find extension
extension=php_mbstring.dll
extension=php_gd2.dll
extension=php_mysql.dl
Remove the semicolons in front of the above three items, so that these dlls can be loaded when apache starts
Of course, we also copied these dlls to system32 is downloaded l

3 Set the session save path
Look for session.save_path and there is such a line
; Session.save_path = "N;/path"
Add a line after this line (Note that it is to add a line, not to the end)
session.save_path = "C:WINDOWSTemp"
Save it to your temporary directory. You can save it to the windows temporary directory Temp

4 It is also worth noting that short_open_tag is Off by default
That is to say, php cannot use short tags such as and must use
Due to the short tag It is easy to use, and many programs are also written with short tags, such as discuz, etc.
If you do not change short_open_tag to On, the symptoms that will appear will be difficult to determine the above reasons. It is recommended to modify
to search for
short_open_tag = Off
Change to
short_open_tag = On

5 Whether to display errors display_errors
For security reasons, display_errors also defaults to Off
That is to say, when debugging, if the php code If there is an error, only a blank page will appear. The cause of the error and the number of error lines will not be displayed.
It will be very inconvenient to debug like this. It is recommended to modify
according to your own needs. Find
display_errors = Off (note not; - display_errors = Off [Security])
Change to
display_errors = On

6 register_globals
For security reasons, it is also Off by default
When register_globals=Off, the next program should use $_POST['user_name'] and $_POST['user_pass' when receiving ])
When register_globals=On, the next program can directly use $user_name and $user_pass to accept values.
更详细的说明请参考
http://www.phpfans.net/bbs/archiver/?tid-234.htm
建议根据自己需要修改

7 php5时差问题
时间相差八小时
为什么呢?PHP5系列版本新增了时区设置,默认为格林威治时间,与中国所在的东8区正好相差8个小时
查找date.timezone有这么一行
;date.timezone =
将;去掉,改成
date.timezone = PRC
其中PRC:People's 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是你安装php的相应路径.
注意不要把php5apache2.dll和php5apache.dll混淆.php5apache.dll只适用于apache 版本1的.
注意: PHP5压缩包里的php5apache2.dll只适用于apache2.0.*版本,如果是2.2.*以上版本,就可能会出现
"Cannot load C:/php/php5apache2.dll into server: The specified module could not be found."
或者:
"The requested operation has failed"
的情况.关于这个问题的解决方法可以参考本论坛的
http://www.phpfans.net/bbs/viewt ... &extra=page%3D1

5 查找 AddType application/x-gzip .gz .tgz
在此行后加入一行
AddType application/x-httpd-php .php
这样apache就可以解释php文件了
到这里配置基本完成了

########重启apache#########

在网站根目录下创建一个 phpinfo.php 文件

phpinfo();
?>

在浏览器打开
http://localhost/phpinfo.php
如果出现如下信息,则说明php已经配置好了


下面再测试php和mysql数据库的关联
在网站根目录下创建一个test.php 文件

CODE:
[Copy to clipboard]
<font color="#000000"><font color="#0000bb"></font><font color="#007700"><?</FONT><FONT color=#0000bb>php <BR>$link</FONT><FONT color=#007700>=</FONT><FONT color=#0000bb>mysql_connect</FONT><FONT color=#007700>(</FONT><FONT color=#dd0000>"localhost"</FONT><FONT color=#007700>,</FONT><FONT color=#dd0000>"root"</FONT><FONT color=#007700>,</FONT><FONT color=#dd0000>"12345"</FONT><FONT color=#007700>); </FONT><FONT color=#ff8000>//12345改成你的mysql密码 <BR></FONT><FONT color=#007700>if(!</FONT><FONT color=#0000bb>$link</FONT><FONT color=#007700>) echo </FONT><FONT color=#dd0000>"失败!"</FONT><FONT color=#007700>; <BR>else echo </FONT><FONT color=#dd0000>"成功!"</FONT><FONT color=#007700>; <BR></FONT><FONT color=#0000bb>mysql_close</FONT><FONT color=#007700>(); <BR>?> </font><br></font>
Open http://localhost/test.php in the browser
If the output is successful, it means you are done.

Installation 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 modifications:

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

Fill in your mysql password into $ cfg['Servers'][$i]['password'] = ''; inside 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'], Set it to zh-gb2312;
4 Search $cfg['DefaultCharset'] and set it to gb2312;

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


Please familiarize yourself with the specific functions of phpMyAdmin, and I won’t go into details here.

==============================
More articles php enthusiast site http:// www.phpfans.net

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/316915.htmlTechArticleThe configuration of PHP environment is definitely a troublesome thing for novices. You will always encounter problems of one kind or another and take many detours. So I specially wrote this configuration document today. I believe it should be as follows...
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