Laravel Homestead

https://laravel.com/docs/12.x/homestead#introduction

 

查看php版本

sudo update-alternatives --config php

 

2. nginx 是否运行:

sudo service nginx status

如果没运行:

 
sudo service nginx restart

3. php7.1-fpm 是否运行:

sudo service php7.1-fpm status

如果没运行:

sudo service php7.1-fpm restart
 
 
创建nginx配置文件

sudo vim/etc/nginx/sites-available/homestead.test

server {
listen 80;
server_name homestead.test;
root /home/vagrant/code/public;

index index.php index.html index.htm;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}

location ~ /\.ht {
deny all;
}
}

然后启用这个站点:

sudo ln -s /etc/nginx/sites-available/homestead.test /etc/nginx/sites-enabled/
 

步骤 3:测试 nginx 配置是否正确

sudo nginx -t
 

输出应该是:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
 
然后重启 nginx:
sudo service nginx restart
 
这样就可以访问了
 
 

1. 切换当前默认的 PHP 版本到你想用的,比如 8.2

sudo update-alternatives --set php /usr/bin/php8.2
sudo update-alternatives --set phpize /usr/bin/phpize8.2
sudo update-alternatives --set php-config /usr/bin/php-config8.2

切换后,确认版本:

 
php -v
phpize -v
php-config --version
 
 

 

posted @ 2025-06-25 09:41  胡良庆  阅读(5)  评论(0)    收藏  举报