0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

VirtualBox+CentOS7+Laravel9.9 の開発環境構築をする

Posted at

はじめに

この記事ではVirtualBoxを使用して、Laravelの開発環境を構築します。

VirtualBoxを使用した、CentOSの環境構築については以下の記事を参考にしてください。
VIrtualBox(Windows10)にCentOS7環境を構築し、TeraTermでssh接続をする
VirtualBox+CentOS7+Apach2.4+PHP8.1+MySQL8.0 の開発環境構築をする

環境

  • VirtualBox:7.0
  • ホストOS:Windows10
  • ゲストOS:CentOS 7.9
  • Apache:2.4.6
  • PHP:8.1.15
  • Mysql:8.0.27
  • Laravel:9.9

1.composerのインストール

composerをインストールする。

# yum install composer

composerがインストールされたことを確認。

# composer -V

2.Laravelプロジェクトの作成

gitのインストール。

# yum install -y git 

composerでLaravelのライブラリを読み込む。

# composer global require laravel/installer

Laravelのプロジェクトを作成。

# cd /var/www/html  
# composer create-project --prefer-dist "laravel/laravel=9.*"  laravel

Allowed memory size of 1610612736 bytes exhaustedエラー がでたら
以下記事が参考になります。

作成したプロジェクトのアクセス権限を変更。(本番環境時は注意)

# chmod -R 777 /var/www/html/laravel/storage

Laravelでmysqlが使用できるように.envを編集。

# vi /var/www/html/laravel/.env

(省略)
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mysqlのデータベース名(別途作成してください。)
DB_USERNAME=root
DB_PASSWORD=mysqlのパスワード

Laravelを日本語環境に変更。

# vi /var/www/html/laravel/config/app.php

(省略)
'timezone' => 'Asia/Tokyo',

(省略)
'locale' => 'ja',

DocumentRootを変更

#  vi /etc/httpd/conf/httpd.conf

(省略)
DocumentRoot "/var/www/html/laravel/public"

Apacheを再起動。

systemctl restart httpd

2.node, npm インストールとadminlte追加

node, npm インストール

# yum install epel-release
# yum install nodejs npm

バージョン管理「n」を導入

# npm install -g n
# n stable

cross-env cross-spawnをglobalでインスコ

# npm -g install cross-env cross-spawn

3.ララベル初期化

phpライブラリ

#  cd /var/www/html/laravel && composer install

JSライブラリ

# cd /var/www/html/laravel && npm install

ブラウザでhttp://{ipアドレス}に接続し、Laravelの初期画面が表示されることを確認。

以上!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?