如何在 Debian 12 上安装 Symfony PHP 框架

Linux命令 Edge插件网 1年前 (2023-10-22) 283次浏览 已收录 0个评论

Symfony是一个备受推崇的PHP框架,以其灵活性,可扩展性和丰富的功能集而闻名。开发人员广泛使用它来构建 Web 应用程序,从简单的网站到复杂的企业系统。另一方面,Debian 12 是一个坚如磐石且可靠的 Linux 发行版。将 Symfony 与 Debian 12 相结合,为您提供了一个安全高效的平台来开发和部署您的 Web 应用程序。

如何在 Debian 12 上安装 Symfony PHP 框架

在 Debian 12 bookworm 上安装 Symfony PHP 框架

第 1 步。在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的非常重要:apt

<span class="pln">sudo apt update
sudo apt upgrade</span>

此命令更新软件包列表并将已安装的软件包升级到最新版本。

第 2 步。安装所需的软件包。

要成功安装Symfony Framework,你需要安装必要的软件包。运行以下命令以安装所需的软件包:

<span class="pln">sudo apt install php php</span><span class="pun">-</span><span class="pln">json php</span><span class="pun">-</span><span class="pln">ctype php</span><span class="pun">-</span><span class="pln">curl php</span><span class="pun">-</span><span class="pln">mbstring php</span><span class="pun">-</span><span class="pln">xml php</span><span class="pun">-</span><span class="pln">zip php</span><span class="pun">-</span><span class="pln">tokenizer php</span><span class="pun">-</span><span class="pln">tokenizer libpcre3 git zip unzip</span>

第 3 步。在 Debian 12安装 Symfony PHP 框架

要下载Symfony安装程序脚本,请访问Symfony官方网站。您可以使用首选的 Web 浏览器执行此操作。该网站是Symfony相关资源的主要来源,参考官方渠道以获取最可靠的信息总是一个好主意:

<span class="pln">curl </span><span class="pun">-</span><span class="pln">sS https</span><span class="pun">:</span><span class="com">//get.symfony.com/cli/installer | bash</span>

安装Symfony后,您将获得以下输出:

<span class="lit">2023</span><span class="pun">-</span><span class="lit">10</span><span class="pun">-</span><span class="lit">12</span> <span class="lit">10</span><span class="pun">:</span><span class="lit">46</span><span class="pun">:</span><span class="lit">24</span> <span class="pun">(</span><span class="lit">16.6</span><span class="pln"> MB</span><span class="pun">/</span><span class="pln">s</span><span class="pun">)</span> <span class="pun">-</span><span class="pln"> written to stdout </span><span class="pun">[</span><span class="lit">6300</span><span class="pun">/</span><span class="lit">6300</span><span class="pun">]</span>

<span class="typ">Symfony</span><span class="pln"> CLI installer

</span><span class="typ">Environment</span><span class="pln"> check
  </span><span class="pun">[*]</span><span class="pln"> cURL </span><span class="kwd">is</span><span class="pln"> installed
  </span><span class="pun">[*]</span> <span class="typ">Tar</span> <span class="kwd">is</span><span class="pln"> installed
  </span><span class="pun">[*]</span> <span class="typ">Git</span> <span class="kwd">is</span><span class="pln"> installed
  </span><span class="pun">[*]</span> <span class="typ">Your</span><span class="pln"> architecture </span><span class="pun">(</span><span class="pln">amd64</span><span class="pun">)</span> <span class="kwd">is</span><span class="pln"> supported</span>

接下来,是时候确定Symfony系统在系统上的确切位置了。这可以通过执行以下命令来实现:

<span class="kwd">export</span><span class="pln"> PATH</span><span class="pun">=</span><span class="str">"$HOME/.symfony5/bin:$PATH"</span><span class="pln">
source </span><span class="pun">~/.</span><span class="pln">bashrc</span>

第 4 步。创建Symfony项目。

现在通过在终端中运行以下命令来创建一个新的Symfony项目:

<span class="pln">symfony </span><span class="kwd">new</span><span class="pln"> project </span><span class="pun">--</span><span class="pln">full</span>

此命令将创建一个包含所有推荐包和配置的新Symfony项目。

接下来,导航到您的项目并使用以下命令运行 Web 服务器:

<span class="pln">cd project
symfony server</span><span class="pun">:</span><span class="pln">start</span>

输出:

<span class="pun">[</span><span class="pln">OK</span><span class="pun">]</span> <span class="typ">Web</span><span class="pln"> server listening                                                                                              
      </span><span class="typ">The</span> <span class="typ">Web</span><span class="pln"> server </span><span class="kwd">is</span> <span class="kwd">using</span><span class="pln"> PHP CLI </span><span class="lit">8.2</span><span class="pln">                                                                             
      http</span><span class="pun">:</span><span class="com">//127.0.0.1:8000                                                                                             </span>
                                                                                                                        

<span class="pun">[</span><span class="typ">Web</span> <span class="typ">Server</span> <span class="pun">]</span> <span class="typ">Oct</span> <span class="lit">21</span> <span class="lit">11</span><span class="pun">:</span><span class="lit">15</span><span class="pun">:</span><span class="lit">46</span> <span class="pun">|</span><span class="pln">DEBUG  </span><span class="pun">|</span><span class="pln"> PHP    </span><span class="typ">Reloading</span><span class="pln"> PHP versions 
</span><span class="pun">[</span><span class="typ">Web</span> <span class="typ">Server</span> <span class="pun">]</span> <span class="typ">Oct</span> <span class="lit">21</span> <span class="lit">11</span><span class="pun">:</span><span class="lit">15</span><span class="pun">:</span><span class="lit">66</span> <span class="pun">|</span><span class="pln">DEBUG  </span><span class="pun">|</span><span class="pln"> PHP    </span><span class="typ">Using</span><span class="pln"> PHP version </span><span class="lit">8.2</span> <span class="pun">(</span><span class="kwd">from</span> <span class="kwd">default</span><span class="pln"> version </span><span class="kwd">in</span><span class="pln"> $PATH</span><span class="pun">)</span>

第5步。访问Symfony Web UI。

打开您的网络浏览器并转到 http://localhost:8000。如果一切都配置正确,你应该看到Symfony欢迎页面。

如何在 Debian 12 上安装 Symfony PHP 框架

感谢您使用本教程在 Debian 12 Bookworm 上安装最新版本的 Symfony PHP 框架。如需其他帮助或有用的信息,我们建议您查看Symfony框架官方网站


Edge插件网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在 Debian 12 上安装 Symfony PHP 框架
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址