


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

PHP remains a powerful and widely used tool in modern programming, especially in the field of web development. 1) PHP is easy to use and seamlessly integrated with databases, and is the first choice for many developers. 2) It supports dynamic content generation and object-oriented programming, suitable for quickly creating and maintaining websites. 3) PHP's performance can be improved by caching and optimizing database queries, and its extensive community and rich ecosystem make it still important in today's technology stack.

In PHP, weak references are implemented through the WeakReference class and will not prevent the garbage collector from reclaiming objects. Weak references are suitable for scenarios such as caching systems and event listeners. It should be noted that it cannot guarantee the survival of objects and that garbage collection may be delayed.

The \_\_invoke method allows objects to be called like functions. 1. Define the \_\_invoke method so that the object can be called. 2. When using the $obj(...) syntax, PHP will execute the \_\_invoke method. 3. Suitable for scenarios such as logging and calculator, improving code flexibility and readability.

Fibers was introduced in PHP8.1, improving concurrent processing capabilities. 1) Fibers is a lightweight concurrency model similar to coroutines. 2) They allow developers to manually control the execution flow of tasks and are suitable for handling I/O-intensive tasks. 3) Using Fibers can write more efficient and responsive code.

The PHP community provides rich resources and support to help developers grow. 1) Resources include official documentation, tutorials, blogs and open source projects such as Laravel and Symfony. 2) Support can be obtained through StackOverflow, Reddit and Slack channels. 3) Development trends can be learned by following RFC. 4) Integration into the community can be achieved through active participation, contribution to code and learning sharing.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version
Chinese version, very easy to use