This tutorial has moved.
Showing posts with label satis. Show all posts
Showing posts with label satis. Show all posts
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.
Docker users can use my docker-satis tutorial for a much easier deployment.
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).
+-+byobu_082.png)
[ Change DocumentRoot to /var/www ]
sudo editor /etc/apache2/sites-enabled/000-default.conf
+-+byobu_082.png)
[ 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
Creating A PHP Package
You may or may not already be using Packagist in order to create PHP packages. By converting your code into packages, it becomes faster and simpler to develop more complex applications. Since these packages will be re-used, less time will be spent writing and debugging "new" code. One of the best aspects of packages is that they can automatically updated through Composer with a call to
composer update
. This tutorial is going to cover the creation of a "package" repository in SVN that we will reference with a private Satis server, rather than using Packagist ion order to keep our packages private.
Related Posts
Steps
Create a new repository on your SVN server
svnadmin create my-repo
Check the new repository out
svn checkout svn://my.domain.com/my-repo
Navigate to within the directory that was just checked out and create the default folders that are expected by the package program trunk,branches, and tags
cd my-repo mkdir trunk mkdir branches mkdir tags
Create the src directory this will be referenced later.
mkdir trunk/src
Create the composer.json file which provides all the relevant packaging details
This must go in the top level of the codebase (e.g. top of trunk or any branch)
editor trunk/composer.json
Template
{
"name": "[vendor name]/[package name]",
"type": "library",
"description": "[description]",
"keywords": ["log","logging"],
"homepage": "[project homepage]",
"license": "none",
"authors": [
{
"name": "[author name]",
"email": "[author email]",
"homepage": "[authors website]",
"role": "[authors role]"
}
],
"require": {
"php": ">=5.x.x"
},
"autoload": {
"psr-4": {
"[vendor name]\\[package name]\\": ""
"[vendor name]\\[package name]\\": "subfolder1",
"[vendor name]\\[package name]\\": "subfolder2"
}
}
}
Example
{
"name": "Programster/CoreLibs",
"type": "library",
"description": "Core libraries for PHP 5.3+",
"keywords": ["core","library"],
"homepage": "http://www.programster.blogspot.co.uk",
"license": "none",
"authors": [
{
"name": "Programster",
"email": "my.email@gmail.com",
"homepage": "http://programster.blogspot.co.uk/",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Programster\\CoreLibs\\": ""
}
}
}
Add everything to SVN and commit it
svn add * svn commit .
Now all you have to do is add all the actual source code to the trunk directory and commit to SVN!
References
Subscribe to:
Posts
(
Atom
)