facebook twitter hatena line email

Php/laravel/laravel5/インストール

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

インストール

composer create-project laravel/laravel laraveltest --prefer-dist

バージョン指定してインストール

composer create-project "laravel/laravel=5.2.*"  laraveltest --prefer-dist

nginxのconf

$ sudo vi /etc/nginx/conf.d/laraveltest.localhost.conf
server {
   listen       80;
   server_name  laraveltest.localhost;
   root /var/www/laravel/laraveltest/public;
   index  index.php index.html;
   location / {
     if (!-e $request_filename) {
       rewrite ^.*$ /index.php last;
     }
   }
   location ~* \.(jpg|jpeg|gif|png|swf|css|js|inc|ico|pdf|flv|gz|woff|html|htm|txt|xml)$ {
     root    /var/www/laravel/laraveltest/public;
     index   index.html;
     ssi     on;
     access_log off;
     break;
   }
   location ~ \.php$ {
     root /var/www/laravel/laraveltest/public;
     fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     include        fastcgi_params;
   }
}

httpdのconf

<VirtualHost *:80>
  ServerName laraveltest.localhost
  DocumentRoot "/var/www/laravel/laraveltest/public"
  HostNameLookups off
  UseCanonicalName on
  <Directory "/var/www/laravel/laraveltest/public">
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

初期設定

$ vi config/app.php
return [
  'url' => 'http://localhost',
  'timezone' => 'Asia/Tokyo',
  'locale' => 'ja',
];

権限変更

ここままだと真っ白なので・・。

テンプレートのコンパイルファイルを生成できるように

$ chmod -R 777 storage
$ chmod 777 bootstrap/cache

laravel5と真ん中に表示されれば成功

構成

your-project-name
 app
 artisan
 bootstrap
 composer.json
 composer.lock
 config
 database
 gulpfile.js
 package.json
 phpunit.xml
 public
 readme.md
 resources
 server.php
 storage
 tests
 vendor

composer.jsonメモ

$ vi composer.json

{
   "name": "laravel/laravel",
   "description": "The Laravel Framework.",
   "keywords": ["framework", "laravel"],
   "license": "MIT",
   "type": "project",
   "require": {
       "php": ">=5.5.9",
       "laravel/framework": "5.2.*"
   },
   "require-dev": {
       "fzaninotto/faker": "~1.4",
       "mockery/mockery": "0.9.*",
       "phpunit/phpunit": "~4.0",
       "symfony/css-selector": "2.8.*|3.0.*",
       "symfony/dom-crawler": "2.8.*|3.0.*"
   },
   "autoload": {
       "classmap": [
           "database"
       ],
       "psr-4": {
           "App\\": "app/"
       }
   },
   "autoload-dev": {
       "classmap": [
           "tests/TestCase.php"
       ]
   },
   "scripts": {
       "post-root-package-install": [
           "php -r \"copy('.env.example', '.env');\""
       ],
       "post-create-project-cmd": [
           "php artisan key:generate"
       ],
       "post-install-cmd": [
           "php artisan clear-compiled",
           "php artisan optimize"
       ],
       "pre-update-cmd": [
           "php artisan clear-compiled"
       ],
       "post-update-cmd": [
           "php artisan optimize"
       ]
   },
   "config": {
       "preferred-install": "dist"
   }
}

composerインストール後のキャッシュクリア

rm -f bootstrap/cache/config.php
php artisan cache:clear
composer dump-autoload

version確認

php artisan --version

git cloneしてからのセットアップ

vendorがない場合

composer update --no-scripts

参考

公式日本語サイト:http://readouble.com/laravel/4/2/0/ja/quick.html