Private PHP Packages - Setup Your Own Satis Server

Previously, we created a PHP "package", but this is useless unless we host it on Packagist, or set up our own private server for referencing them, which is what I will now show you how to do, using Satis.

Related Posts

Steps

    Install all the necessary packages.
    sudo apt-get install apache2 libapache2-mod-php5 php5 php5-cli subversion -y
    Navigate to your web folder and give yourself permission to write there.
    sudo chown $USER:www-data /var/www
    cd /var/www
    Install composer
    curl -sS https://getcomposer.org/installer | php
    Now you will see a directory called satis in /var/www
    Now install satis using composer.
    php composer.phar create-project composer/satis --stability=dev --keep-vcs
    create a file called satis.json containing all the configuration details for the packages you desire
    {
        "name": "MyDomain Packages",
        "homepage": "http://www.mydomain.com",
        "repositories": [
            {
                "type": "svn",
                "url": "svn://svn.mydomain.com/packages/CoreLibs"
            },
            {
                "type": "svn",
                "url": "svn://svn.mydomain.com/packages/Package2"
            },
            {
                "type": "svn",
                "url": "svn://svn.mydomain.com/packages/Package3"
            }
        ],
        "require-all": true
    }
    
    Now build the package list. You will need to enter your SVN username/password.
    php satis/bin/satis build satis.json .

    Configure Apache

    We need to update Apache to point to the correct directory, which is now /var/www instead of the default /var/www/html (in Ubuntu 14.04).
    sudo editor /etc/apache2/sites-enabled/000-default.conf

    [ Change DocumentRoot to /var/www ]
    Restart Apache for the changes to take effect.
    sudo service apache2 restart
    That's it! Your Satis server is now at this server's IP/domain. Now you just need to configure your firewall rules with UFW or IPtables, or even configure an Nginx reverse proxy to only allow/forward the IPs that you specify, so that only you can access the Satis server, unless you want to keep your packages open to the public.

References

No comments:

Post a Comment