コンポーサーのインストールInstall Composer
LaravelはComposerを依存パッケージの管理に使用しています。ですから、Laravelを始める前に、自分の開発機にComposerを確実にインストールしておいてください。Laravel utilizes Composer[http://getcomposer.org] to manage its dependencies. So, before using Laravel, you will need to make sure you have Composer installed on your machine.
LaravelのインストールInstall Laravel
LaravelインストーラーによるインストールVia Laravel Installer
最初にComposerを使用し、Laravelインストーラーをダウンロードします。First, download the Laravel installer using Composer.
composer global require "laravel/installer=~1.1"
laravel
コマンドが端末で実行できるように、~/.composer/vendor/bin
ディレクトリーへ実行PATHを通してください。Make sure to place the
~/.composer/vendor/bin
directory in
your PATH so the laravel
executable can
be located by your system.
インストールが完了したら、あとはlaravel
new
コマンドを実行するだけで、指定したディレクトリーに真新しいLaravelプロジェクトが作成されます。例えば、laravel
new
blog
と打ち込めば、blog
というディレクトリーに、必要な依存パッケージと一緒に、Laravelがインストールされます。このインストール方法は、Composerを使うよりも多少早いです。Once installed, the simple
laravel new
command will create a fresh
Laravel installation in the directory you specify.
For instance, laravel new blog
would
create a directory named blog
containing a fresh Laravel installation with all
dependencies installed. This method of installation
is much faster than installing via
Composer:
laravel new blog
Composer Create-ProjectによるインストールVia Composer Create-Project
また、ターミナルでコンポーサーのcreate-project
コマンドを実行して、Laravelをインストールすることもできます。You may also install Laravel by
issuing the Composer create-project
command in your terminal:
composer create-project laravel/laravel --prefer-dist
サーバー要件Server Requirements
Laravelフレームワークには、多少のシステム動作要件があります。The Laravel framework has a few system requirements:
- PHP バージョン5.4以上PHP >= 5.4
- Mcrypt PHP拡張Mcrypt PHP Extension
- OpenSSL PHP拡張OpenSSL PHP Extension
- Mbstring PHP拡張Mbstring PHP Extension
いくつかのOSでは、PHP 5.5を使用する場合、PHP
JSON拡張をインストールする必要があります。Ubuntuを使用する場合、apt-get
install
php5-json
でインストールされます。As of PHP 5.5,
some OS distributions may require
you to manually install the PHP JSON
extension. When using Ubuntu, this
can be done via apt-get
install
php5-json
.
設定Configuration
インストール後に最初に行うべきことは、アプリケーションキーへランダム文字列をセットすることです。コンポーサーでLaravelをインストールした場合、key:generate
コマンドにより、多分既に設定されているでしょう。The first thing
you should do after installing
Laravel is set your application key
to a random string. If you installed
Laravel via Composer, this key has
probably already been set for you by
the key:generate
command.
**通常、この文字列は32桁です。キーは.env
設定ファイルへ設定されます。アプリケーションキーが設置されていないと、セッションや他の暗号化されるデーターは安全ではありません!Typically, this
string should be 32 characters long.
The key can be set in the
.env
environment file.
If the application key is
not set, your user sessions and
other encrypted data will not be
secure!
Laravelのその他の設定は、最初に指定する必要がありません。すぐに開発を開始しても良いのです!しかし、config/app.php
ファイルと、その中の記述を確認しておいたほうが良いでしょう。アプリケーションに合わせ変更したい、timezone
やlocal
のような多くのオプションが含まれています。Laravel needs
almost no other configuration out of
the box. You are free to get started
developing! However, you may wish to
review the
config/app.php
file and
its documentation. It contains
several options such as
timezone
and
locale
that you may
wish to change according to your
application.
Laravelをインストールし終えたら、ローカル環境の設定も済ませるべきでしょう。Once Laravel is installed, you should also configure your local environment[/docs/master/configuration#environment-configuration].
注意: 実働アプリケーションに対しては、
app.debug
をtrue
に設定してはいけません。Note: You should never have theapp.debug
configuration option set totrue
for a production application.
パーミッションPermissions
Laravelではパーミッションの設定が必要です。storageにあるフォルダー全部に対し、Webサーバーによる書き込みアクセスができるように設定して下さい。Laravel may
require some permissions to be
configured: folders within
storage
require write
access by the web server.
きれいなURLPretty URLs
ApacheApache
index.php
をURLへ付けなくても利用できるようにするため、public/.htaccess
ファイルが最初からフレームワークへ含まれています。Apacheを利用し、Laravelアプリケーションを動かす場合、mod_rewrite
モジュールを確実に有効にしてください。The framework
ships with a
public/.htaccess
file
that is used to allow URLs without
index.php
. If you use
Apache to serve your Laravel
application, be sure to enable the
mod_rewrite
module.
Laravelに付属している、.htaccess
ファイルが、皆さんのApache環境で動作しない場合は、以下の設定を試してください。If the
.htaccess
file that
ships with Laravel does not work
with your Apache installation, try
this one:
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
NginxNginx
Nginxでは、以下の仮想ホストの設定により、「きれいな」URLが使えるようになります。On Nginx, the following directive in your site configuration will allow "pretty" URLs:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
もちろん、Homesteadを使う場合は、きれいなURLが自動的に設定されます。Of course, when using Homestead[/docs/master/homestead], pretty URLs will be configured automatically.