php-手动搭建windows的php和nginx、phpmyadmin环境
手动搭建windows的php和nginx环境
- 背景
- 下载地址
- 具体步骤
- 参考
背景
由于某种原因,只能手动搭建php的开发环境,因此就有了这篇文章
下载地址
- php
官网:https://windows.php.net/downloads/releases/archives/
csdn下载:https://download.csdn.net/download/xjhaoya/9533113?spm=1003.2122.3001.6634.19 - nginx
https://blog.csdn.net/GyaoG/article/details/124081770 - WinSW(如果安装多进程请参考)
https://github.com/winsw/winsw/releases/tag/v2.12.0
https://blog.csdn.net/a1513049385/article/details/88395286
具体步骤
- 下载好php包
- 将php包目录下的php.ini-development文件,将其复制一份命名为php.ini
- 修改php.ini内容
extension_dir = "ext"
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_openssl.dll
- 启动php-cgi
php-cgi.exe -b 127.0.0.1:9000 - 下载nginx的包
- 打开nginx.conf修改php程序的目录
server {
listen 8088;
server_name localhost;
index index.html index.php index.htm default.php default.htm default.html;
root D:\\jm\\co\\co1\\yoshop2.0\\public;
include D:\\jm\\nginx-1.10.3\\nginx-1.10.3\\conf\\rewrite.conf;
}
rewrite.conf
location ~* (runtime|application)/{
return 403;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
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;
}
-
启动nginx
进入nginx解压的目录,执行如下命令启动
nginx.exe
进入nginx解压的目录,执行如下命令停止nginx
nginx.exe -s stop -
安装phpmyadmin
8.1 下载地址
官网下载即可
https://www.phpmyadmin.net/license/
8.2 在nginx的配置文件中加上一个server就可以了
server {
listen 8087;
server_name localhost;
index index.html index.php index.htm default.php default.htm default.html;
root D:\\jm\phpMyAdmin-5.2.1-all-languages\\phpMyAdmin-5.2.1-all-languages;
include D:\\jm\\nginx-1.10.3\\nginx-1.10.3\\conf\\rewrite.conf;
}
8.3 配置
进入到phpmyadmin解压包目录phpMyAdmin-5.2.1-all-languages\libraries,找到config.default.php,设置如下参数
$cfg['PmaAbsoluteUri'] = 'localhost:8087';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root用户密码';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
8.4 重启nginx然后方位http://127.0.0.1:8087就可以了
参考
https://www.php.cn/faq/537691.html