2014-10-01 03:14:18 +05:30
---
layout: default
title: Installation
permalink: /installation/
---
# Installation
2016-03-16 02:03:44 +05:30
The recommended installation method is using [Composer ](https://getcomposer.org ).
2014-10-13 20:37:45 +05:30
In your project root just run:
2014-10-01 03:14:18 +05:30
2016-03-16 02:03:44 +05:30
{% highlight shell %}
2016-04-25 15:13:04 +05:30
composer require league/oauth2-server
2016-03-16 02:03:44 +05:30
{% endhighlight %}
2014-10-01 03:14:18 +05:30
2016-04-13 23:59:22 +05:30
Ensure that you’ ve set up your project to [autoload Composer-installed packages ](https://getcomposer.org/doc/01-basic-usage.md#autoloading ).
2016-03-16 02:03:44 +05:30
2016-03-29 13:35:49 +05:30
Depending on [which grant ](/authorization-server/which-grant/ ) you are implementing you will need to implement a number of repository interfaces. Each grant documentation page lists which repositories are required, and each repository interface has it's own documentation page.
2016-03-16 02:03:44 +05:30
2016-06-05 02:39:33 +05:30
The repositories are expected to return (on success) instances of [entity interfaces ](https://github.com/thephpleague/oauth2-server/tree/master/src/Entities ); to make integration with your existing entities and models as easy as possible though, all required methods have been implemented as traits that you can use.
2016-03-23 18:15:09 +05:30
## Generating public and private keys
To generate the private key run this command on the terminal:
{% highlight shell %}
openssl genrsa -out private.key 1024
{% endhighlight %}
2016-03-29 13:35:49 +05:30
If you want to provide a passphrase for your private key run this command instead:
{% highlight shell %}
openssl genrsa -passout pass:_passphrase_ -out private.key 1024
{% endhighlight %}
2016-03-23 18:15:09 +05:30
then extract the public key from the private key:
{% highlight shell %}
2016-03-29 13:35:49 +05:30
openssl rsa -in private.key -pubout -out public.key
{% endhighlight %}
or use your passphrase if provided on private key generation:
{% highlight shell %}
openssl rsa -in private.key -passin pass:_passphrase_ -pubout -out public.key
2016-03-23 18:15:09 +05:30
{% endhighlight %}
2016-03-29 13:35:49 +05:30
2016-03-23 18:15:09 +05:30
The private key must be kept secret (i.e. out of the web-root of the authorization server). The authorization server also requires the public key.
2016-03-29 13:35:49 +05:30
If a passphrase has been used to generate private key it must be provided to the authorization server.
The public key should be distributed to any services (for example resource servers) that validate access tokens.
2017-07-02 23:28:35 +05:30
## Generating encryption keys
2017-07-02 23:31:28 +05:30
To generate an encryption key for the `AuthorizationServer` run the following command in the terminal:
2017-07-02 23:28:35 +05:30
{% highlight shell %}
php -r 'echo base64_encode(random_bytes(32)), PHP_EOL;'
{% endhighlight %}