1.在入口文件index.php里写入phpinfo();看一下php版本
修改homestead 版本 ,需要php所在的位置(可以使用phpinfo(),如何使用不再赘述,作为一个phper,请自行查找,或者是在vagrant ssh后输入ps -ef |grep php-fpm可以查看)
2.在终端中输入 vagrant up 成功后通过vagrant ssh进入命令行
(1)cd xxxx (xxxx 是php目录 博主的在etc/php)
(2)ls 可以看到博主的php版本有 5.6 7.0 7.1 7.2 7.3 7.4
(3)cd /etc/nginx/sites-available 查看虚拟机信息
(4) sudo vi shop.test 去编辑 配置文件
server {
listen 80;
listen 443 ssl http2;
server_name .shop.test;
root "/home/vagrant/code/laravel-shop/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/shop.test-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
ssl_certificate /etc/nginx/ssl/shop.test.crt;
ssl_certificate_key /etc/nginx/ssl/shop.test.key;
}
我们修改的地方是配置文件里fastcgi_pass unix后面的PHP版本 本人修改为php7.4
按键盘上的i进入修改,修改完按esc退出 :wq 退出并保存,记得重启ngnix
输入 vagrant provision && vagrant reload 重启之后再看如下图php版本切换为7.4了