2

Web 开发环境配置与升级

 3 years ago
source link: http://misaka.im/index.php/archives/49/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Web 开发环境配置与升级

2019.08.03默认分类 0 评

本文适用于 :

  1. 新系统中 Web 开发环境丢失的情况
  2. 更新开发环境中的 PHP/Mysql 版本

恢复开发环境

自发布篇文章大半年后,又因为手贱弄坏了 Windows 系统。现在重写这个章节,修改疏漏的地方。

PHP/Mysql

首先 phpstudy 是已存在硬盘上,管理员权限打开,以系统服务的模式运行。

php-cgi.exe 提示缺少 VCRUNTIME140.dll

mysqld.exe 提示缺少 MSVCR120.dll

使用 3DM GAME 游戏运行库把所有 Microsoft Visual C++ 和 Microsoft .NET Framework 安装一遍。

windows 10 也会提示你需要安装以下 Windows 功能:.NET Framework 3.5 ,选择下载安装,完成后无需重启,也能使用。

命令行环境

不清楚 phpstudy 是怎么处理切换版本后动态切换环境变量的,长期使用一个版本的 PHP 话可以设置成环境变量 E:\phpStudy\php\php-7.2.21-nts

>php -v
PHP 7.2.21 (cli) (built: Jul 30 2019 13:09:38) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

临时解决方式是打开 phpstudy - cmd 命令行,这里可以执行 php 命令,切换到项目下使用。

Composer

使用Composer-Setup.exe 重新安装一遍 Composer 到 PHP 目录

在项目下设置好 composer 的加速镜像

cd E:\phpStudy\WWW\laravel-simple

composer config repo.packagist composer https://mirrors.aliyun.com/composer/
#composer config --unset repos.packagist

composer update

从官网下载 windows 版本的 PHP ,目前是 PHP 7.2.21

解压到 phpStudy\php 目录下,复制一份 php.ini-development 作为 php.ini

打开 php.ini ,取消 On windows 下面的 extension_dir 的注释

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
;extension_dir = "./"
; On windows:
extension_dir = "ext"

并搜索 extension= 开启一些常用的扩展

PHP 7.3.8 存在向下不兼容的问题:

composer 里的 swith 语句瞬间爆炸,使用 composer self-update 来解决。

保险起见选择了 7.2

Composer

这个家伙简直就像 npm 一样难缠

这里下载一个 PEM 证书,免得使用 composer 时候会出现安全报错的问题

The openssl extension is required for SSL/TLS protection but is not available. 
If you can not enable the openssl exension, you can disable this error,
at your own risk, by setting the 'disable-tls' option to true.

开启 openssl 并指定证书的绝对地址

composer config -g -- disable-tls true
extension=openssl
[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
openssl.cafile=E:\phpStudy\php\php-7.2.21-nts\cacert.pem

self-update 出现证书验证失败的问题,干脆自己来升级好了

  [RuntimeException]
  SHA384 is not supported by your openssl extension, could not verify the phar file integrity

根据文档描述粘贴几行代码就安装好最新的 composer,要什么 self-update !

MySQL

开启 PHP 模块:

extension=pdo_firebird
extension=pdo_mysql

连接数据库时报错:

ERROR 1146 (42S02): Table 'performance_schema.session_variables' doesn't exist

参考 Windows 下更新 MySQL 至 5.7.22 中再配置环境变量

修改 mysql ini ,添加下面几行得以连接数据库。

#cannot select database
show_compatibility_56 = ON
performance_schema

这里没有做重新安装的流程,先备份数据再可以重做配置。

https://www.php.net/manual/en/migration73.incompatible.php

https://stackoverflow.com/questions/54184707/warning-continue-targeting-switch-is-equivalent-to-break-did-you-mean-to-u

https://www.jianshu.com/p/dea53f940169

https://curl.haxx.se/docs/caextract.html

composer

https://getcomposer.org/download/

https://laravelacademy.org/post/19806.html

https://developer.aliyun.com/composer

https://www.jianshu.com/p/181719a291ae

MySQL

https://blog.csdn.net/qq1069006993/article/details/77814816

https://stackoverflow.com/questions/31967527/table-performance-schema-session-variables-doesnt-exist

https://www.cnblogs.com/Bccd/p/5987426.html


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK