Vagrant環境でLaravel-Adminをインストールするメモ

環境を設定手順です。
■ nginxの設定

```
sudo yum -y update --nogpgcheck
sudo yum -y install epel-release && sudo yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
sudo yum --enablerepo=epel install -y nginx
sudo systemctl enable nginx && sudo systemctl start nginx
```

■ PHPの設定

```
sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum install -y --enablerepo=epel,remi,remi-php72 php php-devel php-opcache php-mbstring php-mcrypt php-pdo php-gd php-mysqlnd php-fpm php-xml php-pecl-redis
php -v
PHP 7.2.19 (cli) (built: May 29 2019 11:04:13) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.19, Copyright (c) 1999-2018, by Zend Technologies
```
■ PHP-FPMの設定

```
sudo sed -i -e "s/= apache/= nginx/g" /etc/php-fpm.d/www.conf
sudo sed -i -e "s/;listen.owner = nobody/listen.owner = nginx/g" /etc/php-fpm.d/www.conf
sudo sed -i -e "s/;listen.group = nobody/listen.group = nginx/g" /etc/php-fpm.d/www.conf
sudo sed -i -e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" /etc/php-fpm.d/www.conf
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
```

■ Mysql8の設定

```
sudo yum -y remove mariadb-libs
- https://dev.mysql.com/downloads/repo/yum/

sudo rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

sudo yum install -y --enablerepo=mysql80-community mysql-community-server

sudo vim /etc/my.cnf
+ character_set_server = utf8mb4
+ default-authentication-plugin = mysql_native_password

sudo systemctl enable mysqld && sudo systemctl start  mysqld

grep -i password /var/log/mysqld.log
2019-06-23T09:47:55.368429Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 9yJ:-oxz&Gp6

mysql_secure_installation

mysql -u root -p
Enter password: 上記の新しパスーワード
```

■ SELUNUXの設定

```
sudo setenforce 0
sudo sed -i -e "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
```

■ Composerの設定

```
sudo yum install -y git unzip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
```

■ プロジェクトクローン

```
cd /Users/Projects/
git clone
cd app-cms
Vagrantfileの設定
config.vm.synced_folder "/Users/Projects/app-cms", "/var/www/app-cms", owner: 'vagrant', group: 'vagrant', mount_options: ['dmode=777', 'fmode=777']
vagrant reload
vagrant ssh
```

■ Laravelの設定

```
cd /var/www/app-cms
composer install
```

sudo vi /etc/nginx/nginx.conf

```
user nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        off;
    #tcp_nopush     on;
    client_max_body_size 20M;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen 80;
        server_name localhost.dev;
        root /var/www/app-admin/public;
	index index.php index.html index.htm;
        charset utf-8;
        location / {
            ##try_files  $uri $uri/ /index.php?_url=$uri&args;
            # for laravel
	    try_files $uri $uri/ /index.php?$query_string;
        }
        location ~ \.(php|json)$ {
            rewrite ^(.*)\.json$ $1.php;
            fastcgi_pass   unix:/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            include fastcgi_params;
            fastcgi_split_path_info     ^(.+\.php)(/.+)$;
            fastcgi_param  PATH_INFO $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param  SA_ENV local;
        }
    }
    include /etc/nginx/conf.d/*.conf;
}

```

```
sudo systemctl restart nginx
```

```
-- env ファイル --
cp .env.example .env

composer install

php artisan migrate
php artisan key:generate
sudo chmod -R 777 storage/logs/
sudo chmod -R 770 storage
sudo chmod -R 770 bootstrap/cache

-- Laravel Admin --
php artisan vendor:publish --provider="Encore\Admin\AdminServiceProvider"
php artisan admin:install

-- 初期データ登録
php artisan db:seed

https://YOURDOMAIN/admin
-- 初期接続情報
ID:admin, Password:admin
```
以上です。