windows下安装nginx+php+mysql多版本

1. 下载软件:本示例软件版本nginx-1.16.1+php-7.2.9+mysql-5.7.35
PHP:   https://windows.php.net/download/
Nginx: http://nginx.org/en/download.html
Mysql: https://downloads.mysql.com/archives/community/

2. 解压软件到目录:
PHP:   C:\env\php\php-7.2.9-nts-Win32-VC15-x64
Nginx: C:\env\nginx\nginx-1.16.1
Mysql: C:\env\mysql\mysql-5.7.35-winx64

3. 配置php.ini和nginx.conf:
php.ini:
extension_dir="./ext"
error_log=C:/env/php/php-7.2.9-nts-Win32-VC15-x64.log

nginx.conf:
upstream fastcgi_backend {
    server 127.0.0.1:9000;
    server 127.0.0.1:9001;
        server 127.0.0.1:9002;
        server 127.0.0.1:9003;
}
server {
        listen        80;
        server_name  localhost;
        root   html;
        location / {
            index index.php index.html;
        }
        location ~ \.php(.*)$ {
            fastcgi_pass   fastcgi_backend;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

4. start.bat批命令启动指定版本nginx,php,mysql
@echo off
set console_home=C:\env
set php_home=C:\env\php\php-7.2.9-nts-Win32-VC15-x64
set nginx_home=C:\env\nginx\nginx-1.16.1
set mysql_home=C:\env\mysql\mysql-5.7.35-winx64

REM set PHP_FCGI_CHILDREN=5
set PHP_FCGI_MAX_REQUESTS=1000

echo Starting nginx .......................
"%console_home%/RunHiddenConsole.exe" "%nginx_home%/nginx.exe" -p "%nginx_home%"
echo Start nginx success

echo Starting PHP .......................
"%console_home%/RunHiddenConsole.exe" "%php_home%\php-cgi.exe" -b 127.0.0.1:9000 -c "%php_home%\php.ini"
"%console_home%/RunHiddenConsole.exe" "%php_home%\php-cgi.exe" -b 127.0.0.1:9001 -c "%php_home%\php.ini"
"%console_home%/RunHiddenConsole.exe" "%php_home%\php-cgi.exe" -b 127.0.0.1:9002 -c "%php_home%\php.ini"
"%console_home%/RunHiddenConsole.exe" "%php_home%\php-cgi.exe" -b 127.0.0.1:9003 -c "%php_home%\php.ini"
echo Start php-cgi success

echo Starting mysql .......................
"%console_home%/RunHiddenConsole.exe" "%mysql_home%\bin\mysqld.exe"
echo Start mysql success

pause
Exit

5. stop.bat批命令停止nginx,php,mysql
stop.bat
@echo off
echo Stopping nginx...
taskkill /fi "imagename eq nginx.exe" /f> nul
echo Stop nginx success
 
echo Stopping PHP FastCGI...
taskkill /fi "imagename eq php-cgi.exe" /f> nul
echo Stop php-cgi success
 
echo Stopping mysql...
taskkill /fi "imagename eq mysqld.exe" /f> nul
echo Stop mysql success

pause

exit

DEMO

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值