


Detailed explanation of win7+apache+php+mysql environment configuration operations_PHP tutorial
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
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
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
$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
mysql_query("set names utf8");
can solve Chinese garbled characters

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

C language functions are the basis for code modularization and program building. They consist of declarations (function headers) and definitions (function bodies). C language uses values to pass parameters by default, but external variables can also be modified using address pass. Functions can have or have no return value, and the return value type must be consistent with the declaration. Function naming should be clear and easy to understand, using camel or underscore nomenclature. Follow the single responsibility principle and keep the function simplicity to improve maintainability and readability.

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

Detailed explanation of XPath search method under DOM nodes In JavaScript, we often need to find specific nodes from the DOM tree based on XPath expressions. If you need to...

Although C and C# have similarities, they are completely different: C is a process-oriented, manual memory management, and platform-dependent language used for system programming; C# is an object-oriented, garbage collection, and platform-independent language used for desktop, web application and game development.

In PHP, you can effectively prevent CSRF attacks by using unpredictable tokens. Specific methods include: 1. Generate and embed CSRF tokens in the form; 2. Verify the validity of the token when processing the request.

C language functions are reusable code blocks. They receive input, perform operations, and return results, which modularly improves reusability and reduces complexity. The internal mechanism of the function includes parameter passing, function execution, and return values. The entire process involves optimization such as function inline. A good function is written following the principle of single responsibility, small number of parameters, naming specifications, and error handling. Pointers combined with functions can achieve more powerful functions, such as modifying external variable values. Function pointers pass functions as parameters or store addresses, and are used to implement dynamic calls to functions. Understanding function features and techniques is the key to writing efficient, maintainable, and easy to understand C programs.

The... (splat) operator in PHP is used to unpack function parameters and arrays, improving code simplicity and efficiency. 1) Function parameter unpacking: Pass the array element as a parameter to the function. 2) Array unpacking: Unpack an array into another array or as a function parameter.
