Rocky Linux 9 にWeb アプリケーションフレームワーク Laravelをインストールする

環境
OSバージョンを確認します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)
# cat /etc/redhat-release Rocky Linux release 9.0 (Blue Onyx)
# cat /etc/redhat-release
Rocky Linux release 9.0 (Blue Onyx)

操作方法
1. EPELからPHP Composer をインストールします

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# dnf --enablerepo=epel -y install composer
# dnf --enablerepo=epel -y install composer
# dnf --enablerepo=epel -y install composer

2. Laravel テストプロジェクトを作成します
# mkdir test-project
# cd test-project

Laravel プロジェクト [tapp] を作成します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# composer create-project laravel/laravel tapp
No security vulnerability advisories found
> @php artisan key:generate --ansi
INFO Application key set successfully.
# composer create-project laravel/laravel tapp 略 No security vulnerability advisories found > @php artisan key:generate --ansi INFO Application key set successfully.
 # composer create-project laravel/laravel tapp
 略
 No security vulnerability advisories found
> @php artisan key:generate --ansi

   INFO  Application key set successfully.

3.Firewalld を有効にしている場合は、ポート番号「8000」の許可が必要です。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# firewall-cmd --add-port=8000/tcp
success
# firewall-cmd --runtime-to-permanent
success
# firewall-cmd --add-port=8000/tcp success # firewall-cmd --runtime-to-permanent success
# firewall-cmd --add-port=8000/tcp
success
# firewall-cmd --runtime-to-permanent
success

4.Laravel プロジェクトを起動します

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# cd tapp
# php artisan serve --host 0.0.0.0 --port=8000
INFO Server running on [http://0.0.0.0:8000].
Press Ctrl+C to stop the server
# cd tapp # php artisan serve --host 0.0.0.0 --port=8000 INFO Server running on [http://0.0.0.0:8000]. Press Ctrl+C to stop the server
# cd tapp
# php artisan serve --host 0.0.0.0 --port=8000

   INFO  Server running on [http://0.0.0.0:8000].

  Press Ctrl+C to stop the server

4.動作確認
http://(サーバーのホスト名 または IP アドレス):8000/にアクセスします
例http://192.168.71.133:8000/
Laravel画面が表示されます。

Rocky Linux 9

Posted by arkgame