How to setup a private Composer Repository using Satis on Ubuntu 16.04 with SSL3 min read

As the code in your project or organization grow, is a good practice to separate those concerns across different modules or packages. In order to do that you will need a private Composer Repository.

When it comes to host PHP packages you can either use a SaaS provider like packagist.com or self-hosted using Satis or Private Packagist.

In this tutorial we’re going to be covering the hole setup process of Satis as a private Composer Repository.

Step 1. Install Apache

Open your terminal and type in these commands:

That’s it. Check if apache is installed opening your browser and typing the server’s IP address. The page should display “It works!”.

Step 2. Install SSL using Let’s Encrypt

Setting up Apache to use ServerName:

First of all let’s configure apache to include ServerName. Open the apache configuration file for the default site  in “/etc/apache2/sites-enabled/000-default.conf”. Uncomment the “ServerName” parameter and change it  with the domain you want to use for your private repository. Ex: “packagist.domain.com”.

The file should look like this:

Restart apache typing this command in your console:

Installing Let’s Encrypt Client:

Let’s Encrypt client require a non-root sudo enabled-user. If you already have one you can skip adding these commands:

Log into your server using using the your sudo-enabled account. Let’s go ahead and install the official Let’s Encrypt client called Certbot.

Set up the SSL Certificate:

To obtain a certificate, run the certbot  command like so, where “packagist.domain.com” is your domain:

Follow the installation process and you should get the following message if everything is good:

You’re good to go, check your SSL connection opening your browser using your https URL.

Step 3. Install PHP and required extensions

Open your terminal and type in these commands:

Check if php is installed typing this command in your console:

You should see something like:

Finally restart apache typing this command in your console:

 

Step 4. Install Satis

In order to install Satis, type the these commands in your console:

We’re good, now we need to create the satis configuration file. Create a file named  satis.json  In /var/www/html with the following content:

Make sure to add your repositories to the “repositories” array. Now we can generate the static web pages:

Final Step. Use your private repository in your projects:

In your project’s composer.json  file add the new private repository to the “repositories” array. The final composer.json  file should like this:

 

Related: