Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Installing SilverStripe /

Getting SilverStripe up and running on your computer and on your web server.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Automating Installation (quiet mode?)


Go to End


5 Posts   2622 Views

Avatar
TotalNet

Community Member, 181 Posts

10 June 2009 at 11:17am

Edited: 10/06/2009 11:22am

A search of the forum does not show this particular question being asked AFAIK so here goes...

As the title suggests, I am looking for a way to automate the deployment of SS on to a production environment that I know will support it. I can create a _config.php with all the database and environment settings but this does not seem to work. I still need the installer to create DB tables etc.

I have found this documentation:
http://doc.silverstripe.org/doku.php?id=environment-management

Is this what I'm looking for?

The process I was intending to follow is:

  • 1. empty MySQL5 DB is already created with SS specific user and passwd
  • 2. externally generated "answer file" (_ss_environment.php/_config.php ?) created with settings info - DB connection info, admin user/passwd, admin email/theme plus configs for other modules
  • 3. additional modules put in the root folder
  • 4. copy the above to the webserver
  • 5. then run mysite.com/install.php

hopefully that makes sense

cheers,

Rich

Avatar
Willr

Forum Moderator, 5523 Posts

10 June 2009 at 10:17pm

Using the _ss_environement.php file is the way to manage / deploy a site. Note that usually you have 1 _ss_environment per server so this stores super globals like mysql name, server. If you have multiple sites you still use the _config file in each project for setting theme and module vars.

Avatar
TotalNet

Community Member, 181 Posts

11 June 2009 at 1:28pm

Thanks for the reply willr,

This isn't quite working the way I was expecting; the database name was not being picked up from _config.php and the admin user & password was not being used either despite comments in ConfigureFromEnv.php looking like it should. This was after setting this info in _ss_environment.php and _config.php and going to www.mysite.com/install.php

So I took a look at install.php - can't believe I've not done this before! - and the answer is right there :)

database name is set from $_SERVER['argv'][2] which is only available when run from the command line so no wonder it's always SS_mysite. The good news is it does this only if there is no 'mysql' array in the POST or GET data and the same can be done for most of the settings. So that's my answer, I can call install.php with all the settings in the URL and/or write a script that POSTs them.

I will still use _ss_environment.php as I like the idea of moving database passwords above the www root directory.

Cheers,

Rich

Avatar
bennettpr

Community Member, 37 Posts

23 February 2011 at 10:16pm

Hi Rich & Willr,

Can you clarify the solution you found?

Willr, I understand that _ss_environment.php shares db connections and admin accounts etc across sites, but am I correct in assuming that a separate db is still required for each site?

If so, is there a way to automate the install from the command line?

At the moment I have a shell script which can pass a variable into (the project name in this case). It then copies the latest release of SS into a local directory and copies across a base theme and files I tend to reuse across projects.
It then creates the assets and silverstripe-cache dirs and sets the relevant permissions as well as creating a new db and assigning a user account to it.

From there I'd love to be able to pass parameters to the install script by running something like:
> php $PROJECT/install.php databasename
and having SS generate the required db tables etc

after that the script could remove the install.php file and I'd essentially have a working SS install that I can have built and running in around 10 - 15 seconds.

Is this possible? If not, is there a better way to achieve the same result?

Thanks,
Paul

Avatar
Willr

Forum Moderator, 5523 Posts

24 February 2011 at 8:55pm

Willr, I understand that _ss_environment.php shares db connections and admin accounts etc across sites, but am I correct in assuming that a separate db is still required for each site?

Unless you use Subsites you will need 1 db for each site. Subsites stores everyone in 1 database with an extra foreign key to the site that record belongs too.

From there I'd love to be able to pass parameters to the install script by running something like:
> php $PROJECT/install.php databasename
and having SS generate the required db tables etc

Don't even bother using the installer, all that does is check requirements and get your info. If you have that information you could have a template _config.php and a .htaccess file, store these in say /sites/template/ and just adapt your script to copy those files into the new project. To build the database you can do that via the command line using sake.

For example this is one of our old internal scripts (still uses svn)

	echo `svn cp svn://svn.silverstripe.com/silverstripe/projects/_skel svn://svn.silverstripe.com/silverstripe/projects/$project -m "Created new project '$project'"`;
		`svn cp svn://svn.silverstripe.com/silverstripe/open/themes/blackcandy/trunk/blackcandy svn://svn.silverstripe.com/silverstripe/projects/$project/trunk/themes/$project -m "Creating default theme for project '$project'"`;

		echo `cd /sites/test.silverstripe.com; svn checkout svn://svn.silverstripe.com/silverstripe/projects/$project/trunk $project`;

		echo "\nCustomizing '$project'\n";
		templateFile("$project/mysite/_config.php", "%%PROJECT%%", $project);

		echo "\nBuilding database\n";
		echo `cd /sites/test/www/$project; sake dev/build`;
		`chmod 777 -R /tmp/silverstripe-cache-sites-test-www-$project`;

		echo "done\n\n";

templateFile() is a function which copies an _config.php file to that location and str_replaces the %%PROJECT%% database string and theme name.

You can also not include the $database value and just include the following line in your _ss_environment.php file

define('SS_DATABASE_CHOOSE_NAME', true);

Then it will use the sites folder name as the database name and you won't even need to customize the _config.php