Home > Backend Development > PHP Tutorial > Detailed explanation of win7+apache+php+mysql environment configuration operations_PHP tutorial

Detailed explanation of win7+apache+php+mysql environment configuration operations_PHP tutorial

WBOY
Release: 2016-07-21 15:06:54
Original
1012 people have browsed it

1.php版本简介
php各版本之间的区别,php版本后面一般有VC6和VC9、Thread Safe和Non Thread Safe的区别,VC6就是legacy Visual Studio 6 compiler,就
是使用这个编译器编译的,VC9就是the Visual Studio 2008 compiler,就是用微软的VS编辑器编译的,如果你选用的是Apache或者其他服务软
件,那么选择VC6,选用的是IIS的话,那么请下载VC9 的。Thread Safe 是线程安全,而Non Thread Safe就是非线程安全, 官方并不建议你将
Non Thread Safe 应用于生产环境,所以一般选择Thread Safe版本的下载就可以了。下载Zip包就可以了。

2.php下载,选择哪个版本
下载地址http://windows.php.net/download/,笔者选择的是php-5.3.16-Win32-VC9-x86.zip
(1)如果用的是apache1或apache2,请选择vc6版的php
(2)如果用的是IIS,你应该选择VC9版的PHP
VC6的版本是用Visual Studio 6编译的,VC9是用Visual Studio 2008编译的,提升了性能和稳定性,VC9版本需要安装Microsoft 2008 C++ 
Runtime,下载地址http://www.microsoft.com/en-us/download/details.aspx?id=29,或者安装VC10,下载地址 
http://www.microsoft.com/download/en/details.aspx?id=8328

3.下载和安装apache
(1)下载地址http://httpd.apache.org/download.cgi,笔者下载的是httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
(2)apache安装:
在这里主要配置
Network Domain:yourdomain.com
Server Name:www.yourdomain.com
Email:username@126.com
Apache服务的占用端口,默认为80端口,你可以根据需要配置在其他端口,Apache的安装目录你可以使用默认目录或根据需要自行选择安装目录
在完成apache服务的安装后,在游览器中输入http://localhost/,出现It's work!字样,说明Apache服务安装成功了。
(3)如果启动apache时,报了“(OS 10013)以一种访问权限不允许的方式做了一个访问套接字的尝试。 : make_sock: could not bind to 
address 0.0.0.0:80”的错误。
用netstat -ano查看80端口已被占用,通常80端口会被IIS占用。
(4)解决方法:打开Apache安装目录\conf\httpd.conf文件,需要修改listen 80--》listent 88
(5)在浏览器里输入http://localhost:88即可
(6)如果启动apache出错“httpd.exe: Could not reliably determine the server's fully qualified domain name, using 192.168.1.111 
for ServerName”是因为DNS没配置好. 如果不想配置DNS, 就在httpd.conf中去掉ServerName前的#,修改为 ServerName 127.0.0.1:88

4.php的安装和配置
(1)将php-5.3.16-Win32-VC9-x86.zip解压至d:\php
(2)php.ini-development配置文件重命名为php.ini
(3)打开php.ini文件,找到如下文本
; On windows:
; extension_dir = "ext"
去掉extension_dir前的“;”,修改为extension_dir = "D:/php/ext" 表示指定PHP扩展包的具体目录,以便调用相应的DLL文件。
(4)由于默认PHP并不支持自动连接Mysql,需开启相应的扩展库功能,比如php_mysql.dll等,找到如下dll文本,去掉前面的";"
extension=php_curl.dll
extension=php_gd2.dll
extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
extension=php_pdo_odbc.dll
extension=php_xmlrpc.dll
(5)配置php的session功能
在使用session功能时,我们必须配置session文件在服务器上的保存目录,否则无法使用session,我们需要在Windows 7上新建一个可读写的目
录文件夹,此目录最好独立于WEB主程序目录之外,此处我在D盘根目录上建立了phpsessiontmp目录,然后在php.ini配置文件中找到
;session.save_path = "/tmp"
修改为
session.save_path = "D:/phpsessiontmp"
(6)配置PHP的文件上传功能
同session一样,在使用PHP文件上传功能时,我们必须要指定一个临时文件夹以完成文件上传功能,否则文件上传功能会失败,我们仍然需要在
Windows 7上建立一个可读写的目录文件夹,此处我在D盘根目录上建立了phpfileuploadtmp目录,然后在php.ini配置文件中找到
;upload_tmp_dir =
修改为

upload_tmp_dir = "D:/phpfileuploadtmp"
php默认上传文件大小为2M,
upload_max_filesize = 2M,可以根据自己的要求将其修改为
upload_max_filesize = 8M

(7) Time zone setting
Modify date.timezone, otherwise the date part will report an error when executing phpinfo: Warning: phpinfo() [function.phpinfo]…, find
;date.timezone in the php.ini configuration file =
modified to
date.timezone = Asia/Shanghai

5. Configure Apache to support PHP, so you also need to complete the corresponding PHP configuration in the Apache configuration file
(1)Open d:/apache/modules/mod_vhost_alias.so
Add under #LoadModule vhost_alias_module
LoadModule php5_module "c:/php/php5apache2_2.dll"
PHPIniDir "c:/php"
AddType application/x-httpd-php .php .html .htm
We can see multiple php5apache DLL files in the PHP directory. Since we are using Apache2.2.15, of course we need to use php5apache2_2. dll, and then specify the installation directory of
PHP and the extension of the executed program.
(2) Open apache's httpd.conf again and modify DocumentRoot
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
to
DocumentRoot "D:/PHPWeb "
(3) Modify Directory

Modify to

(4) Modify the specific order of index files. Since the PHP function is configured, of course index.php needs to be executed first.
DirectoryIndex index.html
is modified to
DirectoryIndex index.php index .html
(5) Enable support for rewrite module
#LoadModule rewrite_module modules/mod_rewrite.so Remove the preceding # and change
to LoadModule rewrite_module modules/mod_rewrite.so

6. Restart the Apache server
At this point, the PHP environment configuration on the Apache server is completed. You only need to create a new PHP file in the D:/PHPWeb directory and write
Copy Code The code is as follows:

phpinfo();
?>

Then in the browser Enter http://localhost:88, and you will see the specific configuration page of PHP, which means that the PHP environment configuration work on Window 7 is completed.

7. Test database connection
Create new testdb.php

Copy the code The code is as follows:

$connect=mysql_connect("127.0.0.1","root","**");
if(!$connect)
echo "Mysql Connect Error!" ;
else
echo "db connect Hello";
mysql_close();
?>

If Chinese garbled characters appear, modify the php.ini configuration default_charset = "utf-8"

8. If your above configuration is too complicated, you can use wamp foolproof installation package, download address http://www.wampserver.com
Because WAMPSERVER (32 BITS & PHP 5.3 ) Included in 2.2E

Apache 2.2.22 – Mysql 5.5.24 – PHP 5.3.13 XDebug 2.1.2 XDC 1.5 PhpMyadmin 3.4.10.1 SQLBuddy 1.3.3 webGrind 1.0

The author used wamp on my computer and found that although UTF-8 was still garbled in the settings when creating databases and tables in PhpMyadmin, the solution was to add

after mysql_connect() Copy Code The code is as follows:

mysql_query("set names utf8");

can solve Chinese garbled characters

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327584.htmlTechArticle1. PHP version introduction The differences between PHP versions. PHP versions generally include VC6, VC9, and Thread Safe The difference from Non Thread Safe is that VC6 is the legacy Visual Studio 6 compiler, which uses this...
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template