Table of Contents
win+Nginx+php+mysql 环境配置,nginxmysql
Home php教程 php手册 win+Nginx+php+mysql 环境配置,nginxmysql

win+Nginx+php+mysql 环境配置,nginxmysql

Jun 13, 2016 am 08:48 AM
nginx

win+Nginx+php+mysql 环境配置,nginxmysql

 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”。

  

@<span>echooff
REMWindows 下无效
REM set PHP_FCGI_CHILDREN</span>=5<span>

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
setPHP_FCGI_MAX_REQUESTS</span>=1000<span>
 
echo Starting PHPFastCGI...
RunHiddenConsole D:</span>/wnmp/php5/php-cgi.exe -b 127.0.0.1:9000 -cD:/wnmp/php5/php.ini
Copy after login

<span>echo Starting nginx...
RunHiddenConsole D:</span>/wnmp/nginx/nginx.exe -p D:/wnmp/<span>nginx

再另外创建一个名为stop_nginx.bat的脚本用来关闭nginx

</span>@<span>echooff
echo Stoppingnginx...  
taskkill </span>/F /IM nginx.exe ><span> nul
echo Stopping PHPFastCGI...
taskkill </span>/F /IM php-cgi.exe ><span> nul
exit</span>
Copy after login

  这样,我们的服务脚本也都创建完毕了。双击start_nginx.bat看看进程管理器是不是有两个nginx.exe的进程和一个php-cgi.exe的进程呢?

这样nginx服务就启动了,而且php也以fastCGI的方式运行了。

到站点目录下,新建一个phpinfo.php的文件,在里面编辑

  phpinfo();?>

  保存后,打开浏览器输入“http://localhost/phpinfo.php”,如果看到

  就说明,nginx+php的环境已经配置好了,呵呵~

4.MySQL安装和配置

   (简略)MySQL安装下载后,一路next安装。

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
How to configure nginx in Windows How to configure nginx in Windows Apr 14, 2025 pm 12:57 PM

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to start containers by docker How to start containers by docker Apr 15, 2025 pm 12:27 PM

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to check the name of the docker container How to check the name of the docker container Apr 15, 2025 pm 12:21 PM

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to check whether nginx is started How to check whether nginx is started Apr 14, 2025 pm 01:03 PM

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to create containers for docker How to create containers for docker Apr 15, 2025 pm 12:18 PM

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

How to configure cloud server domain name in nginx How to configure cloud server domain name in nginx Apr 14, 2025 pm 12:18 PM

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to check nginx version How to check nginx version Apr 14, 2025 am 11:57 AM

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

What to do if nginx server is hung What to do if nginx server is hung Apr 14, 2025 am 11:42 AM

When the Nginx server goes down, you can perform the following troubleshooting steps: Check that the nginx process is running. View the error log for error messages. Check the syntax of nginx configuration. Make sure nginx has the permissions you need to access the file. Check file descriptor to open limits. Confirm that nginx is listening on the correct port. Add firewall rules to allow nginx traffic. Check reverse proxy settings, including backend server availability. For further assistance, please contact technical support.

See all articles