win平台安装配置Nginx+php+mysql 环境_php实例
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安装。

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

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











session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.

To safely and thoroughly uninstall MySQL and clean all residual files, follow the following steps: 1. Stop MySQL service; 2. Uninstall MySQL packages; 3. Clean configuration files and data directories; 4. Verify that the uninstallation is thorough.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json file. 1) parse composer.json to obtain dependency information; 2) parse dependencies to form a dependency tree; 3) download and install dependencies from Packagist to the vendor directory; 4) generate composer.lock file to lock the dependency version to ensure team consistency and project maintainability.

Installing MySQL on macOS can be achieved through the following steps: 1. Install Homebrew, using the command /bin/bash-c"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". 2. Update Homebrew and use brewupdate. 3. Install MySQL and use brewinstallmysql. 4. Start MySQL service and use brewservicesstartmysql. After installation, you can use mysql-u

Use the EXPLAIN command to analyze the execution plan of MySQL queries. 1. The EXPLAIN command displays the execution plan of the query to help find performance bottlenecks. 2. The execution plan includes fields such as id, select_type, table, type, possible_keys, key, key_len, ref, rows and Extra. 3. According to the execution plan, you can optimize queries by adding indexes, avoiding full table scans, optimizing JOIN operations, and using overlay indexes.
