CentOS8にLaravel7をインストールする
CentOS8環境にLaravel7をインストールする手順を記載してます。
環境
- OS:CentOS Linux release 8.1.1911 (Core)
- PHP:7.4.5
- Composer : 1.10.5
PHPインストール
こちらに記述してあります。
phpモジュールインストール
Laravel7を動作させるのみ必要なモジュールをインストールします。
sudo dnf install -y php-mcrypt php-pdo php-bcmath php-tokenizer php-xml php-mysqlnd php-gd php-intl php-zip php-opcache php-pecl-xdebug
Composerインストール
次にcomposerをインストールしていきます。
wget https://getcomposer.org/installer -O composer-installer.php
php composer-installer.php --filename=composer --install-dir=/usr/local/bin
念の為アップデートします。
composer self-update
バージョンを確認します。
composer -v
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.10.5 2020-04-10 11:44:22
Laravel 7 インストール
composerを利用してインストールします。
## プロジェクトフォルダを作成
sudo mkdir /var/www/html/sample
# プロジェクトを生成
composer create-project laravel/laravel /var/www/html/sample --prefer-dist
アクセス権設定
ディレクトリのアクセス権を設定します。
## フォルダに移動
cd /var/www/html/sample
## アクセス権を設定
find ./ -type d -exec chmod 755 {} \;
find ./ -type f -exec chmod 644 {} \;
laravelグループを作成して、storageディレクトリとbootstrap/cache ディレクトリの所有グループをlaravelに設定する
## グループ作成
sudo groupadd laravel
## 必要なユーザーをグループに追加
sudo gpasswd -a testuser laravel
sudo gpasswd -a apache larave
## 所有グループを変更
sudo chown -R :laravel ./storage
sudo chown -R :laravel ./bootstrap/cache
storageディレクトリとbootstrap/cache ディレクトリのアクセス権を設定
find ./storage -type d -exec chmod 775 {} \;
find ./storage -type f -exec chmod 664 {} \;
find ./bootstrap/cache -type d -exec chmod 775 {} \;
find ./bootstrap/cache -type f -exec chmod 664 {} \;
SGIDを指定して、ディレクトリ内部で作成されたファイル全てをディレクトリのSGIDで指定したグループ に設定します。
find ./storage -type d -exec chmod g+s {} \;
find ./bootstrap/cache -type d -exec chmod g+s {} \;
アクセス制御リスト(ACL) も設定して、ディレクトリやファイル作成時にアクセス権を775と664にします。
setfacl -R -d -m g::rwx ./storage
setfacl -R -d -m g::rwx ./bootstrap/cache
Laravel 7 起動
起動します。
## 起動
php artisan serve --host 0.0.0.0
ブラウザから http://プライベートIP:8000 にアクセスすると下記の画面が表示されます。
-
前の記事
Linux sudoのタイムアウト時間を変更する 2020.04.16
-
次の記事
React.js ライブラリ「react-split-pane」を使用して画面を分割する 2020.04.16
コメントを書く