一、PHP 安装及配置

1、下载地址:https://windows.php.net/download

2、重名名 php-ini-developmend 为 php.ini 并打开修改如下:

# 开启 Zlib 压缩
zlib.output_compression = On
# Zlib 压缩等级
zlib.output_compression_level = 5

# 超时时间
max_execution_time = 3600
max_input_time = 3600

# 使用的内存大小
memory_limit = 128M

# 上传文件大小
post_max_size = 100M
upload_max_filesize = 1000M

# 扩展目录
extension_dir = "D:\Web\php\ext"

# 按需取消 ; 注释
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=mbstring
extension=mysqli
extension=pdo_mysql
extension=xmlrpc

# 时区
date.timezone = Asia/Shanghai

# 开启 opcache
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.max_wasted_percentage=5
opcache.use_cwd=0
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=0
opcache.enable_file_override=1
opcache.file_cache=D:\Web\opcache

3、利用 WinSW 将 PHP 注册为服务:

WinSW Github:https://github.com/winsw/winsw/releases

下载后重命名 php-service.exe 放到 PHP 根目录,并新建 php-service.xml 内容如下:

<service>
 <id>php</id>
 <name>php</name>
 <description>php server</description>
 <executable>D:\Web\php\php-cgi.exe</executable>
 <arguments>-b 127.0.0.1:9000 -c php.ini</arguments>
 <logmode>rotate</logmode>
</service>

二、MariaDB 安装及配置

1、下载地址:https://downloads.mariadb.org/mariadb/

2、将 MariaDB 注册为服务并设置 root 密码:
.\mysql_install_db.exe --datadir=D:\Web\data --service=mariadb --passeord=123456

3、启动停止 MariaDB 命令:

net start mariadb
net stop mariadb

三、Nginx 安装及配置

1、下载地址:http://nginx.org/en/download.html

2、编辑 nginx.conf:

#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;

events {
    worker_connections  2048;
}

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  120;

    gzip  on;
    gzip_proxied any;
    gzip_min_length 1k;
    gzip_comp_level 4;
    gzip_buffers 4 16k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include D:/Web/nginx/conf/conf/*.conf;
}

3、利用 WinSW 将 Nginx 注册为服务:

下载后重命名 nginx-service.exe 放到 Nginx 根目录,并新建 nginx-service.xml 内容如下:

<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <env name="path" value="D:\Web\nginx"/>
  <executable>D:/Web/nginx/nginx.exe</executable>
  <arguments>-p D:/Web/nginx</arguments>
  <logpath>D:/Web/nginx/logs/</logpath>
  <logmode>roll</logmode>
</service>

接着运行 CMD 输入 .\nginx-service.exe install

4、Nginx 调用 PHP:

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;
}
Last modification:August 9th, 2020 at 01:50 pm
如果觉得我的文章对你有用,请随意赞赏