Home >Backend Development >PHP Tutorial >PHP environment configuration php5 MySQL5 apache2 phpmyadmin installation and configuration graphic tutorial_PHP tutorial
So I specially wrote this configuration document. I believe you will succeed if you follow the following steps. I hope you can correct me if I have any mistakes.
This example is under wiondws XP
php5.2.1 (zip)
apache2.2.4
MySQL5.0.37
phpmyadmin2.10.0.2
ZendOptimizer-3.2.6
Installation and configuration
Apache installation
1 Click apahce installation package
2 Accept the agreement
3 Just fill in the following 3 items as you like
Apache listens to port 80. If iis uses port 80, modify the iis port or apache port to avoid conflicts
4 The default here is typical, click next.
5 You can modify the installation path here. Note that the installation path cannot contain Chinese characters.
6 Click install to start the installation
7 Installation After completion, type http://localhost or http://127.0.0.1
in the browser. If you can see this page, it proves that apache has been installed successfully. Explanation of static pages
MySQL installation
1 点击MySQL安装包
2 默认是Typical,如果想修改安装路径的话也可以选择custom.
注意:安装mysql的路径中,不能含有中文!
3 点击intall开始安装
4 跳过注册
5 是否现在就配置 MySQL.也可以之后在开始菜单的configuration wizard 进行配置.
这里是现在进行配置
6 选择Detailed Configuration(详细设置),点Next继续
7 下面这个选项是选择mysql应用于何种类型,第一种是开发服务器,
将只用尽量少的内存,第二种是普通WEB服务器,将使用中等数量内存,
最后一种是这台服务器上面只运行MySQL数据库,将占用全部的内存.
用户可根据自己的需求,选择选项.这里只选择开发服务器,点Next继续
8 下面是选择数据库用途,第一种是多功能用途,
将把数据库优化成很好的innodb(事务)存储类型和高效率的myisam(非事务)存储类型,
第二种是只用于事务处理类型,最好的优化innodb,但同时也支持myisam,只有myisam才支持全文索引
最后一种是简单的网络开发,适合于简单的应用,只有不支持事务的myisam类型是被支持的.
一般选择第一种多功能的.
9 下面是选择InnodDB的数据存放位置,一般默认好了,不需要改动
(如果要修改数据保存路径,也可用在安装后修改my.ini的datadir的值)
10 下面是选择MySQL允许的最大连接数,第一种是最大20个连接并发数,
第二种是最大500个并发连接数,最后 一种是自定义,你可以根据自己的需要选择.
这里选择第一个
11 下面是是否运行网络链接.这里选择复选框.数据库监听的端口,一般默认是3306,
如果改成其他端口,以后连接数据库的时候都要记住修改的端口,否则不能连接mysql数据库,
比较麻烦,这里不做修改,用mysq的默认端口:3306
12 这一步设置mysql的默认编码,默认是latin1,也是标准的编码.第二种是UTF8,第三种是手动设置.
编码是版本4.1以上引入的.如果要用原来数据库的数据,最好能确定原来数据库用的是什么编码,如果这里设置的编码
和原来数据库数据的编码不一致,在使用的时候可能会出现乱码.建议使用latin1标准编码
当然我们有需要的话,也可以修改它的编码(不建议).
13 这一步是是否要把mysql设置成windows的服务,一般选择设成服务,
这样以后就可以通过服务中启动和关闭mysql数据库了.推荐:下面的复选框也勾选上,
这样,在cmd模式下,不必非到mysql的bin目录下执行命令.在命令行下咨询可以执行文件
14 这一步是设置mysql的超级用户密码,这个超级用户非常重要,
对mysql拥有全部的权限,请设置好并牢记超级用户的密码,
下面有个复选框是表示创建一个匿名账号,这会使数据库系统不安全.
如果有这个需求,也请勾选.
15 Click Execute to install
16 Click finish to complete the installation
17 We can start using mysql , open the mysql Command line Client of all programs in the start menu, enter the password
When this interface appears, it means that mysql has been installed
Possible problems:
If in step 15, the following prompt appears
It is because you have installed mysql before. Some configuration files were retained when uninstalling.
Click retry to see See if it can pass. Otherwise, click cancel to exit. Then click MySQL Server Instance Config Wizard
in the start menu to reconfigure mysql
and repeat the previous operation. In step 14, the interface will appear as follows
There are three places to enter the password. You have installed mysql before.
You can enter the original root password in the first text box, and enter the new root password in the next two text boxes.
If it still doesn't work, reinstall MySQL.
Note on reinstallation: It is best to delete all the original files. If necessary, you can clear the registry.
If there are no other mysql-related programs on your machine. And be sure not to keep the original my.ini file.
The other thing is to delete the files in the original installation path and delete the ibdata1 file under the data directory.
More articles on PHP fan sitehttp://www.phpfans.net
Installation of PHP
Since php is a zip file (non-install version), the installation is relatively complicated Simply
decompress it. Rename the decompressed php-5.2.1-Win32 to php5 and copy it to the C drive directory. That is, the installation path is c:php5
1 Find php in the php directory .ini.recommended (or php.ini-dist) file, 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.
3 Copy the php_gd2.dll, php_mysql.dll and php_mbstring.dll files in the php5ext directory to c:windowssystem32
Note: Do not confuse php_mysql.dll and php_mssql.dll
If php_gd2.dll is not loaded, php will not be able to process images. Without php_mysql.dll, php will not support the mysql function library
php_mbstring.dll will be used later Support wide characters in phpmyadmin
More articles php fan sitehttp://www.phpfans.net
Installation of ZendOptimizer
Zend Optimizer uses code optimization to improve the execution speed of PHP applications. PHP programs that use Zend Optimizer execute 40% to 100% faster than those without. And some files encrypted with Zend SafeGuard must be installed with Zend Optimizer before they can run.
Note: Whether Zend Optimizer is installed or not does not affect the normal operation of php. If you find it troublesome, this step Can be omitted.
1 点击安装Zend Optimizer
2 接受协议,点击next
3 选定安装路径
4 选定apache本版,我们用的是apache2.2.4,所以这里选 apache2.x
5 选定 php.ini 的位置.我们的是在 C:\WINDOWS\ 下
6 选定apache安装路径.我们的是C:\Program Files\Apache Software Foundation\Apache2.2 .所以要修改过来
7 点击install进行安装
8 点击 是.安装程序自动完成配置和服务器重启.
9 点击 Finish 完成安装
所有东西安装完成后我们再进行配置
配置php并关联MySQL
打开c:\windows\php.ini文件
1 Set the extension path
Look for extension_dir and there is 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 = "./", you need to remove the preceding semicolon)
2 Search separately
;extension=php_mbstring.dll
;extension=php_gd2.dll
;extension=php_mysql.dll
Remove the semicolon in front of the above three items, so that these dlls can be loaded when apache starts
Be careful not to confuse ;extension=php_mysql.dl with ;extension=php_mssql.dl
Of course we also copied these dlls to system32 earlier. (Everyone noticed how to copy some dlls during the installation process. It’s loaded.
You need to load some dlls in the future, such as php_mysqli.dll, so you know how to load them)
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 adding a line, not adding it 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 Another thing worth noting is short_open_tag. Some PHP versions are Off by default.
Also That is to say, php cannot use short tags such as ?> and must use
Because short tags are easy to use, and many programs are also written with short tags, such as discuz, etc.
If If you don’t change short_open_tag to On, it will be difficult to determine whether the symptoms are due to the above reasons. It is recommended to modify
to find
short_open_tag = Off
and change it to
short_open_tag = On
5 Yes Display errors display_errors
For security reasons, some versions of display_errors also default to Off.
That is to say, during debugging, if there is an error in the PHP code, only a blank page will appear. The reason for the error and the error will not be displayed. Number of lines.
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])
and change it to
display_errors = On
6 Display NOTICE warning prompt
Although the error prompt is turned on in the fifth step, the error report is also controlled by error_reporting.
php5 turns off the NOTICE warning prompt by default. If you are debugging locally, it is recommended Open NOTICE notice.
Look for
error_reporting = E_ALL & ~E_NOTICE
and change it to
error_reporting = E_ALL
As a reminder, errors can also be controlled through error_reporting() in the program Report output, please refer to the manual for how to use it specifically.
7 register_globals
For security reasons, it is also Off by default
When register_globals=Off, the next program should use $ when receiving _POST['user_name'] and $_POST['user_pass'])
When register_globals=On, the next program can directly use $user_name and $user_pass to accept values.
For more detailed instructions, please refer to
http://www.phpfans.net/bbs/archiver/?tid-234.htm
It is recommended to modify it according to your own needs. It is not recommended to modify it here, after all, there are security risks.
8 php5 time difference problem
The time difference is eight hours
Why? The PHP5 series version has added a new time zone setting, the default It is Greenwich Mean Time, which is exactly 8 hours different from the East 8th District where China is located.
Look for date.timezone and there is such a line
;date.timezone =
Remove; and change it to
date. timezone = PRC
where PRC: People's Republic of China,
For more detailed solutions, please refer to this forum's
http://www.phpfans.net/bbs/archiver/? tid-60.html
Please refer to this forum's
http://www.phpfans.net/bbs/viewthread.php?tid= for the configuration that should be paid attention to when uploading files. 1663&extra=page%3D1
More articles php fan sitehttp://www.phpfans.net
Apache integration PHP
1 从开始菜单打开apache配置文档,如图
2 修改网站根目录
查找DocumentRoot有这么一行
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
这就是你网站的根目录,你可以修改,也可以用默认的.如果改,还要修改下面这项,否则可能会出现 403 错误
查找 This should be changed to whatever you set DocumentRoot to
在它下面两行有
把上面两项的 C:/Program Files/Apache Group/Apache2/htdocs 改成你想要的目录
3 查找 DirectoryIndex index.html
修改成
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_2.dll
(其中C:/php5/php5apache2_2.dll是你安装php的相应路径.
注意不要把php5apache2_2.dll,php5apache2.dll和php5apache.dll混淆.php5apache.dll只适用于apache 版本1的.
PHP5压缩包里的php5apache2.dll只适用于apache2.0.*版本,如果是2.2.*以上版本,必须使用php5apache2_2.dll.否则就可能会出现
"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
不过php5apache2_2.dll出来之后也就没有多少参考价值了)
5 查找 AddType application/x-gzip .gz .tgz
在此行后加入一行
AddType application/x-httpd-php .php
这样apache就可以解释php文件了
到这里配置基本完成了
########重启apache.如图,点击restart#########
在网站根目录下创建一个 phpinfo.php 文件
phpinfo();
?>
在浏览器打开
http://localhost/phpinfo.php
如果出现如下信息,则说明php已经配置好了
下面再测试php和mysql数据库的关联
在网站根目录下创建一个test.php 文件
<span style="COLOR: #000000"><span style="COLOR: #0000bb"></span><span style="COLOR: #007700"><?</SPAN><SPAN style="COLOR: #0000bb">php<BR></SPAN><SPAN style="COLOR: #ff8000">//php爱好者站 系列教程 [url]http://www.phpfans.net[/url]<BR></SPAN><SPAN style="COLOR: #0000bb">$host </SPAN><SPAN style="COLOR: #007700">= </SPAN><SPAN style="COLOR: #dd0000">"localhost"</SPAN><SPAN style="COLOR: #007700">;<BR></SPAN><SPAN style="COLOR: #0000bb">$user </SPAN><SPAN style="COLOR: #007700">= </SPAN><SPAN style="COLOR: #dd0000">"root"</SPAN><SPAN style="COLOR: #007700">;<BR></SPAN><SPAN style="COLOR: #0000bb">$password </SPAN><SPAN style="COLOR: #007700">= </SPAN><SPAN style="COLOR: #dd0000">"12345"</SPAN><SPAN style="COLOR: #007700">;</SPAN><SPAN style="COLOR: #ff8000">//12345改成你的mysql密码<BR></SPAN><SPAN style="COLOR: #0000bb">$link</SPAN><SPAN style="COLOR: #007700">=</SPAN><SPAN style="COLOR: #0000bb">mysql_connect</SPAN><SPAN style="COLOR: #007700">(</SPAN><SPAN style="COLOR: #0000bb">$host</SPAN><SPAN style="COLOR: #007700">,</SPAN><SPAN style="COLOR: #0000bb">$user</SPAN><SPAN style="COLOR: #007700">,</SPAN><SPAN style="COLOR: #0000bb">$password</SPAN><SPAN style="COLOR: #007700">); <BR>if(!</SPAN><SPAN style="COLOR: #0000bb">$link</SPAN><SPAN style="COLOR: #007700">) echo </SPAN><SPAN style="COLOR: #dd0000">"<h1>失败!</h1>"</span><span style="COLOR: #007700">;<br>else echo </span><span style="COLOR: #dd0000">"<h1>成功!</h1>"</span><span style="COLOR: #007700">;<br></span><span style="COLOR: #0000bb">mysql_close</span><span style="COLOR: #007700">();<br>?> </span><br></span>
Open http://localhost/test.php in the browser
If the output is successful, it means you are done.
More articles on PHP enthusiast site http://www.phpfans.net
Install phpMyAdmin
Download phpMyAdmin-2.10.0.2-all-languages.zip, unzip it to the root directory of your website and rename it to phpMyAdmin,
Find and open libraries/config.default.php (Some versions are config.inc.php or config.defaut.php in the current directory)
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 the single quotes
2 Search $cfg['PmaAbsoluteUri'] and set the value in the following single quotes to the phpMyAdmin directory Path, such as: http://localhost/phpMyAdmin/;
3 Search $cfg['DefaultLang'] and set the value in single quotes after it to zh-gb2312;
Modify the following encoding according to your own needs (if you are not very familiar with database coding, it is recommended not to modify it)
4 Search $cfg['DefaultCharset'] and set it to the encoding you want.
Open the browser and enter: http://localhost/phpMyAdmin/, both Apache and MySQL have been started,
If the following page appears, the phpmyadmin installation is complete and can be used
Please familiarize yourself with the specific functions of phpMyAdmin and will not go into details here.