Win10 + Nginx + MariaDB + PHP 环境搭建笔记

目录

一、软件下载

1. Nginx

2. MariaDB

3. PHP

4. Visual C++ Runtime library

5、xxfpm

6、RunHiddenConsole

二、部署与配置

1. 构建wnmp项目目录

2. 部署PHP

3. 部署Mysql

4. 部署Nginx

5、运行wnmp环境

1) 运行nginx命令

2) 运行mysql命令

3)运行xxfpm命令

4)隐藏运行xxfpm命令


一、软件下载

1. Nginx

nginx: download

2. MariaDB

Download MariaDB Server - MariaDB.org ,下载历史版本,请点击View All MariaDB Releases按钮。

3. PHP

PHP: Downloads

4. Visual C++ Runtime library

Latest supported Visual C++ Redistributable downloads | Microsoft Learn

5、xxfpm

GitHub - 78/xxfpm: FCGI Process Manager

6、RunHiddenConsole

下载地址:PHP-FastCGI on Windows | NGINX

二、部署与配置

1. 构建wnmp项目目录

在D:\目录下创建wnmp文件夹,并构建一下目录

(当时使用的mysql数据库mysql5.7.26,是从wamp下拷贝的)

将mysql(mariadb),nginx和php拷贝到wnmp目录中(其中,www为web项目目录)。

2. 部署PHP

参考: 

https://www.cnblogs.com/wwjchina/p/9804576.html

Nginx No input file specified问题解决_nginx no input file specified._b15365637的博客-CSDN博客

操作:

1)将 php.ini-development 文件拷贝一份,并修改为 php.ini。

2)安装php扩展库

如,Mcrypt:windows.php.net - /downloads/pecl/releases/,将dll文件拷贝到php/ext/目录下。

修改PHP.ini文件

; On windows:

extension_dir = "ext"

extension=curl
extension=mysqli
extension=pdo_mysql
extension=openssl
extension=mcrypt

extension=soap

3. 部署Mysql

安装MariaDB Download MariaDB Server - MariaDB.org,选择安装HeidiSQL管理工具。

或手动安装msyql服务如下:

1)打开命令窗口:快捷键win+r 键,或右键点击窗口左下角的windows图标选择运行,进入运行窗口。在输入框中输入cmd回车,打开终端命令窗口。

2)cd 到bin目录下,执行命令 mysqld -install,添加MySQL服务。自定义服务名时,请输入 mysqld -install 自定义名如mariadb。

3)移除mysql服务:mysqld --remove mysql,服务名不区分大小写。

4)管理服务使用sc命令,若 sc query mysql, 查看mysql服务是否开启。

服务管理全靠它:sc命令一键搞定!https://baijiahao.baidu.com/s?id=1773379911412224285&wfr=spider&for=pc

4. 部署Nginx

Nginx.conf


#user  nobody;
worker_processes auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
	multi_accept on;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  180;

    #gzip  on;
	
	map $http_upgrade $connection_upgrade {
	  default upgrade;
	  ''   close;
	}
	upstream websocket {
	  #ip_hash;
	  server localhost:8888; 
	}

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening 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;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
	
	include D:/wnmp/nginx-1.18.0/conf/local/*.conf;


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

D:\wnmp\nginx-1.18.0\conf\local\laundry.conf

server {
	listen 80;
	server_name  my.laundry.com;
	root D:/wnmp/www/laundry_portal;
	index index.php index.html index.htm;
	
	location / {
		try_files $uri $uri/ /index.php$is_args$args;
		autoindex on;
	}

	location ~ \.php$ {
		try_files $uri /index.php =404;
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;
	}
	
	location ~ /\.ht {
		deny all;
	}
}

server {
	listen 5006;
	server_name  my.laundry.com;
	root D:/wnmp/www/value_code;
	index index.php index.html index.htm;
	
	location / {
		try_files $uri $uri/ /index.php$is_args$args;
		autoindex on;
	}

	location ~ \.php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;
	}
	
	location ~ /\.ht {
		deny all;
	}
}

server {
	listen 5007;
	server_name  my.laundry.com;
	root D:/wnmp/www/reporting_service;
	index index.php index.html index.htm;
	
	location / {
		try_files $uri $uri/ /index.php$is_args$args;
		autoindex on;
	}

	location ~ \.php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;
	}
	
	location ~ /\.ht {
		deny all;
	}
}

5、运行wnmp环境

1) 运行nginx命令

nginx.exe -s quit
nginx.exe -s start
nginx.exe -s reload

2) 运行mysql命令

//添加服务,默认为mysql
mysqld -install
mysqld --install MariaDB

//启动或停止服务,也可以使用win10工具
//在我的电脑上,单击右键->管理,
//选择服务与应用程序->服务。
//寻找到添加过的服务如mysql,点击右键,选择启动或停止。
net start mysql
net stop mysql

//删除服务
mysqld --remove mysql
mysqld --remove MariaDB

3)运行xxfpm命令

进入D:\xnmp\xxfpm\bin目录下,按住Shift+右键选择打开Power Shell窗口,

D:\xnmp\xxfpm\bin> .\xxfpm "D:\xnmp\php-7.3.27\php-cgi.exe  -b 127.0.0.1:9000 -c D:\xnmp\php-7.3.27\php.ini" -n 6 -i 127.0.0.1 -p 9000

4)隐藏运行xxfpm命令

xxfpm+nginx setup.bat

@echo off
set php_path=./php-7.3.27
set xxfpm_path=./xxfpm/bin
set nginx_path=./nginx-1.18.0

REM Windows 下无效
REM set PHP_FCGI_CHILDREN=5

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=100
echo Starting PHP FastCGI...
RunHiddenConsole %xxfpm_path%\xxfpm.exe "%php_path%\php-cgi.exe  -b 127.0.0.1:9000 -c %php_path%\php.ini" -n 6 -i 127.0.0.1 -p 9000

echo Starting Nginx...
RunHiddenConsole %nginx_path%/nginx.exe -p %nginx_path%

xxfpm+nginx quit.bat

@echo off
echo Stopping Nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
taskkill /F /IM xxfpm.exe > nul
exit

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值