下载下来到终于看到默认的界面,持续两天,记录一下过程与遇到的问题。
第一天:下载、Composer使用、多版本PHP安装
1. 下载
最开始不知道composer安装的,直接从git上面拉的代码:
git clone https://github.com/laravel/laravel.git
下载下来怎么用还是一头雾水,直接放在Apache的DocumentRoot目录,浏览器打开看看。报错:laravel\public/../vendor/autoload.php找不到。最后知道要用composer安装依赖包。
2. Composer使用
composer之前就已经安装了,但基本没有使用过。不过现在不用安装composer了,直接在laravel代码目录中执行:
composer update
遇到第一个问题:
卡在
Loading composer repositories with package information
不动了,等很久有提示但没有记录。
查到composer模式是从官网下载资料,换国内源:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
重试遇到第二个问题:
PHP版本不对,提示
This package requires php ^7.2.5 but your PHP version (5.6.29) does not satisfy that requirement.
一顿操作下载配置完 PHP 7.4.6
继续重试第三个问题:
[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl ex
tension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.
这个只是php.ini里面的
extension=openssl
打开即可
继续重试终于可以了
3. 多版本PHP安装
上面遇到第二个问题时,是因为PHP版本不对,但本地环境PHP5.6还有用,还得保留,所以不能替换掉现有版本。
方案是启动两个apache服务,一个用PHP5.6,一个用PHP7.4。用nginx做反向代理,根据域名不同转发到不同的apache服务的端口。
3.1. 下载并解压php-7.4.6
3.2. 配置和安装新的apache服务
apache的conf目录下复制一个httpd.conf,改为httpd-php7.conf,修改这三行:
LoadModule php7_module "D:/php-7.4.6/php7apache2_4.dll" LoadFile "D:/php-7.4.6/php7ts.dll" PHPIniDir "D:/php-7.4.6/"
另外修改DocumentRoot与相应的
再改掉Listen的端口和ErrorLog、
然后安装服务:
httpd -k install -n Apache2.4-PHP7.2 -f "D:\Apache24\conf\httpd-php-7.conf"
3.3. 设置nginx反向代理
注释掉默认的server节,添加两个分别指向两个apache的服务端口:
server {
listen 80;
server_name localhost local.test56.com;
location / {
proxy_pass http://127.0.0.1:88;
index index.html index.htm index.php;
}
}
server {
listen 80;
server_name local.test74.com;
location / {
proxy_pass http://127.0.0.1:89;
index index.html index.htm index.php;
}
}