PHPフレームワーク · 1 min read · Sep 23, 2025
Ubuntu 22.04にSymfony PHPフレームワークをインストールする方法

Symfonyは、ウェブアプリケーションに使用される最も人気のあるPHPフレームワークの1つです。独立したコンポーネントが特徴で、他のPHPプロジェクトに簡単に統合できます。Symfonyはオープンソースソフトウェアとしてリリースされており、あらゆる規模のPHPアプリケーションを構築するのに適しています。
このチュートリアルでは、Ubuntu 22.04にSymfony PHPフレームワークをインストールする方法を示します。
前提条件
- Ubuntu 22.04を実行しているサーバー。
- 有効なドメイン名がサーバーのIPにポイントされています。
- サーバーにルートパスワードが設定されています。
PHPのインストール
SymfonyはPHPフレームワークなので、PHPをサーバーにインストールする必要があります。インストールされていない場合は、次のコマンドを使用して他の依存関係と一緒にインストールできます。
apt install php php-json php-ctype php-curl php-mbstring php-xml php-zip php-tokenizer php-tokenizer libpcre3 git zip unzipPHPと他のPHPコンポーネントがインストールされたら、次のステップに進むことができます。
Ubuntu 22.04にSymfonyをインストールする
Symfonyをインストールする最も簡単で簡単な方法は、自動インストールスクリプトからです。
次のコマンドを使用してSymfonyインストールスクリプトをダウンロードして実行できます。
wget https://get.symfony.com/cli/installer -O - | bashSymfonyがインストールされると、次の出力が得られます。
2022-12-21 10:59:24 (11.6 MB/s) - written to stdout [6100/6100]
Symfony CLI installer
Environment check
[*] cURL is installed
[*] Tar is installed
[*] Git is installed
[*] Your architecture (amd64) is supported
Download
Downloading https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_linux_amd64.tar.gz...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 5232k 100 5232k 0 0 2309k 0 0:00:02 0:00:02 --:--:-- 7400k
Uncompress binary...
Installing the binary into your home directory...
The binary was saved to: /root/.symfony5/bin/symfony
The Symfony CLI was installed successfully!
Use it as a local file:
/root/.symfony5/bin/symfony
Or add the following line to your shell configuration file:
export PATH="$HOME/.symfony5/bin:$PATH"
Or install it globally on your system:
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
Then start a new shell and run 'symfony'
次に、システム上でSymfonyのシステムパスを定義する必要があります。次のコマンドで行うことができます。
export PATH="$HOME/.symfony5/bin:$PATH"
source ~/.bashrcSymfonyプロジェクトの作成
この時点で、Symfonyはサーバーにインストールされています。次に、新しいSymfonyプロジェクトを作成して使用する必要があります。
symfony new project --full次の出力が得られます。
* Setting up the project under Git version control
(running git init /root/project)
[OK] Your project is now ready in /root/project 次に、プロジェクトに移動し、次のコマンドを使用してウェブサーバーを実行します。
cd project
symfony server:start次の出力が得られるはずです。
[OK] Web server listening
The Web server is using PHP CLI 8.1.2
http://127.0.0.1:8000
[Web Server ] Dec 21 11:01:36 |DEBUG | PHP Reloading PHP versions
[Web Server ] Dec 21 11:01:36 |DEBUG | PHP Using PHP version 8.1.2 (from default version in $PATH)
[Application] Dec 21 11:01:15 |INFO | DEPREC User Deprecated: The "Monolog\Logger" class is considered final. It may change without further notice as of its next major version. You should not extend it from "Symfony\Bridge\Monolog\Logger".
[Web Server ] Dec 21 11:01:36 |INFO | PHP listening path="/usr/bin/php8.1" php="8.1.2" port=44005
[PHP ] [Wed Dec 21 11:01:36 2022] PHP 8.1.2-1ubuntu2.9 Development Server (http://127.0.0.1:44005) started
Symfonyにアクセスする
この時点で、Symfonyサーバーが起動し、ポート8000でリッスンしています。今すぐhttp://your-server-ip:8000を使用してアクセスできます。次の画面にSymfonyのデフォルトページが表示されるはずです。

結論
おめでとうございます!Ubuntu 22.04にSymfony PHPフレームワークを正常にインストールしました。これで、Symfonyフレームワークを使用してPHPベースのウェブアプリケーションの構築を開始できます。質問があればお気軽にお尋ねください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。