1.准备工作
(1)PHP 版本5.6.17 下载地址 PHP官网 脚本之家 下载地址
(2)Nginx 版本1.8.0 下载地址 Nginx官网 脚本之家 下载地址
(3)MySQL 版本5.7.10 MySQL官网 脚本之家 下载地址
2.php的安装与配置
直接解压下载好的php包,到D盘wnmp目录(D:\wnmp),这里把解压出来的文件夹重命名成php5。进入文件夹修改php.ini-delelopment文件为php.ini,并用Editplus或者Notepad++打开来。找到
extension_dir = "ext" 更改为 extension_dir = "D:/wnmp/php5/ext"
常用扩展,去掉最前面的";"
extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mcrypt.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll
nginx支持配置,去掉前面";"
;cgi.fix_pathinfo=1
;cgi.force_redirect = 1
;cgi.rfc2616_headers = 0 先去前面的分号再改为 cgi.rfc2616_headers = 1
3.Nginx的安装配置
将下载的包解压到D:\wnmp,直接运行目录下nginx.exe启动。
1.启动方式有3种
(1)双击nginx.exe图标,可见黑窗口一闪而过,启动完毕。
(2)命令行到nginx目录,输入nginx启动。(注,此方式命令行窗口无任何提示,且被锁定)
(3)命令行到nginx目录,输入start nginx启动,此方式不锁定
2.修改配置支持PHP
进入nginx的conf目录,打开nginx的配置文件nginx.conf,找到
location / { root html;#这里是站点的根目录 index index.html index.htm index.php; }
将root html;改为root D:/wnmp/www;
再往下,找到
# pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #}
先将前面的“#”去掉,同样将root html;改为root D:/wnmp/www;。再把标记为红色的/scripts改为“$document_root”,这里的 “$document_root”就是指前面“root”所指的站点路径,这是改完后的:
# pass the PHP scripts to FastCGI serverlistening on 127.0.0.1:9000 # location ~ \.php$ { root D:/wnmp/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
保存配置文件,就可以了。
nginx+php的环境就初步配置好了,来跑跑看。我们可以输入命令
来启动php,并手动启动nginx,当然也可以利用脚本来实现。
首先把下载好的RunHiddenConsole.zip包解压到nginx目录内,RunHiddenConsole.exe的作用是在执行完命令行脚 本后可以自动关闭脚本,而从脚本中开启的进程不被关闭。然后来创建脚本,命名为“start_nginx.bat”。
@echooff
REMWindows 下无效
REM set PHP_FCGI_CHILDREN=5
REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
setPHP_FCGI_MAX_REQUESTS=1000
echo Starting PHPFastCGI...
RunHiddenConsole D:/wnmp/php5/php-cgi.exe -b 127.0.0.1:9000 -cD:/wnmp/php5/php.ini
echo Starting nginx...
RunHiddenConsole D:/wnmp/nginx/nginx.exe -p D:/wnmp/nginx
再另外创建一个名为stop_nginx.bat的脚本用来关闭nginx
@echooff echo Stoppingnginx... taskkill /F /IM nginx.exe > nul echo Stopping PHPFastCGI... taskkill /F /IM php-cgi.exe > nul exit
这样,我们的服务脚本也都创建完毕了。双击start_nginx.bat看看进程管理器是不是有两个nginx.exe的进程和一个php-cgi.exe的进程呢?
这样nginx服务就启动了,而且php也以fastCGI的方式运行了。
到站点目录下,新建一个phpinfo.php的文件,在里面编辑
<?php echo phpinfo();?>
保存后,打开浏览器输入“http://localhost/phpinfo.php”,如果看到
就说明,nginx+php的环境已经配置好了,呵呵~
4.MySQL安装和配置
(简略)MySQL安装下载后,一路next安装。

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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