{% note info:: 注意哦~ 这不是官方方法,仅是我这个菜鸟摸索出来的较为方便的一种安装方式。%}
下载源文件
有两种方法,一是clone dev分支一是者下载完后上传。
结果都是一样的,为了尽量对菜鸟友好,咱们这里选择直接在Github下载dev分支的zip包。
环境搭建
宝塔
首先准备好宝塔。没有宝塔的同学请
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
安装PHP
安装PHP
在宝塔的软件商店
中搜索PHP,找到 PHP-8.1
安装。(PHP>=8.0.2均可)
安装插件
点击PHP-8.1的设置,点击安装拓展,安装 fileinfo
和 imagemagick
。
删除禁用函数
依旧是PHP设置页面,点击禁用函数,删除 readlink
、 symlink
两项。
部署兰空
释放文件
在宝塔中新建网站,记得选择PHP81。
上传之前下载好的压缩包并解压。
安装依赖
通过SSH或其他方式登录到服务器。
cd /www/wwwroot/lsky.example.com
sudo composer install
记得将
lsky.example.com
改成你的网站所在目录 之后通过宝塔将lsky.example.com
目录下所有文件的权限改为755
。我chmod没能成功更改,不清楚什么情况。
设置访问
- 设置网站的运行目录为
public
。 - 配置Rewrite规则:
- 宝塔自带Laravel5的伪静态规则,使用即可。
- Nginx:
location / { try_files $uri $uri/ /index.php$is_args$query_string; }
- Apache: 直接使用
.htaccess
即可,无需配置。
完成
访问,根据页面提示安装即可。
其他
以下是Windows下WSL2部署失败记录
我的环境是Windows+WSL2+Docker
{% folding 点击展开 %}
安装PHP8
启用软件仓库PPA:
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
安装
sudo apt update
sudo apt install php8.1
初始化一个文件
curl -s "https://laravel.build/lsky-pro" | bash
cd lsky-pro
./vendor/bin/sail up
直接这样运行访问是会报错的: Target class does not exit.
安装依赖
安装omposer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
安装必要插件,否则 composer install
会报一堆错
记得要php composer.phar install
。
{% folding 点击展开报错 %}
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires PHP extension ext-zip * but it is missing from your system. Install or enable PHP's zip extension.
Problem 2
- alibabacloud/client is locked to version 1.5.31 and an update of this package was not requested.
- alibabacloud/client 1.5.31 requires ext-simplexml * -> it is missing from your system. Install or enable PHP's simplexml extension.
Problem 3
- aws/aws-sdk-php is locked to version 3.209.30 and an update of this package was not requested.
- aws/aws-sdk-php 3.209.30 requires ext-simplexml * -> it is missing from your system. Install or enable PHP's simplexml extension.
Problem 4
- overtrue/qcloud-cos-client is locked to version 1.0.2 and an update of this package was not requested.
- overtrue/qcloud-cos-client 1.0.2 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 5
- sabre/dav is locked to version 4.3.1 and an update of this package was not requested.
- sabre/dav 4.3.1 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 6
- sabre/xml is locked to version 2.2.5 and an update of this package was not requested.
- sabre/xml 2.2.5 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 7
- tijsverkoyen/css-to-inline-styles is locked to version 2.2.4 and an update of this package was not requested.
- tijsverkoyen/css-to-inline-styles 2.2.4 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 8
- phar-io/manifest is locked to version 2.0.3 and an update of this package was not requested.
- phar-io/manifest 2.0.3 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 9
- phpunit/php-code-coverage is locked to version 9.2.13 and an update of this package was not requested.
- phpunit/php-code-coverage 9.2.13 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 10
- phpunit/phpunit is locked to version 9.5.16 and an update of this package was not requested.
- phpunit/phpunit 9.5.16 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 11
- theseer/tokenizer is locked to version 1.2.1 and an update of this package was not requested.
- theseer/tokenizer 1.2.1 requires ext-dom * -> it is missing from your system. Install or enable PHP's dom extension.
Problem 12
- alibabacloud/client 1.5.31 requires ext-simplexml * -> it is missing from your system. Install or enable PHP's simplexml extension.
- alibabacloud/green 1.8.958 requires alibabacloud/client ^1.5 -> satisfiable by alibabacloud/client[1.5.31].
- alibabacloud/green is locked to version 1.8.958 and an update of this package was not requested.
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.1/cli/php.ini
- /etc/php/8.1/cli/conf.d/10-opcache.ini
- /etc/php/8.1/cli/conf.d/10-pdo.ini
- /etc/php/8.1/cli/conf.d/20-calendar.ini
- /etc/php/8.1/cli/conf.d/20-ctype.ini
- /etc/php/8.1/cli/conf.d/20-curl.ini
- /etc/php/8.1/cli/conf.d/20-exif.ini
- /etc/php/8.1/cli/conf.d/20-ffi.ini
- /etc/php/8.1/cli/conf.d/20-fileinfo.ini
- /etc/php/8.1/cli/conf.d/20-ftp.ini
- /etc/php/8.1/cli/conf.d/20-gettext.ini
- /etc/php/8.1/cli/conf.d/20-iconv.ini
- /etc/php/8.1/cli/conf.d/20-phar.ini
- /etc/php/8.1/cli/conf.d/20-posix.ini
- /etc/php/8.1/cli/conf.d/20-readline.ini
- /etc/php/8.1/cli/conf.d/20-shmop.ini
- /etc/php/8.1/cli/conf.d/20-sockets.ini
- /etc/php/8.1/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.1/cli/conf.d/20-sysvsem.ini
{% endfolding %}
安装PHP拓展
sudo apt install php8.1-xml php8.1-zip php8.1-curl php8.1-dom php8.1-dev
安装 imagick
git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
make
make install
然后我 ./config
报错
百度到以下解决方法:
sudo apt-get install libmagickwand-dev libmagickcore-dev
make
sudo make install
将 extension=imagick.so
写到 php.ini
中即可。我在wsl2中没有找到相关文件,放弃了。
{% endfolding %}